Skip to content

Commit

Permalink
add: deleteSignatory (#21)
Browse files Browse the repository at this point in the history
* add: deleteSignatory

* fix delete signatory test assertion
  • Loading branch information
mickhansen authored Mar 20, 2024
1 parent 0f6ea3f commit 8bf517e
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Criipto.Signatures.IntegrationTests/DeleteSignatoryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Xunit;
using Criipto.Signatures;
using Criipto.Signatures.Models;
using System.Collections.Generic;
using System.Linq;
namespace Criipto.Signatures.IntegrationTests;

public class DeleteSignatoryTests
{

[Fact]
public async void MutationDeletesSignatory()
{
using (var client = new CriiptoSignaturesClient(Dsl.CLIENT_ID, Dsl.CLIENT_SECRET, "test"))
{
// Arrange
var signatureOrder = await client.CreateSignatureOrder(
new CreateSignatureOrderInput()
{
title = "Title",
expiresInDays = 1,
documents = new List<DocumentInput>(){
new DocumentInput {
pdf =
new PadesDocumentInput
{
title = "TEST",
blob = Dsl.Sample
}
}
},
}
);

var signatory = await client.AddSignatory(
signatureOrder
);

// Act
var actual = await client.DeleteSignatory(signatory);

// Assert
Assert.Empty(actual.signatories);
}
}
}
31 changes: 31 additions & 0 deletions Criipto.Signatures/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,37 @@ public async Task<Signatory> SignActingAs(string signatoryId, SignActingAsInput
return await SignActingAs(input).ConfigureAwait(false);
}

public async Task<SignatureOrder> DeleteSignatory(DeleteSignatoryInput input)
{
var data = await SendMutation(
DeleteSignatoryMutation.Request(new { input = input }),
() => new { deleteSignatory = new DeleteSignatoryOutput() }
).ConfigureAwait(false);

return data.deleteSignatory.signatureOrder;
}

public async Task<SignatureOrder> DeleteSignatory(string signatureOrderId, string signatoryId)
{
if (signatureOrderId == null) throw new ArgumentNullException(nameof(signatureOrderId));
if (signatoryId == null) throw new ArgumentNullException(nameof(signatoryId));

var input = new DeleteSignatoryInput();
input.signatureOrderId = signatureOrderId;
input.signatoryId = signatoryId;
return await DeleteSignatory(input).ConfigureAwait(false);
}

public async Task<SignatureOrder> DeleteSignatory(Signatory signatory)
{
if (signatory == null) throw new ArgumentNullException(nameof(signatory));

var input = new DeleteSignatoryInput();
input.signatureOrderId = signatory.signatureOrder.id;
input.signatoryId = signatory.id;
return await DeleteSignatory(input).ConfigureAwait(false);
}

public async Task<SignatureOrder?> QuerySignatureOrder(string signatureOrderId, bool includeDocuments = false)
{
if (signatureOrderId == null) throw new ArgumentNullException(nameof(signatureOrderId));
Expand Down
104 changes: 104 additions & 0 deletions Criipto.Signatures/Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -125,6 +128,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -190,6 +196,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -242,6 +251,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -294,6 +306,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -369,6 +384,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -443,6 +461,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -508,6 +529,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -601,6 +625,77 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
}
documents {
edges {
status
node {
__typename
id
}
}
}
}
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
evidenceProviders {
__typename
id
}
}";

}


public class DeleteSignatoryMutation {
/// <summary>
/// DeleteSignatoryMutation.Request
/// <para>Required variables:<br/> { input=(DeleteSignatoryInput) }</para>
/// <para>Optional variables:<br/> { }</para>
/// </summary>
public static GraphQLRequest Request(object variables = null) {
return new GraphQLRequest {
Query = DeleteSignatoryDocument,
OperationName = "deleteSignatory",
Variables = variables
};
}

/// <remarks>This method is obsolete. Use Request instead.</remarks>
public static GraphQLRequest getDeleteSignatoryMutation() {
return Request();
}

public static string DeleteSignatoryDocument = @"
mutation deleteSignatory($input: DeleteSignatoryInput!) {
deleteSignatory(input: $input) {
signatureOrder {
...BasicSignatureOrder
}
}
}
fragment BasicSignatory on Signatory {
id
status
href
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -664,6 +759,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -750,6 +848,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down Expand Up @@ -816,6 +917,9 @@ fragment BasicSignatory on Signatory {
downloadHref
reference
role
signatureOrder {
id
}
evidenceProviders {
__typename
id
Expand Down
12 changes: 12 additions & 0 deletions Criipto.Signatures/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ fragment BasicSignatory on Signatory {
reference
role

signatureOrder {
id
}

evidenceProviders {
__typename
id
Expand Down Expand Up @@ -153,6 +157,14 @@ mutation extendSignatureOrder($input: ExtendSignatureOrderInput!) {
}
}

mutation deleteSignatory($input: DeleteSignatoryInput!) {
deleteSignatory(input: $input) {
signatureOrder {
... BasicSignatureOrder
}
}
}

query signatureOrder($id: ID!) {
signatureOrder(id: $id) {
... BasicSignatureOrder
Expand Down

0 comments on commit 8bf517e

Please sign in to comment.