Skip to content

Commit 6f40fed

Browse files
committed
add get doc group info
1 parent 4cae42a commit 6f40fed

File tree

8 files changed

+312
-8
lines changed

8 files changed

+312
-8
lines changed

Diff for: SignNow.Net.Examples/ExamplesRunner.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ public async Task CreateDocumentGroup()
944944

945945
var documents = new List<SignNowDocument>();
946946

947-
for (int i = 1; i < 2; i++)
947+
for (int i = 0; i < 2; i++)
948948
{
949949
var upload = await testContext.Documents
950950
.UploadDocumentAsync(fileStream, $"ForDocumentGroupFile-{i}.pdf");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
using System.Linq;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using SignNow.Net.Model.Responses;
4+
5+
namespace UnitTests.Responses
6+
{
7+
[TestClass]
8+
public class DocumentGroupInfoResponseTest
9+
{
10+
[TestMethod]
11+
public void ShouldProperDeserialize()
12+
{
13+
var jsonResponse = @"{
14+
""data"": {
15+
""id"": ""03c74b3083f34ebf8ef40a3039dfb32c85a08437"",
16+
""name"": ""CreateDocumentGroupTest"",
17+
""created"": 1729535107,
18+
""updated"": 1729535107,
19+
""invite_id"": null,
20+
""pending_step_id"": null,
21+
""state"": ""created"",
22+
""sign_as_merged"": null,
23+
""last_invite_id"": null,
24+
""owner_email"": ""[email protected]"",
25+
""folder_id"": ""e1d8d63ba51c4009ab9941f279c908a0fd5a5e48"",
26+
""documents"": [
27+
{
28+
""roles"": [],
29+
""document_name"": ""ForDocumentGroupFile-1"",
30+
""page_count"": 1,
31+
""id"": ""66974a4b421546a69167ba342d1ae94af56ce351"",
32+
""updated"": 1729535105,
33+
""folder_id"": ""e1d8d63ba51c4009ab9941f279c908a0fd5a5e48"",
34+
""owner"": {
35+
""id"": ""50204b3344984768bb16d61f8550f8b5edfd719a"",
36+
""email"": ""[email protected]""
37+
},
38+
""thumbnail"": {
39+
""small"": ""https://api-eval.signnow.com/document/66974a4b421546a69167ba342d1ae94af56ce351/thumbnail?size=small"",
40+
""medium"": ""https://api-eval.signnow.com/document/66974a4b421546a69167ba342d1ae94af56ce351/thumbnail?size=medium"",
41+
""large"": ""https://api-eval.signnow.com/document/66974a4b421546a69167ba342d1ae94af56ce351/thumbnail?size=large""
42+
},
43+
""origin_document_id"": null,
44+
""has_unassigned_field"": false,
45+
""has_credit_card_number"": false,
46+
""field_invites"": [],
47+
""shared_with_team"": null,
48+
""settings"": [],
49+
""allow_to_remove"": true
50+
}
51+
],
52+
""owner"": {
53+
""id"": ""50204b3344984768bb16d61f8550f8b5edfd719a"",
54+
""email"": ""[email protected]"",
55+
""organization"": {
56+
""id"": ""44f2dc3eef1c4924a8aea48d238968402abc745f""
57+
}
58+
},
59+
""cc_emails"": [],
60+
""freeform_invite"": {
61+
""id"": null,
62+
""last_id"": null
63+
},
64+
""originator_organization_settings"": [
65+
{
66+
""setting"": ""mobileweb_option"",
67+
""value"": ""app_or_mobileweb_choice""
68+
}
69+
],
70+
""mail_provider"": null
71+
}
72+
}";
73+
74+
var response = TestUtils.DeserializeFromJson<DocumentGroupInfoResponse>(jsonResponse);
75+
76+
Assert.AreEqual("03c74b3083f34ebf8ef40a3039dfb32c85a08437", response.Data.Id);
77+
Assert.AreEqual("CreateDocumentGroupTest", response.Data.Name);
78+
Assert.AreEqual(1, response.Data.Documents.Count);
79+
Assert.AreEqual("ForDocumentGroupFile-1", response.Data.Documents.FirstOrDefault()?.Name);
80+
Assert.AreEqual("50204b3344984768bb16d61f8550f8b5edfd719a", response.Data.Owner.Id);
81+
Assert.AreEqual("44f2dc3eef1c4924a8aea48d238968402abc745f", response.Data.Owner.Organization.Id);
82+
}
83+
}
84+
}

Diff for: SignNow.Net/Interfaces/IDocumentGroup.cs

+8
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,13 @@ public interface IDocumentGroup
2020
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
2121
/// <returns></returns>
2222
Task<DocumentGroupCreateResponse> CreateDocumentGroupAsync(string groupName, IEnumerable<SignNowDocument> documents, CancellationToken cancellationToken = default);
23+
24+
/// <summary>
25+
/// Getting basic information about document groups.
26+
/// </summary>
27+
/// <param name="documentGroupId">ID of the Document Group</param>
28+
/// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
29+
/// <returns></returns>
30+
Task<DocumentGroupInfoResponse> GetDocumentGroupInfoAsync(string documentGroupId, CancellationToken cancellationToken = default);
2331
}
2432
}

Diff for: SignNow.Net/Model/Organization.cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using SignNow.Net.Model.Responses.GenericResponses;
2+
3+
namespace SignNow.Net.Model
4+
{
5+
public class Organization : IdResponse
6+
{
7+
8+
}
9+
}

Diff for: SignNow.Net/Model/Owner.cs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Newtonsoft.Json;
2+
3+
namespace SignNow.Net.Model
4+
{
5+
public class Owner
6+
{
7+
[JsonProperty("id")]
8+
public string Id { get; set; }
9+
10+
/// <summary>
11+
/// Email of document owner.
12+
/// </summary>
13+
[JsonProperty("email")]
14+
public string Email { get; set; }
15+
16+
/// <summary>
17+
/// Organization info.
18+
/// </summary>
19+
[JsonProperty("organization", NullValueHandling = NullValueHandling.Ignore)]
20+
public Organization Organization { get; set; }
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
using Newtonsoft.Json;
1+
using SignNow.Net.Model.Responses.GenericResponses;
22

33
namespace SignNow.Net.Model.Responses
44
{
55
/// <summary>
66
/// Represents response from signNow API for Create Document from Template request.
77
/// </summary>
8-
public class CreateDocumentFromTemplateResponse
8+
public class CreateDocumentFromTemplateResponse :IdResponse
99
{
10-
/// <summary>
11-
/// Identity of new Document.
12-
/// </summary>
13-
[JsonProperty("id")]
14-
public string Id { get; set; }
1510
}
1611
}
+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Newtonsoft.Json;
4+
using SignNow.Net.Internal.Helpers.Converters;
5+
using SignNow.Net.Model.Responses.GenericResponses;
6+
7+
namespace SignNow.Net.Model.Responses
8+
{
9+
public class DocumentGroupInfoResponse
10+
{
11+
[JsonProperty("data")]
12+
public DocumentGroupData Data { get; set; }
13+
}
14+
15+
public class DocumentGroupData : IdResponse
16+
{
17+
/// <summary>
18+
/// Document Group name.
19+
/// </summary>
20+
[JsonProperty("name")]
21+
public string Name { get; set; }
22+
23+
/// <summary>
24+
/// Timestamp of document group creation.
25+
/// </summary>
26+
[JsonProperty("created")]
27+
[JsonConverter(typeof(UnixTimeStampJsonConverter))]
28+
public DateTime Created { get; set; }
29+
30+
/// <summary>
31+
/// Timestamp of document group update.
32+
/// </summary>
33+
[JsonProperty("updated")]
34+
[JsonConverter(typeof(UnixTimeStampJsonConverter))]
35+
public DateTime Updated { get; set; }
36+
37+
/// <summary>
38+
/// Identity of invite for Document Group.
39+
/// </summary>
40+
[JsonProperty("invite_id")]
41+
public string InviteId { get; set; }
42+
43+
/// <summary>
44+
/// Identity of pending step for Document Group.
45+
/// </summary>
46+
[JsonProperty("pending_step_id")]
47+
public string PendingStepId { get; set; }
48+
49+
/// <summary>
50+
/// Identity of last invite for Document Group.
51+
/// </summary>
52+
[JsonProperty("last_invite_id")]
53+
public string LastInviteId { get; set; }
54+
55+
/// <summary>
56+
/// Document Group state.
57+
/// </summary>
58+
[JsonProperty("state")]
59+
public string State { get; set; }
60+
61+
/// <summary>
62+
/// Owner email address.
63+
/// </summary>
64+
[JsonProperty("owner_email")]
65+
public string OwnerEmail { get; set; }
66+
67+
/// <summary>
68+
/// An ID of folder with document group.
69+
/// </summary>
70+
[JsonProperty("folder_id")]
71+
public string FolderId { get; set; }
72+
73+
[JsonProperty("documents")]
74+
public IReadOnlyList<GroupDocumentsInfo> Documents { get; set; }
75+
76+
/// <summary>
77+
/// Document owner info.
78+
/// </summary>
79+
[JsonProperty("owner")]
80+
public Owner Owner { get; set; }
81+
82+
/// <summary>
83+
/// CC emails list.
84+
/// </summary>
85+
[JsonProperty("cc_emails")]
86+
public IReadOnlyList<string> CcEmails { get; set; }
87+
88+
/// <summary>
89+
/// Freeform invite info.
90+
/// </summary>
91+
[JsonProperty("freeform_invite")]
92+
public FreeFormInviteInfo FreeFormInvite { get; set; }
93+
}
94+
95+
public class GroupDocumentsInfo : IdResponse
96+
{
97+
/// <summary>
98+
/// List with document roles.
99+
/// </summary>
100+
[JsonProperty("roles")]
101+
public IReadOnlyList<string> Roles { get; set; }
102+
103+
/// <summary>
104+
/// Document name.
105+
/// </summary>
106+
[JsonProperty("document_name")]
107+
public string Name { get; set; }
108+
109+
/// <summary>
110+
/// Pages count.
111+
/// </summary>
112+
[JsonProperty("page_count")]
113+
public int Pages { get; set; }
114+
115+
/// <summary>
116+
/// Timestamp of document update.
117+
/// </summary>
118+
[JsonProperty("updated")]
119+
[JsonConverter(typeof(UnixTimeStampJsonConverter))]
120+
public DateTime Updated { get; set; }
121+
122+
/// <summary>
123+
/// An ID of folder with document.
124+
/// </summary>
125+
[JsonProperty("folder_id")]
126+
public string FolderId { get; set; }
127+
128+
/// <summary>
129+
/// Document owner info.
130+
/// </summary>
131+
[JsonProperty("owner")]
132+
public Owner Owner { get; set; }
133+
134+
/// <summary>
135+
/// Document thumbnails
136+
/// </summary>
137+
[JsonProperty("thumbnail")]
138+
public Thumbnail Thumbnail { get; set; }
139+
140+
/// <summary>
141+
/// An ID of document origin.
142+
/// </summary>
143+
[JsonProperty("origin_document_id")]
144+
public string OriginDocumentId { get; set; }
145+
146+
/// <summary>
147+
/// Is the document has unassigned field.
148+
/// </summary>
149+
[JsonProperty("has_unassigned_field")]
150+
public bool HasUnassignedField { get; set; }
151+
152+
/// <summary>
153+
/// Is the document has a credit card number.
154+
/// </summary>
155+
[JsonProperty("has_credit_card_number")]
156+
public bool HasCreditCardNumber { get; set; }
157+
158+
/// <summary>
159+
/// Is the document can be removed from document group.
160+
/// </summary>
161+
[JsonProperty("allow_to_remove")]
162+
public bool IsAllowedToRemove { get; set; }
163+
}
164+
165+
public class FreeFormInviteInfo : IdResponse
166+
{
167+
[JsonProperty("last_id")]
168+
public string LastId { get; set; }
169+
}
170+
}

Diff for: SignNow.Net/Service/DocumentGroupService.cs

+16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading;
44
using System.Threading.Tasks;
55
using SignNow.Net.Interfaces;
6+
using SignNow.Net.Internal.Extensions;
67
using SignNow.Net.Internal.Requests;
78
using SignNow.Net.Model;
89
using SignNow.Net.Model.Responses;
@@ -36,5 +37,20 @@ public async Task<DocumentGroupCreateResponse> CreateDocumentGroupAsync(string g
3637
.RequestAsync<DocumentGroupCreateResponse>(requestOptions, cancellationToken)
3738
.ConfigureAwait(false);
3839
}
40+
41+
/// <inheritdoc />
42+
public async Task<DocumentGroupInfoResponse> GetDocumentGroupInfoAsync(string documentGroupId, CancellationToken cancellationToken = default)
43+
{
44+
Token.TokenType = TokenType.Bearer;
45+
var requestOption = new GetHttpRequestOptions
46+
{
47+
RequestUrl = new Uri(ApiBaseUrl, $"/v2/document-groups/{documentGroupId.ValidateId()}"),
48+
Token = Token
49+
};
50+
51+
return await SignNowClient
52+
.RequestAsync<DocumentGroupInfoResponse>(requestOption, cancellationToken)
53+
.ConfigureAwait(false);
54+
}
3955
}
4056
}

0 commit comments

Comments
 (0)