-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f40fed
commit f06f3e8
Showing
7 changed files
with
284 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
SignNow.Net.Test/UnitTests/Requests/LimitOffsetOptionsTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SignNow.Net.Model.Requests; | ||
|
||
namespace UnitTests.Requests | ||
{ | ||
[TestClass] | ||
public class LimitOffsetOptionsTest | ||
{ | ||
[TestMethod] | ||
public void BuildQuery() | ||
{ | ||
var emptyOptions = new LimitOffsetOptions(); | ||
var fullOptions = new LimitOffsetOptions | ||
{ | ||
Limit = 2, | ||
Offset = 3 | ||
}; | ||
|
||
Assert.AreEqual(String.Empty, emptyOptions.ToQueryString()); | ||
Assert.AreEqual("limit=2&offset=3", fullOptions.ToQueryString()); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
SignNow.Net.Test/UnitTests/Responses/DocumentGroupsResponseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SignNow.Net.Model.Responses; | ||
|
||
namespace UnitTests.Responses | ||
{ | ||
[TestClass] | ||
public class DocumentGroupsResponseTests | ||
{ | ||
[TestMethod] | ||
public void ShouldProperDeserialize() | ||
{ | ||
var jsonResponse = @"{ | ||
""document_groups"": [ | ||
{ | ||
""folder_id"": null, | ||
""last_updated"": ""1729535107"", | ||
""group_id"": ""03c74b3083f34ebf8ef40a3039dfb32c85a08333"", | ||
""group_name"": ""CreateDocumentGroupTest"", | ||
""invite_id"": null, | ||
""invite_status"": null, | ||
""documents"": [ | ||
{ | ||
""id"": ""66974a4b421546a69167ba342d1ae94af56ce333"", | ||
""name"": ""ForDocumentGroupFile-1"", | ||
""page_count"": 1, | ||
""thumbnail"": { | ||
""small"": ""https://api-eval.signnow.com/document/66974a4b421546a69167ba342d1ae94af56ce333/thumbnail?size=small"", | ||
""medium"": ""https://api-eval.signnow.com/document/66974a4b421546a69167ba342d1ae94af56ce333/thumbnail?size=medium"", | ||
""large"": ""https://api-eval.signnow.com/document/66974a4b421546a69167ba342d1ae94af56ce333/thumbnail?size=large"" | ||
}, | ||
""roles"": [], | ||
""settings"": { | ||
""advanced_signing_flow"": false | ||
}, | ||
""has_credit_card_number"": false | ||
} | ||
], | ||
""is_full_declined"": false, | ||
""is_embedded"": false, | ||
""freeform_invite"": { | ||
""id"": null | ||
}, | ||
""state"": ""created"", | ||
""has_guest_signer"": false, | ||
""has_signing_group"": false | ||
} | ||
], | ||
""document_group_total_count"": 1 | ||
}"; | ||
|
||
var response = TestUtils.DeserializeFromJson<DocumentGroupsResponse>(jsonResponse); | ||
|
||
Assert.AreEqual(1, response.TotalCount); | ||
Assert.AreEqual(1, response.Data.Count); | ||
|
||
var group = response.Data.First(); | ||
Assert.AreEqual("03c74b3083f34ebf8ef40a3039dfb32c85a08333", group.GroupId); | ||
Assert.AreEqual("CreateDocumentGroupTest", group.Name); | ||
Assert.AreEqual(1, group.Documents.First().Pages); | ||
Assert.AreEqual("advanced_signing_flow", group.Documents.First().Settings.First().Key); | ||
Assert.AreEqual(false, group.Documents.First().Settings.First().Value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using SignNow.Net.Interfaces; | ||
|
||
namespace SignNow.Net.Model.Requests | ||
{ | ||
public class LimitOffsetOptions : IQueryToString | ||
{ | ||
/// <summary> | ||
/// Limit of the items in response. | ||
/// </summary> | ||
public int? Limit { get; set; } | ||
|
||
/// <summary> | ||
/// Offset size for pagination. | ||
/// </summary> | ||
public int? Offset { get; set; } | ||
|
||
public string ToQueryString() | ||
{ | ||
if (Limit == null && Offset == null) | ||
{ | ||
return String.Empty; | ||
} | ||
|
||
var options = new List<string>(); | ||
|
||
if (Limit != null) | ||
{ | ||
options.Add($"limit={Limit}"); | ||
} | ||
|
||
if (Offset != null) | ||
{ | ||
options.Add($"offset={Offset}"); | ||
} | ||
|
||
return String.Join("&", options); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using SignNow.Net.Internal.Helpers.Converters; | ||
|
||
namespace SignNow.Net.Model.Responses | ||
{ | ||
public class DocumentGroupsResponse | ||
{ | ||
[JsonProperty("document_groups")] | ||
public IReadOnlyList<DocumentGroups> Data { get; set; } | ||
|
||
/// <summary> | ||
/// Total documents count in document group. | ||
/// </summary> | ||
[JsonProperty("document_group_total_count")] | ||
public int TotalCount { get; set; } | ||
} | ||
|
||
public class DocumentGroups | ||
{ | ||
/// <summary> | ||
/// An ID of folder with document group. | ||
/// </summary> | ||
[JsonProperty("folder_id")] | ||
public string FolderId { get; set; } | ||
|
||
/// <summary> | ||
/// Timestamp of document group update. | ||
/// </summary> | ||
[JsonProperty("last_updated")] | ||
[JsonConverter(typeof(UnixTimeStampJsonConverter))] | ||
public DateTime Updated { get; set; } | ||
|
||
/// <summary> | ||
/// Document Group name. | ||
/// </summary> | ||
[JsonProperty("group_name")] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// An ID of document group. | ||
/// </summary> | ||
[JsonProperty("group_id")] | ||
public string GroupId { get; set; } | ||
|
||
/// <summary> | ||
/// Identity of invite for Document Group. | ||
/// </summary> | ||
[JsonProperty("invite_id")] | ||
public string InviteId { get; set; } | ||
|
||
/// <summary> | ||
/// Invite status | ||
/// </summary> | ||
[JsonProperty("invite_status")] | ||
public string InviteStatus { get; set; } | ||
|
||
[JsonProperty("documents")] | ||
public IReadOnlyList<GroupDocumentsInfo> Documents { get; set; } | ||
|
||
/// <summary> | ||
/// Is the document full declined. | ||
/// </summary> | ||
[JsonProperty("is_full_declined")] | ||
public bool IsFullDeclined { get; set; } | ||
|
||
/// <summary> | ||
/// Is the document embedded. | ||
/// </summary> | ||
[JsonProperty("is_embedded")] | ||
public bool IsEmbedded { get; set; } | ||
|
||
/// <summary> | ||
/// Freeform invite info. | ||
/// </summary> | ||
[JsonProperty("freeform_invite")] | ||
public FreeFormInviteInfo FreeFormInvite { get; set; } | ||
|
||
/// <summary> | ||
/// Document Group state. | ||
/// </summary> | ||
[JsonProperty("state")] | ||
public string State { get; set; } | ||
|
||
/// <summary> | ||
/// Is the document has guest signer. | ||
/// </summary> | ||
[JsonProperty("has_guest_signer")] | ||
public bool HasGuestSigner { get; set; } | ||
|
||
/// <summary> | ||
/// Is the document has signing group. | ||
/// </summary> | ||
[JsonProperty("has_signing_group")] | ||
public bool HasSigningGroup { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters