Repository navigation
Expand file tree
/
Copy pathDocumentGroupInviteOperations.cs
More file actions
133 lines (118 loc) · 5.42 KB
/
Copy pathDocumentGroupInviteOperations.cs
File metadata and controls
133 lines (118 loc) · 5.42 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SignNow.Net.Model;
using SignNow.Net.Model.Requests.DocumentGroup;
namespace SignNow.Net.Examples
{
public partial class DocumentGroupOperations
{
[TestMethod]
public async Task SendAndManageDocumentGroupInviteAsync()
{
// 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, $"ForDocumentGroupInviteFile-{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("SendDocumentGroupInviteTest", documents)
.ConfigureAwait(false);
// Send a signing invite to the document group, one signer per document
var request = new CreateGroupInviteRequest
{
InviteSteps = new List<GroupInviteStep>
{
new GroupInviteStep
{
Order = 1,
InviteEmails = new List<GroupInviteEmail>
{
new GroupInviteEmail
{
Email = "signer1@signnow.com",
Role = documents[0].Roles[0].Name,
RoleId = documents[0].Roles[0].Id,
Order = 1
},
new GroupInviteEmail
{
Email = "signer2@signnow.com",
Role = documents[1].Roles[0].Name,
RoleId = documents[1].Roles[0].Id,
Order = 1
}
},
InviteActions = new List<GroupInviteAction>
{
new GroupInviteAction
{
Email = "signer1@signnow.com",
RoleName = documents[0].Roles[0].Name,
DocumentId = documents[0].Id
},
new GroupInviteAction
{
Email = "signer2@signnow.com",
RoleName = documents[1].Roles[0].Name,
DocumentId = documents[1].Id
}
}
}
}
};
var invite = await testContext.GroupInvites
.CreateGroupInviteAsync(documentGroup.Id, request)
.ConfigureAwait(false);
Assert.AreEqual("pending", invite.Data.Status);
Console.WriteLine("Group invite created: {0} with status {1}", invite.Data.Id, invite.Data.Status);
// Check the status of the group invite
var inviteStatus = await testContext.GroupInvites
.GetGroupInviteAsync(documentGroup.Id, invite.Data.Id)
.ConfigureAwait(false);
Assert.AreEqual(invite.Data.Id, inviteStatus.Data.Id);
// List signers who have not yet signed
var pendingInvites = await testContext.GroupInvites
.GetPendingGroupInvitesAsync(documentGroup.Id, invite.Data.Id)
.ConfigureAwait(false);
Console.WriteLine("Pending signers: {0}", pendingInvites.Data.Count);
// Reassign the first invite step to a different signer
var stepId = inviteStatus.Data.Steps.First().Id;
await testContext.GroupInvites
.ReassignSignerAsync(documentGroup.Id, invite.Data.Id, stepId, new ReassignSignerRequest
{
NewSigner = new ReassignSignerInfo
{
Email = "reassigned-signer@signnow.com",
RoleName = documents[0].Roles[0].Name
}
})
.ConfigureAwait(false);
Console.WriteLine("Reassigned invite step {0} to a new signer", stepId);
// Resend invite emails to the current signers
await testContext.GroupInvites
.ResendGroupInviteAsync(documentGroup.Id, invite.Data.Id)
.ConfigureAwait(false);
// Cancel the group invite
await testContext.GroupInvites
.CancelGroupInviteAsync(documentGroup.Id, invite.Data.Id)
.ConfigureAwait(false);
// Clean up
await testContext.DocumentGroup.DeleteDocumentGroupAsync(documentGroup.Id).ConfigureAwait(false);
foreach (var document in documents)
{
DeleteTestDocument(document.Id);
}
}
}
}