public async Task <AgreementCreationResponse> CreateAgreement(AgreementCreationInfo agreementCreationInfo, string messageInitiatorEmail)
        {
            var jsonContent = API.SerializeJSon <AgreementCreationInfo>(agreementCreationInfo);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(jsonContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            string json = await API.PostRest("/agreements", byteContent, messageInitiatorEmail);

            return(API.DeserializeJSon <AgreementCreationResponse>(json));
        }
        public static AgreementCreationInfo GetAgreementCreationInfoObject(string transientDocumentId, List <byte[]> lstCompendiumFiles, string agreementName, string[] arrSignerEmail,
                                                                           string messageInitiatorEmail, string urlMiscInfo)
        {
            try
            {
                AgreementCreationInfo creationInfo = new AgreementCreationInfo();
                creationInfo.documentCreationInfo = new DocumentCreationInfo();

                //Document Creation Info
                var documentCreationInfo = creationInfo.documentCreationInfo;
                documentCreationInfo.name          = agreementName;
                documentCreationInfo.signatureType = SignatureTypeEnum.ESIGN;

                string qryUrl = urlMiscInfo;
                if (!string.IsNullOrEmpty(qryUrl) && !urlMiscInfo.StartsWith("&"))
                {
                    qryUrl = "&" + qryUrl;
                }

                // TODO: read the url and code from a confir property
                //documentCreationInfo.callbackInfo = "https://akkiAdobeesignazurefx.azurewebsites.net/api/AkkiAdobeEsignAzureFx?code=5RQkWJkgnTOkOxBYo9PnKq8ZZLqr01dP3nRNuyLdGglD343Tj1kmHQ==" + qryUrl;
                documentCreationInfo.callbackInfo = AdobeRestAPI.AzureFxUrlWithCode + qryUrl;

                //FileInfo
                documentCreationInfo.fileInfos = new List <FileInfo>();
                var      fileInfos = documentCreationInfo.fileInfos;
                FileInfo fileInfo  = new FileInfo(transientDocumentId);
                fileInfos.Add(fileInfo);

                if (lstCompendiumFiles != null)
                {
                    foreach (var compFileByte in lstCompendiumFiles)
                    {
                        AdobeObject compFile = new AdobeObject();
                        var         response = compFile.AddDocument(agreementName, compFileByte, messageInitiatorEmail).Result;
                        documentCreationInfo.fileInfos.Add(new FileInfo {
                            transientDocumentId = response.transientDocumentId
                        });
                    }
                }

                documentCreationInfo.signatureFlow     = SignatureFlow.PARALLEL;
                documentCreationInfo.recipientSetInfos = new List <RecipientSetInfo>();

                // if there is only one signer and that signer  is the person who is running the worflow then use different flow and no recipient set into
                if (arrSignerEmail.Length == 1 && arrSignerEmail.Contains(messageInitiatorEmail))
                {
                    //  documentCreationInfo.signatureFlow = SignatureFlow.FILL_SIGN;
                    RecipientSetInfo recipientSetInfo = new RecipientSetInfo();
                    recipientSetInfo.recipientSetRole = RecipientRoleEnum.SIGNER;

                    RecipientSetMemberInfo setMemberInfo = new RecipientSetMemberInfo();
                    setMemberInfo.email = messageInitiatorEmail;
                    RecipientSetMemberInfo setMemberInfoSys = new RecipientSetMemberInfo();
                    setMemberInfoSys.email = AdobeRestAPI.FarmSysEmailAcc;

                    recipientSetInfo.recipientSetMemberInfos.Add(setMemberInfo);
                    recipientSetInfo.recipientSetMemberInfos.Add(setMemberInfoSys);
                    documentCreationInfo.recipientSetInfos.Add(recipientSetInfo);
                }
                else
                {
                    foreach (var signerEmail in arrSignerEmail)
                    {
                        RecipientSetInfo recipientSetInfo = new RecipientSetInfo();
                        recipientSetInfo.recipientSetRole = RecipientRoleEnum.SIGNER;
                        RecipientSetMemberInfo setMemberInfo = new RecipientSetMemberInfo();
                        setMemberInfo.email = signerEmail;
                        recipientSetInfo.recipientSetMemberInfos.Add(setMemberInfo);

                        documentCreationInfo.recipientSetInfos.Add(recipientSetInfo);
                    }
                }
                return(creationInfo);
            }
            catch (Exception e)
            {
                //log.Error("[GetAgreementCreationInfoObject]", e);
                throw;
            }
        }