Example #1
0
        public EnvelopeTemplate BuildTemplate(string rootDir)
        {
            var envelopeTemplate = new EnvelopeTemplate
            {
                Name         = "Tuition Reimbursement",
                EmailSubject = "Please sign this document",
                Documents    = new List <Document> {
                    new Document
                    {
                        DocumentBase64 = Convert.ToBase64String(File.ReadAllBytes(rootDir + _templatePath)),
                        Name           = "Tuition Reimbursement",
                        FileExtension  = "docx",
                        DocumentId     = "1"
                    }
                },

                Recipients = new Recipients
                {
                    Signers = new List <Signer>
                    {
                        new Signer
                        {
                            RecipientId  = "1",
                            RoleName     = "Employee",
                            RoutingOrder = "1",
                            Tabs         = CreateTabs()
                        }
                    }
                }
            };

            return(envelopeTemplate);
        }
Example #2
0
        public CreateEnvelopeResponse CreateEnvelope(
            DocumentType type,
            string accountId,
            string userId,
            LoginType loginType,
            UserDetails additionalUser,
            string redirectUrl,
            string pingAction)
        {
            if (accountId == null)
            {
                throw new ArgumentNullException(nameof(accountId));
            }
            if (userId == null)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            string      rootDir     = _configuration.GetValue <string>(WebHostDefaults.ContentRootKey);
            UserDetails userDetails = _userService.GetUserDetails(accountId, userId, loginType);

            var templateHandler = GetTemplateHandler(type);
            EnvelopeTemplate   envelopeTemplate = templateHandler.BuildTemplate(rootDir);
            EnvelopeDefinition envelope         = templateHandler.BuildEnvelope(userDetails, additionalUser);

            if (type == DocumentType.I9 && loginType == LoginType.JWT)
            {
                EnableIDV(accountId, envelopeTemplate, "New Hire");
            }

            var listTemplates         = _docuSignApiProvider.TemplatesApi.ListTemplates(accountId);
            EnvelopeTemplate template = listTemplates?.EnvelopeTemplates?.FirstOrDefault(x => x.Name == templateHandler.TemplateName);

            if (template != null)
            {
                envelope.TemplateId = template.TemplateId;
            }
            else
            {
                TemplateSummary templateSummary = _docuSignApiProvider.TemplatesApi.CreateTemplate(accountId, envelopeTemplate);
                envelope.TemplateId = templateSummary.TemplateId;
            }
            EnvelopeSummary envelopeSummary = _docuSignApiProvider.EnvelopApi.CreateEnvelope(accountId, envelope);

            if (type != DocumentType.I9)
            {
                ViewUrl recipientView = _docuSignApiProvider.EnvelopApi.CreateRecipientView(
                    accountId,
                    envelopeSummary.EnvelopeId,
                    BuildRecipientViewRequest(
                        userDetails.Email,
                        userDetails.Name,
                        redirectUrl,
                        pingAction)
                    );
                return(new CreateEnvelopeResponse(recipientView.Url, envelopeSummary.EnvelopeId));
            }

            return(new CreateEnvelopeResponse(string.Empty, envelopeSummary.EnvelopeId));
        }
        private EnvelopeDefinition CreateEnvelopeFromTemplate(EnvelopeTemplate docusignTemplate, SampleCustomer customer)
        {
            var envelopeDefinition = new EnvelopeDefinition
            {
                TemplateId    = docusignTemplate.TemplateId,
                Status        = "sent",
                TemplateRoles = new List <TemplateRole>
                {
                    new TemplateRole
                    {
                        Email    = customer.Email,
                        Name     = customer.Name,
                        RoleName = "Signer",
                        Tabs     = new Tabs(TitleTabs: new List <Title> {
                            new Title {
                                Value = customer.Title
                            }
                        })
                    }
                },
            };

            // If we are using embedded signing, then the signer id in the envelope must match the signer id in the ReceipientView
            if (!string.IsNullOrEmpty(customer.SignerId))
            {
                envelopeDefinition.TemplateRoles[0].ClientUserId = customer.SignerId;
            }

            return(envelopeDefinition);
        }
Example #4
0
        internal static EnvelopeTemplate CreateDefaultTemplate(string templateName = null)
        {
            // Read a file from disk to use as a document.

            EnvelopeTemplate templateDef = new EnvelopeTemplate();

            byte[] fileBytes = File.ReadAllBytes(TestConfig.SignTest1File);

            templateDef.EmailSubject = "Template " + DateTime.Now.ToString();
            templateDef.EnvelopeTemplateDefinition = new EnvelopeTemplateDefinition();

            string tempName = templateName;

            if (tempName == null)
            {
                tempName = "Template Name " + DateTime.Now.ToString();
            }
            templateDef.EnvelopeTemplateDefinition.Name = tempName;

            Document doc = new Document();

            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name           = "TestFile.pdf";
            doc.DocumentId     = "1";

            templateDef.Documents = new List <Document>();
            templateDef.Documents.Add(doc);

            // Add a recipient to sign the documeent
            Signer signer = new Signer();

            signer.RoleName    = "Signer1";
            signer.RecipientId = "1";



            // Create a SignHere tab somewhere on the document for the signer to sign
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List <SignHere>();
            SignHere signHere = new SignHere();

            signHere.DocumentId  = "1";
            signHere.PageNumber  = "1";
            signHere.RecipientId = "1";
            signHere.XPosition   = "200";
            signHere.YPosition   = "100";
            signHere.ScaleValue  = "0.5";
            signer.Tabs.SignHereTabs.Add(signHere);

            templateDef.Recipients         = new Recipients();
            templateDef.Recipients.Signers = new List <Signer>();
            templateDef.Recipients.Signers.Add(signer);
            return(templateDef);
        }
Example #5
0
        public void JwtGetTemplate_CorrectAccountIdAndTemplateId_ReturnEnvelopeTemplate()
        {
            EnvelopeTemplateResults envelopeTemplateResults = _templatesApi.ListTemplates(_testConfig.AccountId);
            string templateId = envelopeTemplateResults.EnvelopeTemplates.FirstOrDefault()?.TemplateId;

            Assert.IsNotNull(envelopeTemplateResults?.EnvelopeTemplates);
            Assert.IsNotNull(templateId);

            EnvelopeTemplate envelopeTemplate = _templatesApi.Get(_testConfig.AccountId, templateId);

            Assert.AreEqual(envelopeTemplate?.TemplateId, templateId);
        }
Example #6
0
        private (bool createdNewTemplate, string templateId, string resultsTemplateName) DoWork(
            string accessToken, string basePath, string accountId)
        {
            // Data for this method
            // accessToken
            // basePath
            // accountId


            // Step 1. List templates to see if ours exists already
            var config = new Configuration(new ApiClient(basePath));

            config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
            TemplatesApi templatesApi = new TemplatesApi(config);

            TemplatesApi.ListTemplatesOptions options = new TemplatesApi.ListTemplatesOptions();
            //options.searchText = "Example Signer and CC template";
            options.searchText = "CoD"; //Added by DT
            EnvelopeTemplateResults results = templatesApi.ListTemplates(accountId, options);

            string templateId;
            string resultsTemplateName;
            bool   createdNewTemplate;

            // Step 2. Process results
            if (int.Parse(results.ResultSetSize) > 0)
            {
                // Found the template! Record its id
                templateId          = results.EnvelopeTemplates[0].TemplateId;
                resultsTemplateName = results.EnvelopeTemplates[0].Name;
                createdNewTemplate  = false;
            }
            else
            {
                // No template! Create one!
                EnvelopeTemplate templateReqObject = MakeTemplate(templateName);

                TemplateSummary template = templatesApi.CreateTemplate(accountId, templateReqObject);

                // Retrieve the new template Name / TemplateId
                EnvelopeTemplateResults templateResults = templatesApi.ListTemplates(accountId, options);
                templateId          = templateResults.EnvelopeTemplates[0].TemplateId;
                resultsTemplateName = templateResults.EnvelopeTemplates[0].Name;
                createdNewTemplate  = true;
            }

            return(createdNewTemplate : createdNewTemplate,
                   templateId : templateId, resultsTemplateName : resultsTemplateName);
        }
Example #7
0
        private void EnableIDV(string accountId, EnvelopeTemplate envelopeTemplate, string roleName)
        {
            AccountIdentityVerificationResponse idvResponse = _docuSignApiProvider.AccountsApi.GetAccountIdentityVerification(accountId);
            var workflowId = idvResponse.IdentityVerification.FirstOrDefault()?.WorkflowId;

            if (workflowId == null)
            {
                throw new IDVException("IdentityVerification workflow is not found. Check that IDV is enabled in DocuSign account.");
            }
            foreach (Signer recipient in envelopeTemplate.Recipients.Signers.Where(x => x.RoleName == roleName))
            {
                recipient.IdentityVerification = new RecipientIdentityVerification
                {
                    WorkflowId = workflowId
                };
            }
        }
Example #8
0
        internal static EnvelopeTemplate CreateDefaultTemplate(string templateName = null)
        {
            // Read a file from disk to use as a document.

            EnvelopeTemplate templateDef = new EnvelopeTemplate();
            byte[] fileBytes = File.ReadAllBytes(TestConfig.SignTest1File);

            templateDef.EmailSubject = "Template " + DateTime.Now.ToString();
            templateDef.EnvelopeTemplateDefinition = new EnvelopeTemplateDefinition();

            string tempName = templateName;
            if (tempName == null) tempName = "Template Name " + DateTime.Now.ToString();
            templateDef.EnvelopeTemplateDefinition.Name = tempName;

            Document doc = new Document();
            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name = "TestFile.pdf";
            doc.DocumentId = "1";

            templateDef.Documents = new List<Document>();
            templateDef.Documents.Add(doc);

            // Add a recipient to sign the documeent
            Signer signer = new Signer();
            signer.RoleName = "Signer1";
            signer.RecipientId = "1";

            // Create a SignHere tab somewhere on the document for the signer to sign
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List<SignHere>();
            SignHere signHere = new SignHere();
            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.RecipientId = "1";
            signHere.XPosition = "200";
            signHere.YPosition = "100";
            signer.Tabs.SignHereTabs.Add(signHere);

            templateDef.Recipients = new Recipients();
            templateDef.Recipients.Signers = new List<Signer>();
            templateDef.Recipients.Signers.Add(signer);
            return templateDef;
        }
Example #9
0
        public EnvelopeSummary GenerateDocument(string name, string email)
        {
            var docuSignClient = new DocuSignClient(this.DocuSignCredentials);
            var accountId      = docuSignClient.AccountId;

            //get TAB's (requiredFields) from document
            TemplatesApi     templateInstanceApi = new TemplatesApi();
            EnvelopeTemplate templateBase        = templateInstanceApi.Get(accountId, this.DocuSignTemplate.TemplateId);

            Tabs requiredFields = new Tabs();

            if (templateBase != null && templateBase.Recipients != null && templateBase.Recipients.Signers.Any())
            {
                requiredFields = templateBase.Recipients.Signers.FirstOrDefault().Tabs;
            }

            // assign recipient to template role by setting name, email, and role name.  Note that the
            // template role name must match the placeholder role name saved in your account template.
            List <TemplateRole> templateRoles = this.DocuSignTemplate.TemplateRoleNames.Select(m => new TemplateRole
            {
                Email    = email,
                Name     = name,
                RoleName = m,
                Tabs     = requiredFields
            }).ToList();

            // create a new envelope which we will use to send the signature request
            EnvelopeDefinition envelope = new EnvelopeDefinition
            {
                EmailSubject  = this.EmailTemplate.Subject,
                EmailBlurb    = this.EmailTemplate.MessageBody,
                TemplateId    = this.DocuSignTemplate.TemplateId,
                TemplateRoles = templateRoles,
                Status        = "sent"
            };

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            var envelopesApi = new EnvelopesApi();

            return(envelopesApi.CreateEnvelope(accountId, envelope));
        }
        /// <summary>
        /// Generates a new DocuSign Template based on static information in this class
        /// </summary>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <returns>Template name, templateId and a flag to indicate if this is a new template or it exited prior to calling this method</returns>
        public static (bool createdNewTemplate, string templateId, string resultsTemplateName) CreateTemplate(string accessToken, string basePath, string accountId)
        {
            // Step 1. List templates to see if ours exists already
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            TemplatesApi templatesApi = new TemplatesApi(apiClient);

            TemplatesApi.ListTemplatesOptions options = new TemplatesApi.ListTemplatesOptions();
            options.searchText = "Example Signer and CC template";
            EnvelopeTemplateResults results = templatesApi.ListTemplates(accountId, options);

            string templateId;
            string resultsTemplateName;
            bool   createdNewTemplate;

            // Step 2. Process results
            if (int.Parse(results.ResultSetSize) > 0)
            {
                // Found the template! Record its id
                templateId          = results.EnvelopeTemplates[0].TemplateId;
                resultsTemplateName = results.EnvelopeTemplates[0].Name;
                createdNewTemplate  = false;
            }
            else
            {
                // No template! Create one!
                EnvelopeTemplate templateReqObject = MakeTemplate(templateName);

                TemplateSummary template = templatesApi.CreateTemplate(accountId, templateReqObject);

                // Retrieve the new template Name / TemplateId
                EnvelopeTemplateResults templateResults = templatesApi.ListTemplates(accountId, options);
                templateId          = templateResults.EnvelopeTemplates[0].TemplateId;
                resultsTemplateName = templateResults.EnvelopeTemplates[0].Name;
                createdNewTemplate  = true;
            }

            return(createdNewTemplate : createdNewTemplate,
                   templateId : templateId, resultsTemplateName : resultsTemplateName);
        }
Example #11
0
        private List <TemplateRole> GetDocuSignTemplateRoles(string accountId, string clientName, string clientEmail, string brokerName, string brokerEmail)
        {
            //get TAB's (requiredFields) from document
            var templateInstanceApi       = new TemplatesApi();
            EnvelopeTemplate templateBase = templateInstanceApi.Get(accountId, TemplateId);

            List <TemplateRole> templateRoles = new List <TemplateRole>();

            if (templateBase != null && templateBase.Recipients != null && templateBase.Recipients.Signers.Any())
            {
                foreach (var signer in templateBase.Recipients.Signers)
                {
                    if (signer.RoleName.Contains("Broker"))
                    {
                        templateRoles.Add(new TemplateRole
                        {
                            Name         = brokerName,
                            Email        = brokerEmail,
                            RoleName     = "Broker",
                            Tabs         = signer.Tabs,
                            RoutingOrder = "99"
                        });
                    }
                    else
                    {
                        templateRoles.Add(new TemplateRole
                        {
                            Name         = clientName,
                            Email        = clientEmail,
                            RoleName     = "Cliente",
                            Tabs         = signer.Tabs,
                            RoutingOrder = "1"
                        });
                    }
                }
            }

            return(templateRoles);
        }
        public void CreateTemplateTest()
        {
            try
            {
                AuthenticationApiTests authTests = new AuthenticationApiTests();
                authTests.LoginTest();

                EnvelopeTemplate templateDef = Utils.CreateDefaultTemplate();

                TemplatesApi    templatesApi = new TemplatesApi();
                TemplateSummary tempSummary  = templatesApi.CreateTemplate(TestConfig.AccountId, templateDef);
                Assert.IsNotNull(tempSummary);
                Assert.IsNotNull(tempSummary.TemplateId);
                Trace.WriteLine("TemplateSummary: " + tempSummary.ToJson());
            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                // FAILS - API-3002 submitted.
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
Example #13
0
        /// <summary>
        /// Creates the env definition.
        /// </summary>
        /// <param name="templateId">The template identifier.</param>
        /// <param name="templateRolesList">The template roles list.</param>
        /// <param name="envTemplate">The env template.</param>
        /// <returns>EnvelopeDefinition.</returns>
        public EnvelopeDefinition CreateEnvDef(string templateId, List <TemplateRole> templateRolesList, EnvelopeTemplate envTemplate)
        {
            var envDef = new EnvelopeDefinition
            {
                TemplateId    = templateId,
                TemplateRoles = templateRolesList,
                EmailSubject  = envTemplate.EmailSubject,
                Status        = "sent"
            };

            return(envDef);
        }
        private static EnvelopeTemplate MakeTemplate(string resultsTemplateName)
        {
            // Data for this method
            // resultsTemplateName


            // document 1 (pdf) has tag /sn1/
            //
            // The template has two recipient roles.
            // recipient 1 - signer
            // recipient 2 - cc
            // The template will be sent first to the signer.
            // After it is signed, a copy is sent to the cc person.
            // read file from a local directory
            // The reads could raise an exception if the file is not available!
            // add the documents
            Document doc    = new Document();
            string   docB64 = Convert.ToBase64String(System.IO.File.ReadAllBytes("World_Wide_Corp_fields.pdf"));

            doc.DocumentBase64 = docB64;
            doc.Name           = "Lorem Ipsum"; // can be different from actual file name
            doc.FileExtension  = "pdf";
            doc.DocumentId     = "1";

            // create a signer recipient to sign the document, identified by name and email
            // We're setting the parameters via the object creation
            Signer signer1 = new Signer();

            signer1.RoleName     = "signer";
            signer1.RecipientId  = "1";
            signer1.RoutingOrder = "1";
            // routingOrder (lower means earlier) determines the order of deliveries
            // to the recipients. Parallel routing order is supported by using the
            // same integer as the order for two or more recipients.

            // create a cc recipient to receive a copy of the documents, identified by name and email
            // We're setting the parameters via setters
            CarbonCopy cc1 = new CarbonCopy();

            cc1.RoleName     = "cc";
            cc1.RoutingOrder = "2";
            cc1.RecipientId  = "2";
            // Create fields using absolute positioning:
            SignHere signHere = new SignHere();

            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.XPosition  = "191";
            signHere.YPosition  = "148";

            Checkbox check1 = new Checkbox();

            check1.DocumentId = "1";
            check1.PageNumber = "1";
            check1.XPosition  = "75";
            check1.YPosition  = "417";
            check1.TabLabel   = "ckAuthorization";

            Checkbox check2 = new Checkbox();

            check2.DocumentId = "1";
            check2.PageNumber = "1";
            check2.XPosition  = "75";
            check2.YPosition  = "447";
            check2.TabLabel   = "ckAuthentication";

            Checkbox check3 = new Checkbox();

            check3.DocumentId = "1";
            check3.PageNumber = "1";
            check3.XPosition  = "75";
            check3.YPosition  = "478";
            check3.TabLabel   = "ckAgreement";

            Checkbox check4 = new Checkbox();

            check4.DocumentId = "1";
            check4.PageNumber = "1";
            check4.XPosition  = "75";
            check4.YPosition  = "508";
            check4.TabLabel   = "ckAcknowledgement";

            List list1 = new List();

            list1.DocumentId = "1";
            list1.PageNumber = "1";
            list1.XPosition  = "142";
            list1.YPosition  = "291";
            list1.Font       = "helvetica";
            list1.FontSize   = "size14";
            list1.TabLabel   = "list";
            list1.Required   = "false";
            list1.ListItems  = new List <ListItem>
            {
                new ListItem {
                    Text = "Red", Value = "Red"
                },
                new ListItem {
                    Text = "Orange", Value = "Orange"
                },
                new ListItem {
                    Text = "Yellow", Value = "Yellow"
                },
                new ListItem {
                    Text = "Green", Value = "Green"
                },
                new ListItem {
                    Text = "Blue", Value = "Blue"
                },
                new ListItem {
                    Text = "Indigo", Value = "Indigo"
                },
                new ListItem {
                    Text = "Violet", Value = "Violet"
                },
            };
            // The SDK can't create a number tab at this time. Bug DCM-2732
            // Until it is fixed, use a text tab instead.
            //   , number = docusign.Number.constructFromObject({
            //         documentId: "1", pageNumber: "1", xPosition: "163", yPosition: "260",
            //         font: "helvetica", fontSize: "size14", tabLabel: "numbersOnly",
            //         height: "23", width: "84", required: "false"})
            Text textInsteadOfNumber = new Text();

            textInsteadOfNumber.DocumentId = "1";
            textInsteadOfNumber.PageNumber = "1";
            textInsteadOfNumber.XPosition  = "153";
            textInsteadOfNumber.YPosition  = "260";
            textInsteadOfNumber.Font       = "helvetica";
            textInsteadOfNumber.FontSize   = "size14";
            textInsteadOfNumber.TabLabel   = "numbersOnly";
            textInsteadOfNumber.Height     = "23";
            textInsteadOfNumber.Width      = "84";
            textInsteadOfNumber.Required   = "false";

            RadioGroup radioGroup = new RadioGroup();

            radioGroup.DocumentId = "1";
            radioGroup.GroupName  = "radio1";

            radioGroup.Radios = new List <Radio>
            {
                new Radio {
                    PageNumber = "1", Value = "white", XPosition = "142", YPosition = "384", Required = "false"
                },
                new Radio {
                    PageNumber = "1", Value = "red", XPosition = "74", YPosition = "384", Required = "false"
                },
                new Radio {
                    PageNumber = "1", Value = "blue", XPosition = "220", YPosition = "384", Required = "false"
                }
            };

            Text text = new Text();

            text.DocumentId = "1";
            text.PageNumber = "1";
            text.XPosition  = "153";
            text.YPosition  = "230";
            text.Font       = "helvetica";
            text.FontSize   = "size14";
            text.TabLabel   = "text";
            text.Height     = "23";
            text.Width      = "84";
            text.Required   = "false";

            // Tabs are set per recipient / signer
            Tabs signer1Tabs = new Tabs();

            signer1Tabs.CheckboxTabs = new List <Checkbox>
            {
                check1, check2, check3, check4
            };

            signer1Tabs.ListTabs = new List <List> {
                list1
            };
            // numberTabs: [number],
            signer1Tabs.RadioGroupTabs = new List <RadioGroup> {
                radioGroup
            };
            signer1Tabs.SignHereTabs = new List <SignHere> {
                signHere
            };
            signer1Tabs.TextTabs = new List <Text> {
                text, textInsteadOfNumber
            };

            signer1.Tabs = signer1Tabs;

            // Add the recipients to the env object
            Recipients recipients = new Recipients();

            recipients.Signers = new List <Signer> {
                signer1
            };
            recipients.CarbonCopies = new List <CarbonCopy> {
                cc1
            };


            // create the overall template definition
            EnvelopeTemplate template = new EnvelopeTemplate();

            // The order in the docs array determines the order in the env
            template.Description = "Example template created via the API";
            template.Name        = resultsTemplateName;
            template.Documents   = new List <Document> {
                doc
            };
            template.EmailSubject = "Please sign this document";
            template.Recipients   = recipients;
            template.Status       = "created";


            return(template);
        }
Example #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.CompositeTemplates = new List <CompositeTemplate>();
            CompositeTemplate ct = new CompositeTemplate();

            ct.CompositeTemplateId = "1";

            ct.ServerTemplates = new List <ServerTemplate>();
            ServerTemplate st = new ServerTemplate();

            st.Sequence = "1";

            ct.InlineTemplates = new List <InlineTemplate>();
            InlineTemplate it = new InlineTemplate();

            it.Sequence           = "1";
            it.Recipients         = new Recipients();
            it.Recipients.Signers = new List <Signer>();

            Signer Signer1 = new Signer();

            Signer1.RecipientId         = "1";
            Signer1.Tabs                = new Tabs();
            Signer1.Tabs.TextTabs       = new List <Text>();
            Signer1.Tabs.CheckboxTabs   = new List <Checkbox>();
            Signer1.Tabs.ListTabs       = new List <List>();
            Signer1.Tabs.RadioGroupTabs = new List <RadioGroup>();
            Signer Signer2 = new Signer();

            Signer2.RecipientId         = "2";
            Signer2.Tabs                = new Tabs();
            Signer2.Tabs.TextTabs       = new List <Text>();
            Signer2.Tabs.CheckboxTabs   = new List <Checkbox>();
            Signer2.Tabs.ListTabs       = new List <List>();
            Signer2.Tabs.RadioGroupTabs = new List <RadioGroup>();

            const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

            foreach (string key in Request.Form)
            {
                if (key.Length > 9)
                {
                    switch (key.Substring(0, 10))
                    {
                    case "signer1_us":
                        Signer1.Name = Request[key];
                        break;

                    case "signer1_em":
                        Signer1.Email = Request[key];
                        break;

                    case "signer1_ro":
                        Signer1.RoleName       = Request[key];
                        envelope.dsSigner1Role = Request[key];
                        break;

                    case "signer1_ty":
                        if (Request[key] == "embedded")
                        {
                            Random random1 = new Random();
                            envelope.dsSigner1CID = new string(Enumerable.Repeat(chars, 10)
                                                               .Select(s => s[random1.Next(s.Length)]).ToArray());
                            Signer1.ClientUserId = envelope.dsSigner1CID;
                        }
                        break;

                    case "signer1_au":
                        envelope.dsSigner1AuthMethod = Request[key];
                        break;

                    case "signer1_nu":
                        envelope.dsSigner1AuthNumber = Request[key];
                        break;

                    case "signer1_si":
                        envelope.dsSigner1SP = Request[key];
                        break;

                    case "signer1_tx":
                        Text   tempText1    = new Text();
                        string tempTxtLabel = key;
                        tempTxtLabel       = tempTxtLabel.Substring(12);
                        tempText1.TabLabel = tempTxtLabel;
                        tempText1.Value    = Request[key];
                        Signer1.Tabs.TextTabs.Add(tempText1);
                        break;

                    case "signer1_rb":
                        RadioGroup tempRG1     = new RadioGroup();
                        string     tempRBLabel = key;
                        tempRBLabel       = tempRBLabel.Substring(11);
                        tempRG1.GroupName = tempRBLabel;
                        tempRG1.Radios    = new List <Radio>();
                        Radio tempRB1 = new Radio();
                        tempRB1.Selected = "true";
                        tempRB1.Value    = Request[key];
                        tempRG1.Radios.Add(tempRB1);
                        Signer1.Tabs.RadioGroupTabs.Add(tempRG1);
                        break;

                    case "signer1_li":
                        List   tempList1     = new List();
                        string tempListLabel = key;
                        tempListLabel      = tempListLabel.Substring(13);
                        tempList1.TabLabel = tempListLabel;
                        tempList1.Value    = Request[key];
                        Signer1.Tabs.ListTabs.Add(tempList1);
                        break;

                    case "signer1_cb":
                        Checkbox tempCB1     = new Checkbox();
                        string   tempCBLabel = key;
                        tempCBLabel      = tempCBLabel.Substring(11);
                        tempCB1.TabLabel = tempCBLabel;
                        tempCB1.Selected = "true";
                        Signer1.Tabs.CheckboxTabs.Add(tempCB1);
                        break;


                    case "signer2_us":
                        Signer2.Name           = Request[key];
                        envelope.dsSigner2Name = Signer2.Name;
                        break;

                    case "signer2_em":
                        Signer2.Email           = Request[key];
                        envelope.dsSigner2Email = Request[key];
                        break;

                    case "signer2_ro":
                        Signer2.RoleName       = Request[key];
                        envelope.dsSigner2Role = Request[key];
                        break;

                    case "signer2_ty":
                        if (Request[key] == "embedded")
                        {
                            Random random2 = new Random();
                            envelope.dsSigner2CID = new string(Enumerable.Repeat(chars, 10)
                                                               .Select(s => s[random2.Next(s.Length)]).ToArray());
                            Signer2.ClientUserId = envelope.dsSigner2CID;
                        }
                        break;

                    case "signer2_au":
                        envelope.dsSigner2AuthMethod = Request[key];
                        break;

                    case "signer2_nu":
                        envelope.dsSigner2AuthNumber = Request[key];
                        break;

                    case "signer2_si":
                        envelope.dsSigner2SP = Request[key];
                        break;

                    case "signer2_tx":
                        Text   tempText2     = new Text();
                        string tempTxtLabel2 = key;
                        tempTxtLabel2      = tempTxtLabel2.Substring(12);
                        tempText2.TabLabel = tempTxtLabel2;
                        tempText2.Value    = Request[key];
                        Signer2.Tabs.TextTabs.Add(tempText2);
                        break;

                    case "signer2_rb":
                        RadioGroup tempRG2      = new RadioGroup();
                        string     tempRBLabel2 = key;
                        tempRBLabel2      = tempRBLabel2.Substring(11);
                        tempRG2.GroupName = tempRBLabel2;
                        tempRG2.Radios    = new List <Radio>();
                        Radio tempRB2 = new Radio();
                        tempRB2.Selected = "true";
                        tempRB2.Value    = Request[key];
                        tempRG2.Radios.Add(tempRB2);
                        Signer2.Tabs.RadioGroupTabs.Add(tempRG2);
                        break;

                    case "signer2_li":
                        List   tempList2      = new List();
                        string tempListLabel2 = key;
                        tempListLabel2     = tempListLabel2.Substring(13);
                        tempList2.TabLabel = tempListLabel2;
                        tempList2.Value    = Request[key];
                        Signer2.Tabs.ListTabs.Add(tempList2);
                        break;

                    case "signer2_cb":
                        Checkbox tempCB2      = new Checkbox();
                        string   tempCBLabel2 = key;
                        tempCBLabel2     = tempCBLabel2.Substring(13);
                        tempCB2.TabLabel = tempCBLabel2;
                        tempCB2.Selected = "true";
                        Signer2.Tabs.CheckboxTabs.Add(tempCB2);
                        break;

                    case "accountnum":
                        envelope.dsAccountId = Request[key];
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    switch (key)
                    {
                    case "usr":
                        envelope.dsUser = Request[key];
                        break;

                    case "pd":
                        envelope.dsPassword = Request[key];
                        break;

                    case "dst":
                        envelope.dsTemplateId = Request[key];
                        break;

                    case "logo":
                        envelope.dsLogo = Request[key];
                        break;

                    default:
                        break;
                    }
                }
            }
            switch (envelope.dsSigner1AuthMethod.ToLower())
            {
            case "access code":
                Signer1.AccessCode = envelope.dsSigner1AuthNumber;
                break;

            case "sms":
                Signer1.IdCheckConfigurationName = "SMS Auth $";
                Signer1.RequireIdLookup          = "true";
                Signer1.SmsAuthentication        = new RecipientSMSAuthentication();
                Signer1.SmsAuthentication.SenderProvidedNumbers = new List <string>();
                Signer1.SmsAuthentication.SenderProvidedNumbers.Add("+" + envelope.dsSigner1AuthNumber);
                break;

            case "phone":
                Signer1.IdCheckConfigurationName = "Phone Auth $";
                Signer1.RequireIdLookup          = "true";
                Signer1.PhoneAuthentication      = new RecipientPhoneAuthentication();
                Signer1.PhoneAuthentication.SenderProvidedNumbers = new List <string>();
                Signer1.PhoneAuthentication.SenderProvidedNumbers.Add("+" + envelope.dsSigner1AuthNumber);
                Signer1.PhoneAuthentication.RecipMayProvideNumber = "false";
                break;

            case "idcheck":
                Signer1.IdCheckConfigurationName = "ID Check $";
                Signer1.RequireIdLookup          = "true";
                break;

            default:
                break;
            }

            switch (envelope.dsSigner1SP.ToLower())
            {
            case "ds electronic":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspE = new RecipientSignatureProvider();
                rspE.SignatureProviderName = "UniversalSignaturePen_ImageOnly";
                Signer1.RecipientSignatureProviders.Add(rspE);
                break;

            case "ds express":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspD = new RecipientSignatureProvider();
                rspD.SignatureProviderName = "UniversalSignaturePen_Default";
                Signer1.RecipientSignatureProviders.Add(rspD);
                break;

            case "ds aes ac":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspAESAC = new RecipientSignatureProvider();
                rspAESAC.SignatureProviderName    = "UniversalSignaturePen_OpenTrust_Hash_TSP";
                rspAESAC.SignatureProviderOptions = new RecipientSignatureProviderOptions();
                rspAESAC.SignatureProviderOptions.OneTimePassword = envelope.dsSigner1AuthNumber;
                Signer1.RecipientSignatureProviders.Add(rspAESAC);
                break;

            case "ds aes sms":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspAESSMS = new RecipientSignatureProvider();
                rspAESSMS.SignatureProviderName        = "UniversalSignaturePen_OpenTrust_Hash_TSP";
                rspAESSMS.SignatureProviderOptions     = new RecipientSignatureProviderOptions();
                rspAESSMS.SignatureProviderOptions.Sms = "+" + envelope.dsSigner1AuthNumber;
                Signer1.RecipientSignatureProviders.Add(rspAESSMS);
                break;

            case "dsa":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspDSA = new RecipientSignatureProvider();
                rspDSA.SignatureProviderName = "universalsignaturepen_docusignsigningappliance_tsp";
                Signer1.RecipientSignatureProviders.Add(rspDSA);
                break;

            case "id now":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspIDNOW = new RecipientSignatureProvider();
                rspIDNOW.SignatureProviderName = "UniversalSignaturePen_IDNow_TSP";
                Signer1.RecipientSignatureProviders.Add(rspIDNOW);
                break;

            case "us piv":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspUSPIV = new RecipientSignatureProvider();
                rspUSPIV.SignatureProviderName = "UniversalSignaturePen_PIV_Test_TSP";
                Signer1.RecipientSignatureProviders.Add(rspUSPIV);
                break;

            case "it agile":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspAgile = new RecipientSignatureProvider();
                rspAgile.SignatureProviderName = "UniversalSignaturePen_ItAgile_TSP";
                Signer1.RecipientSignatureProviders.Add(rspAgile);
                break;

            case "icp":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspICP = new RecipientSignatureProvider();
                rspICP.SignatureProviderName = "UniversalSignaturePen_ICP_SmartCard_TSP";
                Signer1.RecipientSignatureProviders.Add(rspICP);
                break;

            case "ds smart card":
                Signer1.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspSMART = new RecipientSignatureProvider();
                rspSMART.SignatureProviderName = "universalsignaturepen_ds_smartcard_tsp";
                Signer1.RecipientSignatureProviders.Add(rspSMART);
                break;

            default:
                break;
            }

            switch (envelope.dsSigner2AuthMethod.ToLower())
            {
            case "access code":
                Signer2.AccessCode = envelope.dsSigner2AuthNumber;
                break;

            case "sms":
                Signer2.IdCheckConfigurationName = "SMS Auth $";
                Signer2.RequireIdLookup          = "true";
                Signer2.SmsAuthentication        = new RecipientSMSAuthentication();
                Signer2.SmsAuthentication.SenderProvidedNumbers = new List <string>();
                Signer2.SmsAuthentication.SenderProvidedNumbers.Add("+" + envelope.dsSigner2AuthNumber);
                break;

            case "phone":
                Signer2.IdCheckConfigurationName = "Phone Auth $";
                Signer2.RequireIdLookup          = "true";
                Signer2.PhoneAuthentication      = new RecipientPhoneAuthentication();
                Signer2.PhoneAuthentication.SenderProvidedNumbers = new List <string>();
                Signer2.PhoneAuthentication.SenderProvidedNumbers.Add("+" + envelope.dsSigner2AuthNumber);
                Signer2.PhoneAuthentication.RecipMayProvideNumber = "false";
                break;

            case "idcheck":
                Signer2.IdCheckConfigurationName = "ID Check $";
                Signer2.RequireIdLookup          = "true";
                break;

            default:
                break;
            }

            switch (envelope.dsSigner2SP.ToLower())
            {
            case "ds electronic":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspE = new RecipientSignatureProvider();
                rspE.SignatureProviderName = "UniversalSignaturePen_ImageOnly";
                Signer2.RecipientSignatureProviders.Add(rspE);
                break;

            case "ds express":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspD = new RecipientSignatureProvider();
                rspD.SignatureProviderName = "UniversalSignaturePen_Default";
                Signer2.RecipientSignatureProviders.Add(rspD);
                break;

            case "ds aes ac":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspAESAC = new RecipientSignatureProvider();
                rspAESAC.SignatureProviderName    = "UniversalSignaturePen_OpenTrust_Hash_TSP";
                rspAESAC.SignatureProviderOptions = new RecipientSignatureProviderOptions();
                rspAESAC.SignatureProviderOptions.OneTimePassword = envelope.dsSigner1AuthNumber;
                Signer2.RecipientSignatureProviders.Add(rspAESAC);
                break;

            case "ds aes sms":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspAESSMS = new RecipientSignatureProvider();
                rspAESSMS.SignatureProviderName        = "UniversalSignaturePen_OpenTrust_Hash_TSP";
                rspAESSMS.SignatureProviderOptions     = new RecipientSignatureProviderOptions();
                rspAESSMS.SignatureProviderOptions.Sms = "+" + envelope.dsSigner1AuthNumber;
                Signer2.RecipientSignatureProviders.Add(rspAESSMS);
                break;

            case "dsa":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspDSA = new RecipientSignatureProvider();
                rspDSA.SignatureProviderName = "universalsignaturepen_docusignsigningappliance_tsp";
                Signer2.RecipientSignatureProviders.Add(rspDSA);
                break;

            case "id now":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspIDNOW = new RecipientSignatureProvider();
                rspIDNOW.SignatureProviderName = "UniversalSignaturePen_IDNow_TSP";
                Signer2.RecipientSignatureProviders.Add(rspIDNOW);
                break;

            case "us piv":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspUSPIV = new RecipientSignatureProvider();
                rspUSPIV.SignatureProviderName = "UniversalSignaturePen_PIV_Test_TSP";
                Signer2.RecipientSignatureProviders.Add(rspUSPIV);
                break;

            case "it agile":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspAgile = new RecipientSignatureProvider();
                rspAgile.SignatureProviderName = "UniversalSignaturePen_ItAgile_TSP";
                Signer2.RecipientSignatureProviders.Add(rspAgile);
                break;

            case "icp":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspICP = new RecipientSignatureProvider();
                rspICP.SignatureProviderName = "UniversalSignaturePen_ICP_SmartCard_TSP";
                Signer2.RecipientSignatureProviders.Add(rspICP);
                break;

            case "ds smart card":
                Signer2.RecipientSignatureProviders = new List <RecipientSignatureProvider>();
                RecipientSignatureProvider rspSMART = new RecipientSignatureProvider();
                rspSMART.SignatureProviderName = "universalsignaturepen_ds_smartcard_tsp";
                Signer2.RecipientSignatureProviders.Add(rspSMART);
                break;

            default:
                break;
            }

            it.Recipients.Signers.Add(Signer1);
            if (Signer2.Email != "")
            {
                it.Recipients.Signers.Add(Signer2);
            }

            st.TemplateId = envelope.dsTemplateId;

            ct.ServerTemplates.Add(st);
            ct.InlineTemplates.Add(it);

            envDef.CompositeTemplates.Add(ct);

            envDef.Status = "sent";

            string json = JsonConvert.SerializeObject(envDef, Formatting.Indented);

            System.Diagnostics.Debug.Write(json);

            ApiClient apiClient = new ApiClient("https://demo.docusign.net/restapi");

            Configuration.Default.ApiClient = apiClient;
            envelope.dsAuthHeader           = "{\"Username\":\"" + envelope.dsUser + "\", \"Password\":\"" + envelope.dsPassword + "\", \"IntegratorKey\":\"49cfeb67-7406-4cef-bac9-7594a8802986\"}";
            Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication");
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", envelope.dsAuthHeader);

            TemplatesApi     tempApi  = new TemplatesApi();
            EnvelopeTemplate tempInfo = tempApi.Get(envelope.dsAccountId, envelope.dsTemplateId);
            string           brandId  = tempInfo.BrandId;

            AccountsApi acctApi   = new AccountsApi();
            Brand       brandInfo = acctApi.GetBrand(envelope.dsAccountId, brandId);

            foreach (var key in brandInfo.Colors)
            {
                if (key.Name == "headerBackground")
                {
                    envelope.dsHeaderColor = key.Value;
                }
                if (key.Name == "headerText")
                {
                    envelope.dsFontColor = key.Value;
                }
            }
            if (envelope.dsHeaderColor == "")
            {
                envelope.dsHeaderColor = "#5376B7";
            }
            if (envelope.dsFontColor == "")
            {
                envelope.dsFontColor = "#FFFFFF";
            }

            EnvelopesApi envelopesApi = new EnvelopesApi();

            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(envelope.dsAccountId, envDef);

            envelope.dsEnvelopeId = envelopeSummary.EnvelopeId;

            using (StreamWriter file = File.CreateText(Server.MapPath("~/json/" + envelope.dsEnvelopeId + ".json")))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, envDef);
            }

            if (Signer1.ClientUserId != null && Signer2.ClientUserId != null)
            {
                RecipientViewRequest viewOptions = new RecipientViewRequest()
                {
                    ReturnUrl            = "https://innov8ive.app/hmd/signer2start.aspx",
                    ClientUserId         = envelope.dsSigner1CID,
                    AuthenticationMethod = "email",
                    UserName             = Signer1.Name,
                    Email = Signer1.Email
                };

                ViewUrl recipientView = envelopesApi.CreateRecipientView(envelope.dsAccountId, envelope.dsEnvelopeId, viewOptions);

                Response.Redirect(recipientView.Url);
            }
            else if (Signer1.ClientUserId != null && Signer2.ClientUserId == null)
            {
                RecipientViewRequest viewOptions = new RecipientViewRequest()
                {
                    ReturnUrl            = "https://innov8ive.app/hmd/status.aspx",
                    ClientUserId         = envelope.dsSigner1CID,
                    AuthenticationMethod = "email",
                    UserName             = Signer1.Name,
                    Email = Signer1.Email
                };

                ViewUrl recipientView = envelopesApi.CreateRecipientView(envelope.dsAccountId, envelope.dsEnvelopeId, viewOptions);

                Response.Redirect(recipientView.Url);
            }
            else
            {
                Response.Redirect("~/status.aspx");
            }
        }
        /// <summary>
        /// Creates an envelope from a template. Creates a template definition using a multipart request.\n\n###Template Email Subject Merge Fields\n\nCall this endpoint to insert a recipient name and email address merge fields into the email subject line when creating or sending from a template.\n\nThe merge fields, based on the recipient’s role name, are added to the `emailSubject` property when the template is created or when the template is used to create an envelope. After a template sender adds the name and email information for the recipient and sends the envelope, the recipient information is automatically merged into the appropriate fields in the email subject line.\n\nBoth the sender and the recipients will see the information in the email subject line for any emails associated with the template. This provides an easy way for senders to organize their envelope emails without having to open an envelope to check the recipient.\n### Note: If merging the recipient information into the subject line causes the subject line to exceed 100 characters, then any characters over the 100 character limit are not included in the subject line. For cases where the recipient name or email is expected to be long, you should consider placing the merge field at the start of the email subject.\n\nTo add a recipient’s name in the subject line add the following text in the `emailSubject` property when creating the template or when sending an envelope from a template:\n\n[[&lt;roleName&gt;_UserName]]\n\nExample:\n\n`\&quot;emailSubject\&quot;:\&quot;[[Signer 1_UserName]], Please sign this NDA\&quot;,`\n\nTo add a recipient’s email address in the subject line add the following text in the `emailSubject` property when creating the template or when sending an envelope from a template:\n\n[[&lt;roleName&gt;_Email]]\n\nExample:\n\n`\&quot;emailSubject\&quot;:\&quot;[[Signer 1_Email]], Please sign this NDA\&quot;,`\n\n\nIn both cases the &lt;roleName&gt; is the recipient&#39;s contents of the `roleName` property in the template.\n\nFor cases where another recipient (such as an Agent, Editor, or Intermediary recipient) is entering the name and email information for the recipient included in the email subject, then [[&lt;roleName&gt;_UserName]] or [[&lt;roleName&gt;_Email]] is shown in the email subject.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param> <param name="envelopeTemplate">TBD Description</param>
		/// <returns>5TemplateSummary</returns>
        public TemplateSummary CreateTemplate (string accountId, EnvelopeTemplate envelopeTemplate)
        {
             ApiResponse<TemplateSummary> response = CreateTemplateWithHttpInfo(accountId, envelopeTemplate);
             return response.Data;
        }
        /// <summary>
        /// Updates an existing template. Updates an existing template.
        /// </summary>
	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="templateId">The ID of the template being accessed.</param> <param name="envelopeTemplate">TBD Description</param>
		/// <returns>8Task of ApiResponse (TemplateUpdateSummary)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<TemplateUpdateSummary>> UpdateAsyncWithHttpInfo (string accountId, string templateId, EnvelopeTemplate envelopeTemplate)
        {
            // verify the required parameter 'accountId' is set
            if (accountId == null) throw new ApiException(400, "Missing required parameter 'accountId' when calling Update");
            // verify the required parameter 'templateId' is set
            if (templateId == null) throw new ApiException(400, "Missing required parameter 'templateId' when calling Update");
            
    
            var path_ = "/v2/accounts/{accountId}/templates/{templateId}";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                "application/json"
            };
            String http_header_accept = Configuration.ApiClient.SelectHeaderAccept(http_header_accepts);
            if (http_header_accept != null)
                headerParams.Add("Accept", Configuration.ApiClient.SelectHeaderAccept(http_header_accepts));

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (accountId != null) pathParams.Add("accountId", Configuration.ApiClient.ParameterToString(accountId)); // path parameter
            if (templateId != null) pathParams.Add("templateId", Configuration.ApiClient.ParameterToString(templateId)); // path parameter
            

						
			
			

            
            
            postBody = Configuration.ApiClient.Serialize(envelopeTemplate); // http body (model) parameter
            

            

            // make the HTTP request
            IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams);

            int statusCode = (int) response.StatusCode;
 
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling Update: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling Update: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<TemplateUpdateSummary>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (TemplateUpdateSummary) Configuration.ApiClient.Deserialize(response, typeof(TemplateUpdateSummary)));
            
        }
        /// <summary>
        /// Updates an existing template. Updates an existing template.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="templateId">The ID of the template being accessed.</param> <param name="envelopeTemplate">TBD Description</param>
		/// <returns>7Task of TemplateUpdateSummary</returns>
        public async System.Threading.Tasks.Task<TemplateUpdateSummary> UpdateAsync (string accountId, string templateId, EnvelopeTemplate envelopeTemplate)
        {
             ApiResponse<TemplateUpdateSummary> response = await UpdateAsyncWithHttpInfo(accountId, templateId, envelopeTemplate);
             return response.Data;

        }
        /// <summary>
        /// Updates an existing template. Updates an existing template.
        /// </summary>
 	    ///<param name="accountId">The external account number (int) or account ID Guid.</param><param name="templateId">The ID of the template being accessed.</param> <param name="envelopeTemplate">TBD Description</param>
		/// <returns>5TemplateUpdateSummary</returns>
        public TemplateUpdateSummary Update (string accountId, string templateId, EnvelopeTemplate envelopeTemplate)
        {
             ApiResponse<TemplateUpdateSummary> response = UpdateWithHttpInfo(accountId, templateId, envelopeTemplate);
             return response.Data;
        }