Example #1
0
        public IActionResult Create()
        {
            // Check the token with minimal buffer time
            bool tokenOk = CheckToken(3);

            if (!tokenOk)
            {
                // We could store the parameters of the requested operation so it could be restarted
                // automatically. But since it should be rare to have a token issue here,
                // we'll make the user re-enter the form data after authentication
                RequestItemsService.EgName = EgName;
                return(Redirect("/ds/mustAuthenticate"));
            }

            var basePath = RequestItemsService.Session.BasePath + "/restapi";

            // Step 1: Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;  // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}
            var envelopeId  = RequestItemsService.EnvelopeId;

            // Step 2: Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            // Step 3: Call the eSignature REST API
            var envelopesApi         = new EnvelopesApi(apiClient);
            EnvelopeFormData results = envelopesApi.GetFormData(accountId, envelopeId);

            ViewBag.h1          = "Get envelope tab data information";
            ViewBag.message     = "Results from the Envelopes::get method:";
            ViewBag.Locals.Json = JsonConvert.SerializeObject(results, Formatting.Indented);
            return(View("example_done"));
        }
        public void GetFormData_CorrectInputParameters_ReturnEnvelopeFormData()
        {
            var envDef = new EnvelopeDefinition
            {
                EmailSubject = "[DocuSign C# SDK] - Please sign this doc"
            };

            var tRole = new TemplateRole
            {
                Email    = _testConfig.RecipientEmail,
                Name     = _testConfig.RecipientName,
                RoleName = "Manager"
            };

            var rolesList = new List <TemplateRole>()
            {
                tRole
            };

            envDef.TemplateRoles = rolesList;
            envDef.TemplateId    = _testConfig.TemplateId;

            envDef.Status = "sent";

            EnvelopeSummary envelopeSummary = _envelopesApi.CreateEnvelope(_testConfig.AccountId, envDef);

            Assert.IsNotNull(envelopeSummary?.EnvelopeId);

            EnvelopeFormData envFormData = _envelopesApi.GetFormData(_testConfig.AccountId, envelopeSummary.EnvelopeId);

            Assert.IsNotNull(envFormData?.FormData);
            Assert.IsNotNull(envFormData?.EnvelopeId);
        }
        public IActionResult Create()
        {
            // Check the token with minimal buffer time
            bool tokenOk = CheckToken(3);

            if (!tokenOk)
            {
                // We could store the parameters of the requested operation so it could be restarted
                // automatically. But since it should be rare to have a token issue here,
                // we'll make the user re-enter the form data after authentication
                RequestItemsService.EgName = EgName;
                return(Redirect("/ds/mustAuthenticate"));
            }

            var basePath = RequestItemsService.Session.BasePath + "/restapi";

            // Step 1: Obtain your OAuth token
            var accessToken = RequestItemsService.User.AccessToken;  // Represents your {ACCESS_TOKEN}
            var accountId   = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}
            var envelopeId  = RequestItemsService.EnvelopeId;

            // Call the Examples API method to get all tab data from the specified envelope
            EnvelopeFormData results = global::eSignature.Examples.GetEnvelopeTabData.GetEnvelopeFormData(accessToken, basePath, accountId, envelopeId);

            // Process results
            ViewBag.h1          = "Get envelope tab data information";
            ViewBag.message     = "Results from the Envelopes::get method:";
            ViewBag.Locals.Json = JsonConvert.SerializeObject(results, Formatting.Indented);
            return(View("example_done"));
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            logo.ImageUrl = envelope.dsLogo;
            logo.Height   = 100;
            pageHeader.Style.Add("background-color", envelope.dsHeaderColor);
            pageHeader.Style.Add("color", envelope.dsFontColor);

            Configuration.Default.DefaultHeader.Remove("X-DocuSign-Authentication");
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", envelope.dsAuthHeader);

            var apiInstance         = new EnvelopesApi();
            EnvelopeFormData result = apiInstance.GetFormData(envelope.dsAccountId, envelope.dsEnvelopeId);

            TableRow  header = new TableRow();
            TableCell cell1  = new TableCell();

            cell1.Text = "Name";
            TableCell cell2 = new TableCell();

            cell2.Text = "Original Value";
            TableCell cell3 = new TableCell();

            cell3.Text = "Signed Value";
            header.Cells.Add(cell1);
            header.Cells.Add(cell2);
            header.Cells.Add(cell3);
            Table1.Rows.Add(header);

            foreach (var data in result.RecipientFormData)
            {
                TableRow  row1  = new TableRow();
                TableCell name1 = new TableCell();
                name1.Text = data.Name;
                TableCell blank1 = new TableCell();
                TableCell blank2 = new TableCell();
                row1.Cells.Add(name1);
                row1.Cells.Add(blank1);
                row1.Cells.Add(blank2);
                Table1.Rows.Add(row1);
                foreach (var fd in data.FormData)
                {
                    TableRow  entry = new TableRow();
                    TableCell label = new TableCell();
                    label.Text = fd.Name;
                    TableCell oValue = new TableCell();
                    oValue.Text = fd.OriginalValue;
                    TableCell value = new TableCell();
                    value.Text = fd.Value;
                    entry.Cells.Add(label);
                    entry.Cells.Add(oValue);
                    entry.Cells.Add(value);
                    Table1.Rows.Add(entry);
                }
            }
        }
Example #5
0
        public Dictionary <string, string> GetEnvelopData(string accountId, string envelopeId)
        {
            if (accountId == null)
            {
                throw new ArgumentNullException(nameof(accountId));
            }
            if (envelopeId == null)
            {
                throw new ArgumentNullException(nameof(envelopeId));
            }

            EnvelopeFormData results = _docuSignApiProvider.EnvelopApi.GetFormData(accountId, envelopeId);

            return(results.FormData.ToDictionary(x => x.Name, x => x.Value));
        }
        public void JwtGetFormDataTest()
        {
            EnvelopeDefinition envDef = new EnvelopeDefinition();

            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

            // 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.
            TemplateRole tRole = new TemplateRole();

            tRole.Email    = _testConfig.RecipientEmail;
            tRole.Name     = _testConfig.RecipientName;
            tRole.RoleName = "Manager";

            List <TemplateRole> rolesList = new List <TemplateRole>()
            {
                tRole
            };

            // add the role to the envelope and assign valid templateId from your account
            envDef.TemplateRoles = rolesList;
            envDef.TemplateId    = _testConfig.TemplateId;

            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";

            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            EnvelopesApi    envelopesApi    = new EnvelopesApi(_testConfig.ApiClient);
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(_testConfig.AccountId, envDef);

            Assert.IsNotNull(envelopeSummary);
            Assert.IsNotNull(envelopeSummary.EnvelopeId);

            EnvelopeFormData envFormData = envelopesApi.GetFormData(_testConfig.AccountId, envelopeSummary.EnvelopeId);

            Assert.IsNotNull(envFormData);
            Assert.IsNotNull(envFormData.FormData);
            Assert.IsNotNull(envFormData.EnvelopeId);
            Assert.IsNotNull(envFormData.FormData.FirstOrDefault().Name);
        }