Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 alpha #87

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
environment:
SH_VERSION_SUFFIX: 'preview'
SH_VERSION_SUFFIX: 'alpha'

github_auth_token:
secure: qOQatfN0omwlCj5Td82fK9Z3ZKQom0Nv3/x6OH98iB+L9mfOf26bH3q+PnQ7y7g7

configuration: Release

image: Visual Studio 2017
image: Visual Studio 2019

for:
- branches:
only:
- master
- legacy
environment:
SH_VERSION_SUFFIX: ''

before_build:
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { Set-AppveyorBuildVariable 'SH_VERSION_SUFFIX' 'alpha' }
- dotnet tool install --global dotnet-sonarscanner
- dotnet add "src/SignhostAPIClient.Tests/SignhostAPIClient.Tests.csproj" package coverlet.msbuild
- cmd: dotnet restore "src\SignhostAPIClient.sln
- dotnet add "src/SignhostAPIClient.Tests/SignhostAPIClient.Tests.csproj" package coverlet.msbuild --version 3.1.0
- cmd: dotnet restore "src\SignhostAPIClient.sln"

build_script:
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER ) { dotnet sonarscanner begin /key:"SignhostAPIClient" /d:"sonar.host.url=https://sonarcloud.io" /organization:"signhost" /d:"sonar.login=$env:sonarcloud_auth_token" /d:"sonar.cs.opencover.reportsPaths=src\SignhostAPIClient.Tests\result.cover" /d:"sonar.pullrequest.base=master" /d:"sonar.pullrequest.branch=PR-$env:APPVEYOR_PULL_REQUEST_NUMBER" /d:"sonar.pullrequest.key=$env:APPVEYOR_PULL_REQUEST_NUMBER" /d:"sonar.pullrequest.provider=GitHub" /d:"sonar.pullrequest.github.repository=Evidos/SignhostClientLibrary" }
- ps: if (-Not $env:APPVEYOR_PULL_REQUEST_NUMBER) { dotnet sonarscanner begin /key:"SignhostAPIClient" /d:"sonar.host.url=https://sonarcloud.io" /organization:"signhost" /d:"sonar.login=$env:sonarcloud_auth_token" /d:"sonar.cs.opencover.reportsPaths=src\SignhostAPIClient.Tests\result.cover" }
- dotnet build "src\SignhostAPIClient.sln"
- dotnet pack "src\SignhostAPIClient\SignhostAPIClient.csproj"

test_script:
- dotnet test --no-build "src/SignhostAPIClient.Tests/SignhostAPIClient.Tests.csproj" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput="./result.cover" /p:Exclude="[xunit*]*"

after_test:
- ps: dotnet sonarscanner end /d:"sonar.login=$env:sonarcloud_auth_token"; $LASTEXITCODE=0

nuget:
project_feed: true
Expand Down
54 changes: 31 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Signhost client library
[![join gitter chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Evidos/signhost-api)
[![Build status](https://ci.appveyor.com/api/projects/status/696lddgivr6kkhsd/branch/master?svg=true)](https://ci.appveyor.com/project/MrJoe/signhostclientlibrary-xcr5f/branch/master)
[![Nuget package](https://img.shields.io/nuget/v/SignhostClientLibrary.svg)](https://www.nuget.org/Packages/SignhostClientLibrary)
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=SignhostAPIClient&metric=alert_status)](https://sonarcloud.io/dashboard?id=SignhostAPIClient)
[![Nuget package](https://img.shields.io/nuget/v/EntrustSignhostClientLibrary.svg)](https://www.nuget.org/Packages/EntrustSignhostClientLibrary)

This is a client library in c# to demonstrate the usage of the [signhost api](https://api.signhost.com/) using .net.
You will need a valid APPKey and APIKey.
Expand All @@ -11,46 +10,55 @@ You can request a APPKey for signhost at [ondertekenen.nl](https://portal.signho
### Install
Get it on NuGet:

`PM> Install-Package SignhostClientLibrary`
`PM> Install-Package EntrustSignhostClientLibrary`

### Example code
The following code is an example of how to create and start a sign transaction with two documents.
```c#
var client = new SignHostApiClient(new SignHostApiClientSettings("AppName appkey", "apikey or usertoken"));

var transaction = await client.CreateTransactionAsync(new Transaction
{
Signers = new List<Signer>
{
new Signer
{
Email = "john.doe@example.com",
var settings = new SignHostApiClientSettings(
"AppName appkey"));

var client = new SignHostApiClient(settings);

var transaction = await client.CreateTransactionAsync(new Transaction {
Signers = new List<Signer> {
new Signer {
Email = "john.doe@example.com",
SignRequestMessage = "Could you please sign this document?",
SendSignRequest = true,
SendSignRequest = true,
/*
* The verifications listed here are executed in order.
* Your last verification _must_ be one of the following:
* - PhoneNumberVerification
* - ScribbleVerification
* - ConsentVerification
*/
Verifications = new List<IVerification> {
Verifications = new List<IVerification> {
new PhoneNumberVerification {
Number = "+3161234567890"
Number = "+3161234567890",
},
new ScribbleVerification {
ScribbleName = "John Doe",
RequireHandsignature = true,
ScribbleName = "John Doe",
RequireHandsignature = true,
},
}
}
}
},
},
},
});

await client.AddOrReplaceFileToTransactionAsync("PathToFile", transaction.Id, "First document", new FileUploadOptions());
await client.AddOrReplaceFileToTransactionAsync("PathOtherFile", transaction.Id, "General agreement", new FileUploadOptions());
await client.AddOrReplaceFileToTransactionAsync(
"PathToFile",
transaction.Id,
"First document",
new FileUploadOptions());

await client.AddOrReplaceFileToTransactionAsync(
"PathOtherFile",
transaction.Id,
"General agreement",
new FileUploadOptions());

/* When everything is setup we can start the transaction flow */
/* When everything is setup we can start the transaction flow. */
await client.StartTransactionAsync(transaction.Id);

```
7 changes: 1 addition & 6 deletions src/SignhostAPIClient.Tests/SignhostApiClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ namespace Signhost.APIClient.Rest.Tests
public class SignHostApiClientTests
{
private SignHostApiClientSettings settings = new SignHostApiClientSettings(
"AppKey",
"AuthKey"
"AppKey"
) {
Endpoint = "http://localhost/api/"
};
Expand Down Expand Up @@ -575,22 +574,18 @@ public async Task When_a_complete_transaction_flow_is_created_headers_are_not_se
var mockHttp = new MockHttpMessageHandler();
mockHttp.Expect(HttpMethod.Post, "http://localhost/api/transaction")
.WithHeaders("Application", "APPKey AppKey")
.WithHeaders("Authorization", "APIKey AuthKey")
.WithHeaders("X-Custom", "test")
.Respond(new StringContent(RequestBodies.TransactionSingleSignerJson));
mockHttp.Expect(HttpMethod.Put, "http://localhost/api/transaction/*/file/somefileid")
.WithHeaders("Application", "APPKey AppKey")
.WithHeaders("Authorization", "APIKey AuthKey")
.WithHeaders("X-Custom", "test")
.Respond(HttpStatusCode.Accepted, new StringContent(RequestBodies.AddOrReplaceFileMetaToTransaction));
mockHttp.Expect(HttpMethod.Put, "http://localhost/api/transaction/*/file/somefileid")
.WithHeaders("Application", "APPKey AppKey")
.WithHeaders("Authorization", "APIKey AuthKey")
.WithHeaders("X-Custom", "test")
.Respond(HttpStatusCode.Created);
mockHttp.Expect(HttpMethod.Put, "http://localhost/api/transaction/*/start")
.WithHeaders("Application", "APPKey AppKey")
.WithHeaders("Authorization", "APIKey AuthKey")
.WithHeaders("X-Custom", "test")
.Respond(HttpStatusCode.NoContent);

Expand Down
4 changes: 2 additions & 2 deletions src/SignhostAPIClient/Rest/DataObjects/Signer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

Expand Down Expand Up @@ -38,7 +38,7 @@ private Signer(IReadOnlyList<Activity> activities)

public bool? SendSignConfirmation { get; set; }

public int DaysToRemind { get; set; }
public int? DaysToRemind { get; set; }

public string Language { get; set; }

Expand Down
5 changes: 0 additions & 5 deletions src/SignhostAPIClient/Rest/ISignhostApiClientSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ namespace Signhost.APIClient.Rest

public interface ISignHostApiClientSettings
{
/// <summary>
/// Gets the usertoken identifying an authorized user.
/// </summary>
string APIKey { get; }

/// <summary>
/// Gets the app key of your applications.
/// </summary>
Expand Down
4 changes: 0 additions & 4 deletions src/SignhostAPIClient/Rest/SignHostApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@ public SignHostApiClient(
"SignhostClientLibrary",
Version));
this.client.DefaultRequestHeaders.Add("Application", ApplicationHeader);
this.client.DefaultRequestHeaders.Add("Authorization", AuthorizationHeader);
this.client.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse($"application/vnd.signhost.{ApiVersion}+json"));
settings.AddHeader?.Invoke(this.client.DefaultRequestHeaders.Add);
}

private string ApplicationHeader
=> $"APPKey {settings.APPKey}";

private string AuthorizationHeader
=> $"APIKey {settings.APIKey}";

/// <summary>
/// Globally register an additional verification type.
/// </summary>
Expand Down
11 changes: 1 addition & 10 deletions src/SignhostAPIClient/Rest/SignHostApiClientSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@ public class SignHostApiClientSettings
{
public const string DefaultEndpoint = "https://api.signhost.com/api/";

public SignHostApiClientSettings(string appkey, string apikey)
public SignHostApiClientSettings(string appkey)
{
APPKey = appkey;
APIKey = apikey;
}

[Obsolete("Obsoleted by UserToken")]
public string APIKey { get; private set; }

public string UserToken {
get { return APIKey; }
set { APIKey = value; }
}

public string APPKey { get; private set; }
Expand Down
11 changes: 6 additions & 5 deletions src/SignhostAPIClient/SignhostAPIClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
<PropertyGroup Label="Package">
<VersionBuildNumber Condition="'$(APPVEYOR_BUILD_NUMBER)' != ''">$(APPVEYOR_BUILD_NUMBER)</VersionBuildNumber>
<VersionBuildNumber Condition="'$(VersionBuildNumber)' == ''">0</VersionBuildNumber>
<VersionPrefix>3.0.$(VersionBuildNumber)</VersionPrefix>
<VersionPrefix>4.0.$(VersionBuildNumber)</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)' == ''">$(SH_VERSION_SUFFIX)</VersionSuffix>
<Authors>Evidos</Authors>
<Authors>Entrust</Authors>
<Product>Signhost</Product>
<Copyright>Copyright 2016-2018 © Evidos</Copyright>
<Copyright>Copyright © Entrust</Copyright>
<PackageProjectUrl>https://github.com/Evidos/SignhostClientLibrary</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<PackageId>SignhostClientLibrary</PackageId>
<PackageId>EntrustSignhostClientLibrary</PackageId>
<PackageTags>sign;signing;digital signature;pdf</PackageTags>
<PackageReleaseNotes>
* 4.0.0 - Added access token marks a significant enhancement in the security and authentication mechanisms of the application
* 3.0.0 - Bumped verifications support and added .net core target
* 2.3.0 - Added support for custom forms creation over the API
* 2.2.2 - Added basic parameter validation
Expand All @@ -29,7 +30,7 @@
* 2.1.0 - Lowered minimum framework from 4.5.2 to 4.5
* 2.0.0 - First release using new multidoc API.
</PackageReleaseNotes>
<Company>Evidos</Company>
<Company>Entrust</Company>
<Description>A .NET library for the signhost.com api.</Description>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
Expand Down