コード例 #1
0
        /// <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);
                }
            }
        }
コード例 #2
0
        private AgreementCreationResponse CreateAgreement(int?creditDataId, string transientDocumentId, string recipientEmail, string agreementName)
        {
            var agreementRequest = new AgreementMinimalRequest
            {
                fileInfos = new List <AdobeSignRESTClient.Models.FileInfo>
                {
                    new AdobeSignRESTClient.Models.FileInfo
                    {
                        transientDocumentId = transientDocumentId
                    }
                },
                name = agreementName,
                participantSetsInfo = new List <ParticipantInfo>
                {
                    new ParticipantInfo
                    {
                        memberInfos = new List <MemberInfo>
                        {
                            new MemberInfo
                            {
                                email = recipientEmail
                                        //email = string.Empty
                            }
                        },
                        order = 1,
                        role  = "SIGNER"
                    }
                },
                emailOption = new EmailOption
                {
                    sendOptions = new SendOption
                    {
                        completionEmails = "NONE",
                        inFlightEmails   = "NONE",
                        initEmails       = "NONE"
                    }
                },

                externalId = new ExternalId
                {
                    id = creditDataId.Value.ToString()
                },
                signatureType = "ESIGN",
                state         = "IN_PROCESS"
                                //state="AUTHORING"
            };

            try
            {
                var response = client.CreateAgreement(creditDataId, agreementRequest).Result;
                repository.AddAdobeSignLog(creditDataId, "CreateAgreement", agreementRequest.ToJson(), response);
                return(response);
            }
            catch (Exception e)
            {
                repository.AddAdobeSignLog(creditDataId, "CreateAgreement", agreementRequest.ToJson(), e);
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #3
0
        //[HttpPost]
        //[Route("api/AdobeSign/CreateAgreement")]
        public async Task <AgreementCreationResponse> CreateAgreement([FromBody] AgreementMinimalRequest agreement)
        {
            Task <AgreementCreationResponse> response;

            try
            {
                this.RefreshToken(null);
                response = Task.FromResult(client.CreateAgreement(null, agreement).Result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(await response);
        }
コード例 #4
0
        public AgreementCreationResponse CreateAgreement(string transientDocumentId, string agreementName, string recipientEmail, int AgreementId)
        {
            var newAgreementRequest = new RestRequest("CreateAgreement", Method.POST);
            var agreementRequest    = new AgreementMinimalRequest
            {
                fileInfos = new List <FileInfo>
                {
                    new FileInfo
                    {
                        transientDocumentId = transientDocumentId
                    }
                },
                name = agreementName,
                participantSetsInfo = new List <ParticipantInfo>
                {
                    new ParticipantInfo
                    {
                        memberInfos = new List <MemberInfo>
                        {
                            new MemberInfo
                            {
                                email = recipientEmail
                            }
                        },
                        order = 1,
                        role  = "SIGNER"
                    }
                },
                signatureType = "ESIGN",
                state         = "IN_PROCESS"
                                //state="AUTHORING"
            };

            newAgreementRequest.RequestFormat = DataFormat.Json;
            newAgreementRequest.AddJsonBody(agreementRequest);

            IRestResponse <AgreementCreationResponse> agreementResponse = client.Execute <AgreementCreationResponse>(newAgreementRequest);

            //log
            repository.AddAdobeSignLog("CreateAgreement", agreementRequest.ToJson(), agreementResponse.Data.ToJson());

            return(agreementResponse.Data);
        }
コード例 #5
0
        public async Task <AgreementCreationResponse> CreateAgreement([FromBody] AgreementMinimalRequest agreement)
        {
            Task <AgreementCreationResponse> response;

            try
            {
                await this.RefreshTokenAsync().ConfigureAwait(true);

                response = Task.FromResult(client.CreateAgreement(agreement).Result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }


            return(await response);
            //client.CreateAgreement();
        }