Skip to content

Commit bf5f3f4

Browse files
authored
Merge pull request #132 from signnow/prefill-text
Edit Text field feature
2 parents 76701f7 + bdd2a92 commit bf5f3f4

54 files changed

Lines changed: 785 additions & 268 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/release-notes.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,12 @@
66
set -eu
77
set -o pipefail
88

9-
109
# Get Release notes for the latest release from CHANGELOG.md
1110
# How to use:
1211
# release-notes.sh CHANGELOG.md
1312

1413
startLine=$(cat $1 | grep -nE "^### " | head -n 1 | cut -d ":" -f 1)
15-
finishLine=$(($(cat $1 | grep -nE "^## " | head -n 2 | tail -n 1 | cut -d ":" -f 1) - 1))
14+
finishLine=$(($(cat $1 | grep -nE "^## \[\d+\." | head -n 2 | tail -n 1 | cut -d ":" -f 1) - 1))
1615
changelog=`sed -n "${startLine},${finishLine}p" $1`;
1716

18-
: "${GITHUB_ACTIONS:=0}"
19-
20-
if [ "$GITHUB_ACTIONS" = "true" ]
21-
then
22-
changelog="${changelog//'%'/'%25'}"
23-
changelog="${changelog//$'\n'/'%0A'}"
24-
changelog="${changelog//$'\r'/'%0D'}"
25-
fi
26-
2717
echo "${changelog}"

.github/workflows/build_and_test.yml

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,63 @@
1-
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2-
31
name: Build and Test
42

53
on:
64
push:
5+
branches:
6+
- '**'
77
paths-ignore:
88
- '**.md'
99
- 'SignNow.Net/SignNow.Net.Examples/**'
10-
10+
tags-ignore:
11+
- '**'
1112
pull_request:
1213
branches:
1314
- 'master'
1415
- 'develop'
16+
paths-ignore:
17+
- '**.md'
18+
tags-ignore:
19+
- '**'
1520

1621
# Workflow
1722
jobs:
1823
build:
19-
20-
name: ${{ matrix.osname }} ${{ matrix.framework }}
24+
name: ${{ matrix.name }}
2125
runs-on: ${{ matrix.os }}
2226

2327
strategy:
2428
fail-fast: false
2529

2630
matrix:
27-
framework:
28-
- 'net45'
29-
- 'netcoreapp3.1'
30-
- 'net5'
31-
32-
name:
33-
- ubuntu-18.04
34-
- macOS-latest
35-
- windows-latest
36-
3731
include:
38-
- name: ubuntu-18.04
39-
os: ubuntu-18.04
40-
osname: Linux
41-
42-
- name: macOS-latest
43-
os: macOS-latest
44-
osname: macOS
45-
46-
- name: windows-latest
47-
os: windows-latest
48-
osname: Windows
49-
50-
exclude:
51-
- name: ubuntu-18.04
52-
framework: 'net45'
53-
54-
- name: macOS-latest
55-
framework: 'net45'
32+
# Ubuntu
33+
- { name: 'Linux .NET Core 3', os: ubuntu-18.04, framework: 'netcoreapp3.1' }
34+
- { name: 'Linux .NET 5', os: ubuntu-18.04, framework: 'net5' }
35+
# macOs
36+
- { name: 'macOS .NET Core 3', os: macOS-latest, framework: 'netcoreapp3.1' }
37+
- { name: 'macOS .NET 5', os: macOS-latest, framework: 'net5' }
38+
# Windows
39+
- { name: 'Windows .NET Core 3', os: windows-latest, framework: 'netcoreapp3.1' }
40+
- { name: 'Windows .NET 5', os: windows-latest, framework: 'net5' }
41+
- { name: 'Windows .NET 4.5', os: windows-latest, framework: 'net45' }
5642

5743
env:
5844
COREHOST_TRACE: false
59-
# Disable sending usage data to Microsoft
60-
DOTNET_CLI_TELEMETRY_OPTOUT: 1
61-
# prevent the caching of the packages on the build machine
62-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
63-
# removes logo and telemetry message from first run of dotnet cli
64-
DOTNET_NOLOGO: true
65-
# prevent the download of the XML documentation for the packages
66-
NUGET_XMLDOC_MODE: skip
45+
DOTNET_CLI_TELEMETRY_OPTOUT: 1 # Disable sending usage data to Microsoft
46+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 # prevent the caching of the packages on the build machine
47+
DOTNET_NOLOGO: true # removes logo and telemetry message from first run of dotnet cli
48+
NUGET_XMLDOC_MODE: skip # prevent the download of the XML documentation for the packages
6749
COVERAGE_PATH: SignNow.Net.Test/bin/Debug
6850

51+
defaults:
52+
run:
53+
shell: pwsh
54+
6955
steps:
7056
- uses: actions/checkout@v2
7157
with:
7258
fetch-depth: 1
7359

7460
- name: Setup .NET SDK Version for Target Framework
75-
shell: pwsh
7661
run: |
7762
If ("${{ matrix.framework }}" -eq "netcoreapp3.1") {
7863
Write-Output "DOTNET_SDK_VERSION=3.1.x" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
@@ -109,21 +94,17 @@ jobs:
10994

11095
- name: Build for .NET Standard 1.2
11196
if: matrix.framework == 'netcoreapp3.1'
112-
shell: pwsh
11397
run: dotnet build SignNow.Net --configuration Debug --framework netstandard1.2
11498

11599
- name: Build for .NET Standard 2.0
116100
if: matrix.framework == 'net5'
117-
shell: pwsh
118101
run: dotnet build SignNow.Net --configuration Debug --framework netstandard2.0
119102

120103
- name: Build for .NET 4.5
121104
if: (runner.os == 'Windows' && matrix.framework == 'net45')
122-
shell: pwsh
123105
run: dotnet build SignNow.Net --configuration Debug --framework net45
124106

125107
- name: Run Tests on ${{ matrix.framework }} with Coverage
126-
shell: pwsh
127108
run: |
128109
dotnet test SignNow.Net.Test `
129110
--configuration Debug --framework ${{ matrix.framework }} `
@@ -136,7 +117,6 @@ jobs:
136117
path: SignNow.Net.Test/bin/Debug/**/coverage*
137118

138119
- name: Setup Code Coverage report flags
139-
shell: pwsh
140120
run: |
141121
If ("${{ matrix.framework }}" -eq "netcoreapp3.1") {
142122
Write-Output "TARGET_FRAMEWORK=netstandard12" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

.github/workflows/release.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ jobs:
1111

1212
env:
1313
COREHOST_TRACE: false
14-
# Disable sending usage data to Microsoft
15-
DOTNET_CLI_TELEMETRY_OPTOUT: 1
16-
# prevent the caching of the packages on the build machine
17-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
18-
# removes logo and telemetry message from first run of dotnet cli
19-
DOTNET_NOLOGO: true
20-
# prevent the download of the XML documentation for the packages
21-
NUGET_XMLDOC_MODE: skip
14+
DOTNET_CLI_TELEMETRY_OPTOUT: 1 # Disable sending usage data to Microsoft
15+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 # prevent the caching of the packages on the build machine
16+
DOTNET_NOLOGO: true # removes logo and telemetry message from first run of dotnet cli
17+
NUGET_XMLDOC_MODE: skip # prevent the download of the XML documentation for the packages
2218

2319
steps:
2420
- uses: actions/checkout@v2
@@ -54,7 +50,6 @@ jobs:
5450
id: get-version
5551
run: |
5652
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
57-
echo ::set-output name=RELEASE_NOTES::$(.github/release-notes.sh CHANGELOG.md)
5853
.github/release-notes.sh CHANGELOG.md > release-notes.txt
5954
6055
- name: Create Release
@@ -63,7 +58,7 @@ jobs:
6358
token: ${{ secrets.GITHUB_TOKEN }}
6459
name: SignNow .Net SDK v${{ steps.get-version.outputs.VERSION }}
6560
tag: ${{ steps.get-version.outputs.VERSION }}
66-
body: ${{ steps.get-version.outputs.RELEASE_NOTES }}
61+
bodyFile: ${{ github.workspace }}/release-notes.txt
6762
allowUpdates: true
6863
artifacts: ${{ github.workspace }}/SignNow.Net/bin/Publish/*.nupkg
6964
artifactContentType: application/octet-stream

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com)
55
and this project adheres to [Semantic Versioning](http://semver.org).
66

7-
## [develop] - TBD
8-
- `IDocumentService.PrefillTextFieldsAsync` that allows to prefill document fields
7+
## [Unreleased] - TBD
8+
9+
## [1.0.0] - 2022-02-26
10+
### Added
11+
- `IDocumentService.PrefillTextFieldsAsync` that allows you to prefill document fields
12+
- `IDocumentService.EditDocumentAsync` that allows you to add/change various fields
13+
- `IFieldEditable` that represents editable Field attributes
14+
- `Model.EditFields.TextField` that allows you to configure text field and add/change the document fields
15+
16+
### Changed
17+
- `FieldJsonAttributes` added to `ISignNowFields` that allows you to get Field attributes
918

1019
## [0.9.0] - 2021-07-07
1120
### Added

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ Get your account at <https://www.signnow.com/developers>
4444
- [Create a one-time link to download the document as a PDF](#share-document-via-link)
4545
- [Get the history of a document](#document-history)
4646
- [Check the status of the document][check_sign_status example]
47-
- [Move document into specified folder][move_document example]
47+
- [Move document into specified folder][move_document example]
48+
- [Edit document][edit_document example]
49+
- [Prefill document text fields][prefill_text_field example]
4850
- [Template](#template)
4951
- [Create a template by flattening an existing document](#create-template)
5052
- [Create document from the template][create_document example]
@@ -580,7 +582,7 @@ For XML documentation generation, install InheritDocTool:
580582
dotnet tool install -g InheritDocTool
581583
```
582584

583-
More about the InheritDoc [here](https://www.inheritdoc.io)
585+
More about the InheritDoc [here](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/examples#document-a-hierarchy-of-classes-and-interfaces)
584586

585587
### <a name="important-notes"></a>Important notes
586588

@@ -611,7 +613,6 @@ If you have questions about the SignNow API, please visit [SignNow API Reference
611613
[actions build link]: https://github.com/signnow/SignNow.NET/actions?query=workflow%3A%22Build+and+Test%22
612614
[codecov badge]: https://codecov.io/gh/signnow/SignNow.NET/branch/develop/graph/badge.svg "Code coverage report"
613615
[codecov link]: https://codecov.io/gh/signnow/SignNow.NET
614-
[codacy badge]: https://api.codacy.com/project/badge/Grade/1aea9e4b60eb4b6a8c458e16fc8bdb24 "Codacy Repository certification"
615616
[nuget badge]: https://img.shields.io/nuget/v/SignNow.Net.svg?style=flat-square "NuGet package latest SDK version"
616617
[nuget link]: https://www.nuget.org/packages/SignNow.Net
617618
[nuget downloads badge]: https://img.shields.io/nuget/dt/SignNow.Net.svg?style=flat-square
@@ -651,6 +652,8 @@ If you have questions about the SignNow API, please visit [SignNow API Reference
651652
[create_one_time_link example]: https://github.com/signnow/SignNow.NET/blob/develop/SignNow.Net.Examples/Documents/CreateOneTimeLinkToDownloadTheDocument.cs
652653
[document_history example]: https://github.com/signnow/SignNow.NET/blob/develop/SignNow.Net.Examples/Documents/GetTheDocumentHistory.cs
653654
[move_document example]: https://github.com/signnow/SignNow.NET/blob/develop/SignNow.Net.Examples/Documents/MoveTheDocumentToFolder.cs
655+
[edit_document example]: https://github.com/signnow/SignNow.NET/blob/develop/SignNow.Net.Examples/Documents/EditDocumentTextFields.cs
656+
[prefill_text_field example]: https://github.com/signnow/SignNow.NET/blob/develop/SignNow.Net.Examples/Documents/PrefillTextFields.cs
654657

655658
<!-- Templates -->
656659
[create_template example]: https://github.com/signnow/SignNow.NET/blob/develop/SignNow.Net.Examples/Documents/CreateTemplateFromTheDocument.cs
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using SignNow.Net.Interfaces;
4+
using SignNow.Net.Model;
5+
using SignNow.Net.Model.EditFields;
6+
using SignNow.Net.Model.Responses;
7+
8+
namespace SignNow.Net.Examples.Documents
9+
{
10+
// public class EditDocumentTextFields
11+
public static partial class DocumentExamples
12+
{
13+
/// <summary>
14+
/// Updates a document by adding/overwriting fields or elements (texts, checks, signatures, hyperlinks, attachments)
15+
/// </summary>
16+
/// <param name="documentId">Identity of the document to add/edit fields for.</param>
17+
/// <param name="fields">Collection of the <see cref="IFieldEditable">fields</see></param>
18+
/// <param name="token">Access token</param>
19+
/// <returns></returns>
20+
public static async Task<EditDocumentResponse> EditDocumentTextFields(string documentId, IEnumerable<IFieldEditable> fields, Token token)
21+
{
22+
// using token from the Authorization step
23+
var signNowContext = new SignNowContext(token);
24+
25+
return await signNowContext.Documents
26+
.EditDocumentAsync(documentId, fields)
27+
.ConfigureAwait(false);
28+
}
29+
}
30+
}

SignNow.Net.Examples/Documents/PrefillTextFields.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Threading.Tasks;
33
using SignNow.Net.Model;
4+
using SignNow.Net.Model.EditFields;
45

56
namespace SignNow.Net.Examples.Documents
67
{
@@ -11,10 +12,10 @@ public static partial class DocumentExamples
1112
/// Works only with Text field types.
1213
/// </summary>
1314
/// <param name="documentId">Identity of the document to prefill values for.</param>
14-
/// <param name="fields">Collection of the <see cref="PrefillTextField">fields</see></param>
15+
/// <param name="fields">Collection of the <see cref="TextField">fields</see></param>
1516
/// <param name="token">Access token</param>
1617
/// <returns></returns>
17-
public static async Task PrefillTextFields(string documentId, IEnumerable<PrefillTextField> fields, Token token)
18+
public static async Task PrefillTextFields(string documentId, IEnumerable<TextField> fields, Token token)
1819
{
1920
// using token from the Authorization step
2021
var signNowContext = new SignNowContext(token);

SignNow.Net.Examples/ExamplesRunner.cs

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
using SignNow.Net.Examples.Folders;
1010
using SignNow.Net.Examples.Invites;
1111
using SignNow.Net.Examples.Users;
12+
using SignNow.Net.Interfaces;
1213
using SignNow.Net.Model;
14+
using SignNow.Net.Model.EditFields;
1315
using SignNow.Net.Model.Requests;
1416
using SignNow.Net.Model.Requests.GetFolderQuery;
1517
using SignNow.Net.Test.Context;
@@ -272,7 +274,6 @@ public async Task CreateOneTimeLinkToDownloadTheDocumentTest()
272274
StringAssert.Contains(oneTimeLink.Url.Host, "signnow.com");
273275
}
274276

275-
276277
/// <summary>
277278
/// Run test for example: <see cref="DocumentExamples.MoveTheDocumentToFolder"/>
278279
/// </summary>
@@ -309,6 +310,60 @@ await DocumentExamples
309310
await testContext.Folders.DeleteFolderAsync(folderToMoveUpdated.Id).ConfigureAwait(false);
310311
}
311312

313+
/// <summary>
314+
/// Run test for example: <see cref="DocumentExamples.EditDocumentTextFields"/>
315+
/// Run test for example: <see cref="DocumentExamples.PrefillTextFields"/>
316+
/// </summary>
317+
[TestMethod]
318+
public async Task PrefillTextFieldsTest()
319+
{
320+
// Upload test document
321+
await using var fileStream = File.OpenRead(PdfWithSignatureField);
322+
var testDocument = await testContext.Documents
323+
.UploadDocumentWithFieldExtractAsync(fileStream, "PrefillDocumentTest.pdf")
324+
.ConfigureAwait(false);
325+
326+
var documentUploaded = await testContext.Documents.GetDocumentAsync(testDocument.Id).ConfigureAwait(false);
327+
Assert.IsNull(documentUploaded.Fields.FirstOrDefault()?.JsonAttributes.PrefilledText);
328+
329+
// Add simple text field which will be prefilled next.
330+
var editFields = new List<IFieldEditable>
331+
{
332+
new TextField
333+
{
334+
PageNumber = 0,
335+
Name = "Text_1",
336+
Height = 40,
337+
Width = 200,
338+
X = 10,
339+
Y = 40,
340+
Role = "Signer 1"
341+
}
342+
};
343+
344+
var editDocument = await DocumentExamples
345+
.EditDocumentTextFields(testDocument.Id, editFields, token)
346+
.ConfigureAwait(false);
347+
348+
var documentEdited = await testContext.Documents.GetDocumentAsync(editDocument.Id).ConfigureAwait(false);
349+
Assert.IsNull(documentEdited.Fields.FirstOrDefault()?.JsonAttributes.PrefilledText);
350+
Assert.AreEqual("Text_1", documentEdited.Fields.FirstOrDefault()?.JsonAttributes.Name);
351+
352+
var fields = new List<TextField>
353+
{
354+
new TextField
355+
{
356+
Name = "Text_1",
357+
PrefilledText = "Test Prefill"
358+
}
359+
};
360+
361+
await DocumentExamples.PrefillTextFields(testDocument.Id, fields, token).ConfigureAwait(false);
362+
363+
var documentFinal = await testContext.Documents.GetDocumentAsync(testDocument.Id).ConfigureAwait(false);
364+
Assert.AreEqual("Test Prefill", documentFinal.Fields.FirstOrDefault()?.JsonAttributes.PrefilledText);
365+
}
366+
312367
#endregion
313368

314369
#region Invites Examples
@@ -500,7 +555,7 @@ public async Task CreateTemplateFromDocumentTest()
500555
.UploadDocumentWithFieldExtract(PdfWithSignatureField, token).ConfigureAwait(false);
501556
disposableDocumentId = document?.Id;
502557

503-
var templateName = "Template Name";
558+
const string templateName = "Template Name";
504559
var result = await DocumentExamples.CreateTemplateFromTheDocument(document?.Id, templateName, token).ConfigureAwait(false);
505560
var template = await testContext.Documents.GetDocumentAsync(result.Id).ConfigureAwait(false);
506561

SignNow.Net.Test/AcceptanceTests/DocumentServiceTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Linq;
43
using System.Threading.Tasks;

0 commit comments

Comments
 (0)