-
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.
Merge pull request #131 from PaitoAnderson/develop
Add support for document prefill text fields
- Loading branch information
Showing
6 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
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,27 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using SignNow.Net.Model; | ||
|
||
namespace SignNow.Net.Examples.Documents | ||
{ | ||
public static partial class DocumentExamples | ||
{ | ||
/// <summary> | ||
/// Adds values to fields that the Signers can later edit when they receive the document for signature. | ||
/// Works only with Text field types. | ||
/// </summary> | ||
/// <param name="documentId">Identity of the document to prefill values for.</param> | ||
/// <param name="fields">Collection of the <see cref="PrefillTextField">fields</see></param> | ||
/// <param name="token">Access token</param> | ||
/// <returns></returns> | ||
public static async Task PrefillTextFields(string documentId, IEnumerable<PrefillTextField> fields, Token token) | ||
{ | ||
// using token from the Authorization step | ||
var signNowContext = new SignNowContext(token); | ||
|
||
await signNowContext.Documents | ||
.PrefillTextFieldsAsync(documentId, fields) | ||
.ConfigureAwait(false); | ||
} | ||
} | ||
} |
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,24 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace SignNow.Net.Model | ||
{ | ||
/// <summary> | ||
/// Adds values to fields that the Signers can later edit when they receive the document for signature. | ||
/// Works only with Text field types. | ||
/// </summary> | ||
public class PrefillTextField | ||
{ | ||
/// <summary> | ||
/// The unique field name that identifies the field. | ||
/// Can be found in the name parameter of the field in response from GET /document/{{document_id}} | ||
/// </summary> | ||
[JsonProperty("field_name")] | ||
public string FieldName { get; set; } | ||
|
||
/// <summary> | ||
/// The value that should appear on the document. | ||
/// </summary> | ||
[JsonProperty("prefilled_text")] | ||
public string PrefilledText { 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
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,35 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
using Newtonsoft.Json; | ||
using SignNow.Net.Interfaces; | ||
using SignNow.Net.Model; | ||
|
||
namespace SignNow.Net.Internal.Requests | ||
{ | ||
internal class PrefillTextFieldRequest : IContent | ||
{ | ||
/// <summary> | ||
/// Collections of <see cref="PrefillTextField"/> request options. | ||
/// </summary> | ||
[JsonProperty("fields")] | ||
public List<PrefillTextField> Fields { get; set; } = new List<PrefillTextField>(); | ||
|
||
public PrefillTextFieldRequest() {} | ||
|
||
public PrefillTextFieldRequest(IEnumerable<PrefillTextField> fields) | ||
{ | ||
Fields = fields.ToList(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates Json Http Content from object | ||
/// </summary> | ||
/// <returns>HttpContent</returns> | ||
public HttpContent GetHttpContent() | ||
{ | ||
return new StringContent(JsonConvert.SerializeObject(this), Encoding.UTF8, "application/json"); | ||
} | ||
} | ||
} |