Skip to content

Commit 7da56dd

Browse files
authored
Merge pull request #7 from AaronWDS/DEVDOCS-1186
DEVDOCS-1186/DEVDOCS-1178
2 parents 261e120 + 4b04290 commit 7da56dd

File tree

6 files changed

+123
-31
lines changed

6 files changed

+123
-31
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using DocuSign.eSign.Api;
2+
using DocuSign.eSign.Client;
3+
using DocuSign.eSign.Model;
4+
using eg_03_csharp_auth_code_grant_core.Models;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Newtonsoft.Json;
7+
8+
namespace eg_03_csharp_auth_code_grant_core.Controllers
9+
{
10+
[Route("eg015")]
11+
public class Eg015EnvelopeTabDataController : EgController
12+
{
13+
public Eg015EnvelopeTabDataController(DSConfiguration config, IRequestItemsService requestItemsService)
14+
: base(config, requestItemsService)
15+
{
16+
ViewBag.title = "Get Envelope Tab Information";
17+
}
18+
public override string EgName => "eg015";
19+
20+
[HttpPost]
21+
public IActionResult Create()
22+
{
23+
// Check the token with minimal buffer time.
24+
bool tokenOk = CheckToken(3);
25+
if (!tokenOk)
26+
{
27+
// We could store the parameters of the requested operation
28+
// so it could be restarted automatically.
29+
// But since it should be rare to have a token issue here,
30+
// we'll make the user re-enter the form data after
31+
// authentication.
32+
RequestItemsService.EgName = EgName;
33+
return Redirect("/ds/mustAuthenticate");
34+
}
35+
36+
var basePath = RequestItemsService.Session.BasePath + "/restapi";
37+
38+
// Step 1: Obtain your OAuth token
39+
var accessToken = RequestItemsService.User.AccessToken; //represents your {ACCESS_TOKEN}
40+
var accountId = RequestItemsService.Session.AccountId; //represents your {ACCOUNT_ID}
41+
var envelopeId = RequestItemsService.EnvelopeId;
42+
43+
// Step 2: Construct your API headers
44+
var config = new Configuration(new ApiClient(basePath));
45+
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
46+
47+
// Step 3: Call the eSignature REST API
48+
EnvelopesApi envelopesApi = new EnvelopesApi(config);
49+
EnvelopeFormData results = envelopesApi.GetFormData(accountId, envelopeId);
50+
51+
ViewBag.h1 = "Get envelope tab data information";
52+
ViewBag.message = "Results from the Envelopes::get method:";
53+
ViewBag.Locals.Json = JsonConvert.SerializeObject(results, Formatting.Indented);
54+
return View("example_done");
55+
}
56+
}
57+
}

eg-03-csharp-auth-code-grant-core/Controllers/Eg019AccessCodeAuthController.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
using DocuSign.eSign.Api;
44
using DocuSign.eSign.Model;
55
using eg_03_csharp_auth_code_grant_core.Models;
6-
using System.Text;
76
using Microsoft.AspNetCore.Mvc;
7+
using System.Text;
88
using DocuSign.eSign.Client;
99

1010
namespace eg_03_csharp_auth_code_grant_core.Controllers
@@ -20,7 +20,6 @@ public Eg019AccessCodeAuthController(DSConfiguration config, IRequestItemsServic
2020

2121
public override string EgName => "eg019";
2222

23-
2423
[HttpPost]
2524
public IActionResult Create(string signerEmail, string signerName, string accessCode)
2625
{
@@ -37,14 +36,12 @@ public IActionResult Create(string signerEmail, string signerName, string access
3736

3837
// Data for this method:
3938
// signerEmail
40-
// signerName
41-
39+
// signerName
4240
var basePath = RequestItemsService.Session.BasePath + "/restapi";
43-
var recipientId = Guid.NewGuid().ToString();
4441

4542
// Step 1: Obtain your OAuth token
46-
var accessToken = RequestItemsService.User.AccessToken;
47-
var accountId = RequestItemsService.Session.AccountId;
43+
var accessToken = RequestItemsService.User.AccessToken; //represents your {ACCESS_TOKEN}
44+
var accountId = RequestItemsService.Session.AccountId; //represents your {ACCOUNT_ID}
4845

4946
// Step 2: Construct your API headers
5047
var config = new Configuration(new ApiClient(basePath));
@@ -80,7 +77,7 @@ public IActionResult Create(string signerEmail, string signerName, string access
8077
DocumentId = "1",
8178
// A 1- to 8-digit integer or 32-character GUID to match recipient IDs on your own systems.
8279
// This value is referenced in the Tabs element below to assign tabs on a per-recipient basis.
83-
RecipientId = recipientId
80+
RecipientId = "1" //represents your {RECIPIENT_ID}
8481
};
8582

8683
// Tabs are set per recipient/signer
@@ -96,12 +93,11 @@ public IActionResult Create(string signerEmail, string signerName, string access
9693
RoutingOrder = "1",
9794
Status = "Created",
9895
DeliveryMethod = "Email",
99-
RecipientId = recipientId,
100-
AccessCode = accessCode,
96+
RecipientId = "1", //represents your {RECIPIENT_ID}
97+
AccessCode = accessCode, //represents your {ACCESS_CODE}
10198
Tabs = signer1Tabs
10299
};
103100

104-
105101
Recipients recipients = new Recipients();
106102
recipients.Signers = new List<Signer> { signer1 };
107103
env.Recipients = recipients;

eg-03-csharp-auth-code-grant-core/Controllers/Eg023IdvAuthController.cs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ namespace eg_03_csharp_auth_code_grant_core.Controllers
1212
[Route("eg023")]
1313
public class Eg023IdvAuthController : EgController
1414
{
15-
public Eg023IdvAuthController(DSConfiguration config, IRequestItemsService requestItemsService)
15+
public Eg023IdvAuthController(DSConfiguration config, IRequestItemsService requestItemsService)
1616
: base(config, requestItemsService)
1717
{
1818
ViewBag.title = "ID Verification Authentication";
1919
}
2020

2121
public override string EgName => "eg023";
2222

23-
2423
[HttpPost]
25-
public IActionResult Create(string signerEmail, string signerName)
24+
public IActionResult Create(string signerEmail, string signerName, string ccEmail, string ccName)
2625
{
2726
// Check the token with minimal buffer time.
2827
bool tokenOk = CheckToken(3);
@@ -35,27 +34,23 @@ public IActionResult Create(string signerEmail, string signerName)
3534
return Redirect("/ds/mustAuthenticate");
3635
}
3736

38-
39-
// Data for this method:
37+
// Data for this method
4038
// signerEmail
4139
// signerName
4240
var basePath = RequestItemsService.Session.BasePath + "/restapi";
43-
var recipientId = Guid.NewGuid().ToString();
44-
4541

4642
// Step 1: Obtain your OAuth token
47-
var accessToken = RequestItemsService.User.AccessToken;
48-
var accountId = RequestItemsService.Session.AccountId;
43+
var accessToken = RequestItemsService.User.AccessToken; //represents your {ACCESS_TOKEN}
44+
var accountId = RequestItemsService.Session.AccountId; //represents your {ACCOUNT_ID}
4945

5046
// Step 2: Construct your API headers
5147
var config = new Configuration(new ApiClient(basePath));
5248
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
5349

54-
55-
//Step 3: Retreive the WorkflowId
50+
//Step 3: Retreive the workflow ID
5651
AccountsApi workflowDetails = new AccountsApi(config);
5752
AccountIdentityVerificationResponse wfRes = workflowDetails.GetAccountIdentityVerification(accountId);
58-
Console.WriteLine("Workflow id: " + wfRes.IdentityVerification[0].WorkflowId);
53+
Console.WriteLine("Workflow ID: " + wfRes.IdentityVerification[0].WorkflowId);
5954

6055
// Step 4: Construct your envelope JSON body
6156
// Note: If you did not successfully obtain your workflow ID, step 4 will fail.
@@ -88,9 +83,8 @@ public IActionResult Create(string signerEmail, string signerName)
8883
DocumentId = "1",
8984
// A 1- to 8-digit integer or 32-character GUID to match recipient IDs on your own systems.
9085
// This value is referenced in the Tabs element below to assign tabs on a per-recipient basis.
91-
RecipientId = recipientId
92-
};
93-
86+
RecipientId = "1" //represents your {RECIPIENT_ID}
87+
};
9488

9589
// Tabs are set per recipient/signer
9690
Tabs signer1Tabs = new Tabs
@@ -111,7 +105,7 @@ public IActionResult Create(string signerEmail, string signerName)
111105
Note = "",
112106
Status = "created",
113107
DeliveryMethod = "email",
114-
RecipientId = recipientId,
108+
RecipientId = "1", //represents your {RECIPIENT_ID}
115109
IdentityVerification = workflow,
116110
Tabs = signer1Tabs
117111
};
@@ -124,7 +118,6 @@ public IActionResult Create(string signerEmail, string signerName)
124118
EnvelopesApi envelopesApi = new EnvelopesApi(config);
125119
EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, env);
126120

127-
128121
ViewBag.h1 = "Envelope sent";
129122
ViewBag.message = "The envelope has been created and sent!<br />Envelope ID " + results.EnvelopeId + ".";
130123
return View("example_done");
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<h4>15. Get the tab data from an envelope</h4>
2+
<p>Get the tab (field) values from an envelope for all of the envelope's recipients.</p>
3+
4+
<p>
5+
This method is used to read the updated tab values from
6+
the envelope. The method can be used after the envelope is complete or while it is
7+
still in progress.
8+
</p>
9+
10+
@if (ViewBag.showDoc) {
11+
<p><a target='_blank' href='@ViewBag.documentation'>Documentation</a> about this example.</p>
12+
}
13+
14+
15+
<p>
16+
API method used:
17+
<a target='_blank' href="https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeFormData/get">EnvelopeFormData::get</a>.
18+
</p>
19+
20+
<p>
21+
View source file <a target="_blank" href="@ViewBag.source">Eg015EnvelopeTabDataController.cs</a> on GitHub.
22+
</p>
23+
24+
@if (ViewBag.envelopeOk) {
25+
<p>
26+
The last envelope you created with this example launcher will be queried.
27+
Recommendation: use example 9, then this example, since example 9 includes many tabs of different types.
28+
</p>
29+
30+
<form class="eg" action="" method="post" data-busy="form">
31+
<input type="hidden" name="_csrf" value="<%- csrfToken %>">
32+
<button type="submit" class="btn btn-primary">Continue</button>
33+
</form>
34+
} else {
35+
<p>
36+
Problem: please first create an envelope using <a href="eg009">example 9.</a> <br />
37+
Thank you.
38+
</p>
39+
40+
<form class="eg" action="eg009" method="get">
41+
<button type="submit" class="btn btn-primary">Continue</button>
42+
</form>
43+
44+
}

eg-03-csharp-auth-code-grant-core/Views/Eg019AccessCodeAuth/eg019.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div class="form-group">
2929
<label for="accessCode">Access Code</label>
3030
<input type="text" class="form-control" id="accessCode" name="accessCode"
31-
aria-describedby="acText" placeholder="Rnter a recipient access code here" required>
31+
aria-describedby="acText" placeholder="Enter a recipient access code here" required>
3232
<small id="acText" class="form-text text-muted">Provide this string to a recipient that is different such as in person or by mail or via different email.</small>
3333
</div>
3434
<div class="form-group">

eg-03-csharp-auth-code-grant-core/Views/Home/Index.cshtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,11 @@
171171
</p>
172172

173173
<h2>Tabs Examples</h2>
174-
<h4 id="example015">15. <a href="#">Get the tab data from an envelope</a></h4>
175-
<p>Comming Soon...</p>
174+
<h4 id="example015">15. <a href="eg015">Get the tab data from an envelope</a></h4>
175+
<p>This example retrieves the <strong>tab</strong> (<a target="_blank" href="https://developers.docusign.com/esign-rest-api/guides/concepts/tabs">field</a>) values from an envelope.</p>
176176
<p>
177+
API method used:
178+
<a target='_blank' href="https://developers.docusign.com/esign-rest-api/reference/Envelopes/EnvelopeFormData/get">EnvelopeFormData::get</a>.
177179
</p>
178180

179181
<h4 id="example016">16. <a href="#">Set tab values for a envelope</a></h4>

0 commit comments

Comments
 (0)