Esempio n. 1
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);
        }
Esempio n. 2
0
        public void RequestSignatureViaTemplateTest()
        {
            try
            {
                // upload template if one doesn't exist
                // FAILED - CANT UPLOAD A TEMPLATE - API-3002 submitted
                // use predefined template
                AuthenticationApiTests authTests = new AuthenticationApiTests();
                authTests.LoginTest();

                // get pre-existing template with Signer1 role
                // since I can't upload a template right now
                TemplatesApi            templatesApi    = new TemplatesApi();
                EnvelopeTemplateResults templateResults = templatesApi.ListTemplates(TestConfig.AccountId);
                Assert.IsNotNull(templateResults);
                Assert.IsNotNull(templateResults.EnvelopeTemplates);
                string templateId = null;
                foreach (EnvelopeTemplateResult et in templateResults.EnvelopeTemplates)
                {
                    if (et.Name == "Test Template")
                    {
                        templateId = et.TemplateId;
                        break;
                    }
                }
                Assert.IsNotNull(templateId);

                EnvelopeDefinition envDef = new EnvelopeDefinition();
                envDef.TemplateId = templateId;

                envDef.TemplateRoles = new List <TemplateRole>();
                TemplateRole templateRole = new TemplateRole();
                templateRole.Email    = TestConfig.DefaultEmail;
                templateRole.Name     = TestConfig.DefaultName;
                templateRole.RoleName = "Signer1";
                envDef.TemplateRoles.Add(templateRole);
                envDef.Status = "sent"; // trigger the envelope to be sent (vs. Draft/Created)


                // send envelope using template roles
                EnvelopesApi    envelopesApi = new EnvelopesApi();
                EnvelopeSummary es           = envelopesApi.CreateEnvelope(TestConfig.AccountId, envDef);
                Assert.IsNotNull(es);
                Assert.IsNotNull(es.EnvelopeId);
                Trace.WriteLine("Envelope: " + es.ToJson());
            }
            catch (DocuSign.eSign.Client.ApiException apiEx)
            {
                Assert.IsNotNull(apiEx.ErrorCode);
                Assert.IsTrue(!string.IsNullOrWhiteSpace(apiEx.Message));
                Assert.IsTrue(false, "Failed with ErrorCode: " + apiEx.ErrorCode + ", Message: " + apiEx.Message);
            }
        }
Esempio n. 3
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);
        }
        /// <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);
        }
Esempio n. 5
0
        public void JwtGetTemplates_CorrectAccountId_ReturnEnvelopeTemplateResults()
        {
            EnvelopeTemplateResults envelopeTemplateResults = _templatesApi.ListTemplates(_testConfig.AccountId);

            Assert.IsNotNull(envelopeTemplateResults?.EnvelopeTemplates?.FirstOrDefault()?.TemplateId);
        }