Skip to content

Commit 058eb79

Browse files
committed
add options for embedded invite request
1 parent a690219 commit 058eb79

File tree

4 files changed

+186
-2
lines changed

4 files changed

+186
-2
lines changed

Diff for: SignNow.Net.Test/TestData/FakeModels/EmbeddedInviteFaker.cs

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using Bogus;
23
using SignNow.Net.Model;
34
using SignNow.Net.Model.Requests;
@@ -17,7 +18,15 @@ public class EmbeddedInviteFaker : Faker<EmbeddedInvite>
1718
/// <code>
1819
/// {
1920
/// "email": "[email protected]",
21+
/// "language": "en",
2022
/// "auth_method": "none",
23+
/// "first_name": "Jesus",
24+
/// "last_name": "Monahan",
25+
/// "prefill_signature_name": "Jesus Monahan prefill signature",
26+
/// "force_new_signature": "1",
27+
/// "redirect_uri": "https://signnow.com",
28+
/// "decline_redirect_uri": "https://signnow.com",
29+
/// "redirect_target": "self",
2130
/// "role_id": "c376990ca7e1e84ea7f6e252144e435f314bb63b",
2231
/// "order": 1
2332
/// }
@@ -28,7 +37,15 @@ public EmbeddedInviteFaker()
2837
Rules((f, o) =>
2938
{
3039
o.Email = f.Internet.Email();
40+
o.Language = f.PickRandom<Lang>();
3141
o.AuthMethod = f.PickRandom<EmbeddedAuthType>();
42+
o.Firstname = f.Person.FirstName;
43+
o.Lastname = f.Person.LastName;
44+
o.PrefillSignatureName = $"{f.Person.FirstName} {f.Person.LastName} prefill signature";
45+
o.ForceNewSignature = f.Random.Bool();
46+
o.RedirectUrl = new Uri(f.Internet.Url());
47+
o.DeclineRedirectUrl = new Uri(f.Internet.Url());
48+
o.RedirectTarget = f.PickRandom<RedirectTarget>();
3249
o.RoleId = f.Random.Hash(40);
3350
o.SigningOrder = (uint)f.Random.Number(1, 10);
3451
});

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

+134-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Newtonsoft.Json;
33
using Newtonsoft.Json.Converters;
44
using SignNow.Net.Internal.Extensions;
5+
using SignNow.Net.Internal.Helpers.Converters;
56
using SignNow.Net.Model.Requests;
67

78
namespace SignNow.Net.Model
@@ -14,6 +15,20 @@ public class EmbeddedInvite
1415
private string email { get; set; }
1516
private uint signingOrder { get; set; }
1617

18+
private string prefillSignatureName { get; set; }
19+
private bool forceNewSignature { get; set; }
20+
21+
private string requiredPresetSignatureName { get; set; }
22+
23+
/// <summary>
24+
/// Prefilled text in the Signature field, disabled for editing by signer.
25+
/// Cannot be used together with prefill_signature_name and/or force_new_signature.
26+
/// </summary>
27+
private bool isPrefilledSignatureName { get; set; }
28+
29+
private bool isRequiredPresetEnabled { get; set; }
30+
31+
1732
/// <summary>
1833
/// Signer's email address.
1934
/// </summary>
@@ -25,13 +40,13 @@ public string Email
2540
}
2641

2742
/// <summary>
28-
/// Signer's role ID.
43+
/// Signer's role id in the document.
2944
/// </summary>
3045
[JsonProperty("role_id")]
3146
public string RoleId { get; set; }
3247

3348
/// <summary>
34-
/// Order of signing. Cannot be 0.
49+
/// The order of signing. Cannot be 0.
3550
/// </summary>
3651
[JsonProperty("order")]
3752
public uint SigningOrder
@@ -48,11 +63,128 @@ public uint SigningOrder
4863
}
4964
}
5065

66+
/// <summary>
67+
/// Sets the language of the signing session for the signer.
68+
/// </summary>
69+
[JsonProperty("language")]
70+
[JsonConverter(typeof(StringEnumConverter))]
71+
public Lang Language { get; set; }
72+
5173
/// <summary>
5274
/// Signer authentication method.
5375
/// </summary>
5476
[JsonProperty("auth_method")]
5577
[JsonConverter(typeof(StringEnumConverter))]
5678
public EmbeddedAuthType AuthMethod { get; set; } = EmbeddedAuthType.None;
79+
80+
/// <summary>
81+
/// Signer's first name.
82+
/// </summary>
83+
[JsonProperty("first_name", NullValueHandling = NullValueHandling.Ignore)]
84+
public string Firstname { get; set; }
85+
86+
/// <summary>
87+
/// Signer's last name.
88+
/// </summary>
89+
[JsonProperty("last_name", NullValueHandling = NullValueHandling.Ignore)]
90+
public string Lastname { get; set; }
91+
92+
/// <summary>
93+
/// Prefilled text in the Signature field.
94+
/// </summary>
95+
/// <exception cref="ArgumentException">String lenght cannot be greater than 255 characters</exception>
96+
/// <exception cref="ArgumentException">Cannot be used together with Required preset for Signature name</exception>
97+
[JsonProperty("prefill_signature_name", NullValueHandling = NullValueHandling.Ignore)]
98+
public string PrefillSignatureName
99+
{
100+
get { return prefillSignatureName; }
101+
set
102+
{
103+
if (value.Length > 255)
104+
{
105+
throw new ArgumentException(
106+
"Prefilled text in the Signature field can be maximum 255 characters.",
107+
nameof(PrefillSignatureName));
108+
}
109+
110+
if (isRequiredPresetEnabled)
111+
{
112+
throw new ArgumentException(
113+
"Required preset for Signature name is set. Cannot be used together with",
114+
nameof(PrefillSignatureName));
115+
}
116+
117+
prefillSignatureName = value;
118+
isPrefilledSignatureName = true;
119+
}
120+
}
121+
122+
/// <exception cref="ArgumentException">Cannot be used together with Required preset for Signature name</exception>
123+
[JsonProperty("force_new_signature", NullValueHandling = NullValueHandling.Ignore)]
124+
[JsonConverter(typeof(BoolToIntJsonConverter))]
125+
public bool ForceNewSignature
126+
{
127+
get { return forceNewSignature; }
128+
set
129+
{
130+
if (isRequiredPresetEnabled)
131+
{
132+
throw new ArgumentException(
133+
"Required preset for Signature name is set. Cannot be used together with",
134+
nameof(ForceNewSignature));
135+
}
136+
137+
forceNewSignature = value;
138+
139+
if (value)
140+
{
141+
isPrefilledSignatureName = true;
142+
}
143+
}
144+
}
145+
146+
/// <summary>
147+
/// Prefilled text in the Signature field, disabled for editing by signer.
148+
/// </summary>
149+
/// <exception cref="ArgumentException">Cannot be used together with prefill for Signature name</exception>
150+
[JsonProperty("required_preset_signature_name", NullValueHandling = NullValueHandling.Ignore)]
151+
public string RequiredPresetSignatureName
152+
{
153+
get { return requiredPresetSignatureName; }
154+
set
155+
{
156+
if (isPrefilledSignatureName)
157+
{
158+
throw new ArgumentException(
159+
"Prefill for Signature name or Force new signature is set. Cannot be used together with",
160+
nameof(RequiredPresetSignatureName));
161+
}
162+
163+
requiredPresetSignatureName = value;
164+
isRequiredPresetEnabled = true;
165+
}
166+
}
167+
168+
/// <summary>
169+
/// The link that opens after the signing session has been completed.
170+
/// </summary>
171+
[JsonProperty("redirect_uri", NullValueHandling = NullValueHandling.Ignore)]
172+
[JsonConverter(typeof(StringToUriJsonConverter))]
173+
public Uri RedirectUrl { get; set; }
174+
175+
/// <summary>
176+
/// The link that opens after the signing session has been declined by the signer.
177+
/// </summary>
178+
[JsonProperty("decline_redirect_uri", NullValueHandling = NullValueHandling.Ignore)]
179+
[JsonConverter(typeof(StringToUriJsonConverter))]
180+
public Uri DeclineRedirectUrl { get; set; }
181+
182+
/// <summary>
183+
/// Determines whether to open the redirect link in the new tab in the browser, or in the same tab after the signing session.
184+
/// Possible values: blank - opens the link in the new tab, self - opens the link in the same tab, default value.
185+
/// </summary>
186+
[JsonProperty("redirect_target", NullValueHandling = NullValueHandling.Ignore)]
187+
[JsonConverter(typeof(StringEnumConverter))]
188+
public RedirectTarget RedirectTarget { get; set; }
57189
}
58190
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace SignNow.Net.Model
4+
{
5+
public enum Lang
6+
{
7+
[EnumMember(Value = "en")]
8+
English,
9+
10+
[EnumMember(Value = "es")]
11+
Spanish,
12+
13+
[EnumMember(Value = "fr")]
14+
French
15+
}
16+
}

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

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace SignNow.Net.Model
4+
{
5+
public enum RedirectTarget
6+
{
7+
/// <summary>
8+
/// opens the link in the new tab
9+
/// </summary>
10+
[EnumMember(Value = "blank")]
11+
Blank,
12+
13+
/// <summary>
14+
/// opens the link in the same tab.
15+
/// </summary>
16+
[EnumMember(Value = "self")]
17+
Self
18+
}
19+
}

0 commit comments

Comments
 (0)