-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDocumentGroupEmbeddedOperations.cs
More file actions
103 lines (89 loc) · 4.41 KB
/
Copy pathDocumentGroupEmbeddedOperations.cs
File metadata and controls
103 lines (89 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SignNow.Net.Model;
using SignNow.Net.Model.Requests;
using SignNow.Net.Model.Requests.DocumentGroup;
namespace SignNow.Net.Examples
{
public partial class DocumentGroupOperations
{
[TestMethod]
public async Task CreateAndManageDocumentGroupEmbeddedInviteAsync()
{
// Upload two documents with signature fields so each has a role to invite
await using var fileStream = File.OpenRead(PdfWithSignatureField);
var documents = new List<SignNowDocument>();
for (int i = 0; i < 2; i++)
{
var upload = await testContext.Documents
.UploadDocumentWithFieldExtractAsync(fileStream, $"ForDocumentGroupEmbeddedFile-{i}.pdf")
.ConfigureAwait(false);
var doc = await testContext.Documents.GetDocumentAsync(upload.Id).ConfigureAwait(false);
documents.Add(doc);
}
// Create document group from uploaded documents
var documentGroup = await testContext.DocumentGroup
.CreateDocumentGroupAsync("DocumentGroupEmbeddedInviteTest", documents)
.ConfigureAwait(false);
// Create an embedded signing invite for the document group, without sending emails
var embeddedInviteRequest = new CreateDocumentGroupEmbeddedInviteRequest
{
Invites = new List<DocumentGroupEmbeddedInviteSigner>
{
new DocumentGroupEmbeddedInviteSigner
{
Email = "embedded-signer1@signnow.com",
RoleId = documents[0].Roles[0].Id,
SigningOrder = 1
},
new DocumentGroupEmbeddedInviteSigner
{
Email = "embedded-signer2@signnow.com",
RoleId = documents[1].Roles[0].Id,
SigningOrder = 1
}
}
};
var embeddedInvite = await testContext.DocumentGroup
.CreateDocumentGroupEmbeddedInviteAsync(documentGroup.Id, embeddedInviteRequest)
.ConfigureAwait(false);
Assert.AreEqual(2, embeddedInvite.InviteData.Count);
Console.WriteLine("Created {0} embedded invites for the document group", embeddedInvite.InviteData.Count);
// Generate a signing link for the first embedded invite
var embeddedInviteLink = await testContext.DocumentGroup
.GenerateDocumentGroupEmbeddedInviteLinkAsync(
documentGroup.Id,
embeddedInvite.InviteData[0].Id,
new CreateDocumentGroupEmbedLinkOptions { LinkExpiration = 30 })
.ConfigureAwait(false);
Console.WriteLine("Embedded invite link: {0}", embeddedInviteLink.Link.AbsoluteUri);
// Generate a link to open the embedded editor for the document group
var editorLink = await testContext.DocumentGroup
.GenerateDocumentGroupEmbeddedEditorLinkAsync(
documentGroup.Id,
new EmbeddedEditorOptions { LinkExpiration = 30 })
.ConfigureAwait(false);
Console.WriteLine("Embedded editor link: {0}", editorLink.Link.AbsoluteUri);
// Generate a link to open the embedded sending workflow for the document group
var sendingLink = await testContext.DocumentGroup
.GenerateDocumentGroupEmbeddedSendingLinkAsync(
documentGroup.Id,
new EmbeddedSendingOptions { LinkExpiration = 30 })
.ConfigureAwait(false);
Console.WriteLine("Embedded sending link: {0}", sendingLink.Link.AbsoluteUri);
// Cancel all embedded signing invites for the document group
await testContext.DocumentGroup
.CancelDocumentGroupEmbeddedInviteAsync(documentGroup.Id)
.ConfigureAwait(false);
// Clean up
await testContext.DocumentGroup.DeleteDocumentGroupAsync(documentGroup.Id).ConfigureAwait(false);
foreach (var document in documents)
{
DeleteTestDocument(document.Id);
}
}
}
}