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); } }
/// <summary> /// Creates an agreement. Sends it out for signatures, and returns the agreementID in the response to the client /// </summary> /// <param name="newAgreement">Information about the agreement</param> /// <returns>AgreementCreationResponse</returns> public async Task <AgreementCreationResponse> CreateAgreement(AgreementMinimalRequest newAgreement) { string serializedObject = JsonConvert.SerializeObject(newAgreement); using (StringContent content = new StringContent(serializedObject, Encoding.UTF8)) { content.Headers.Remove("Content-Type"); content.Headers.Add("Content-Type", "application/json"); HttpResponseMessage result = await client.PostAsync(apiEndpointVer + "/agreements", content).ConfigureAwait(false); if (result.IsSuccessStatusCode) { string response = await result.Content.ReadAsStringAsync().ConfigureAwait(false); AgreementCreationResponse agreement = JsonConvert.DeserializeObject <AgreementCreationResponse>(response); return(agreement); } else { string response = await result.Content.ReadAsStringAsync().ConfigureAwait(false); HandleError(result.StatusCode, response, false); return(null); } } }
private static async Task <AgreementCreationResponse> PostAgreement(IEnumerable <string> transientDocumentIDs) { HttpClient client = CreateClient(_apiAccessPoint); var fileInfos = transientDocumentIDs.Select(id => new Models.FileInfo { TransientDocumentID = id }); AgreementInfo model = new AgreementInfo { FileInfos = fileInfos, Name = "Customer Order", ParticipantSetsInfo = new[] { new ParticipantSetInfo { MemberInfos = new [] { new ParticipantInfo { Email = TestEmail }, }, Order = 1, Role = StaticData.Role.Signer, }, }, SignatureType = StaticData.SignatureType.ESign, State = StaticData.State.InProgress, }; string json = JsonConvert.SerializeObject(model); HttpResponseMessage responseMesage = await client.PostAsync("agreements", new StringContent(json, Encoding.UTF8, "application/json")); AgreementCreationResponse response = await HandleResponseMessageAsync <AgreementCreationResponse>(responseMesage); return(response); }