private static async Task RunAsync() { //Get base uri info BaseUriInfo uriInfo = await GetBaseUri(); _apiAccessPoint = uriInfo.ApiAccessPoint; //Create Webhook WebhookCreationResponse webhookCreationResponse = await CreateWebhook(); Console.WriteLine("Webhook ID: " + webhookCreationResponse.ID); ////Upload document TransientDocumentResponse transientDocumentResponse1 = await PostTransientDocument(FilePath1); TransientDocumentResponse transientDocumentResponse2 = await PostTransientDocument(FilePath2); var docIds = new[] { transientDocumentResponse1.TransientDocumentID, transientDocumentResponse2.TransientDocumentID }; ////Create agreement and send email AgreementCreationResponse agreementCreationResponse = await PostAgreement(docIds); Console.WriteLine("Agreement ID: " + agreementCreationResponse.ID); await DownloadFile("CBJCHBCAABAAYumJeqRwtbNpk1emzfIpBCdNrw0F55e1"); //Delete Webhook if (webhookCreationResponse.IsSuccess) { await DeleteWebhook(webhookCreationResponse.ID); } }
private static async Task <WebhookCreationResponse> CreateWebhook() { HttpClient client = CreateClient(_apiAccessPoint); WebhookInfo model = new WebhookInfo { Name = "Webhook 1", Scope = StaticData.Scope.User, State = "ACTIVE", WebhookSubscriptionEvents = new[] { //StaticData.Event.AgreementCreated, StaticData.Event.AgreementActionCompleted, }, WebhookUrlInfo = new WebhookUrlInfo { Url = AzureFunctionUrl }, ApplicationName = "ApplicationName", ApplicationDisplayName = "ApplicationDisplayName", WebhookConditionalParams = new WebhookConditionalParams { WebhookAgreementEvents = new WebhookAgreementEvents { IncludeDetailedInfo = true, //IncludeDocumentsInfo = true, IncludeSignedDocuments = true, } } }; string json = JsonConvert.SerializeObject(model); HttpResponseMessage responseMesage = await client.PostAsync("webhooks", new StringContent(json, Encoding.UTF8, "application/json")); WebhookCreationResponse response = await HandleResponseMessageAsync <WebhookCreationResponse>(responseMesage); return(response); }