Skip to content

Commit

Permalink
add test for extendSignatureOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
mickhansen committed Jan 15, 2024
1 parent 8d1f155 commit e109320
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 4 deletions.
49 changes: 49 additions & 0 deletions Criipto.Signatures.IntegrationTests/ExtendSignatureOrderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Xunit;
using Criipto.Signatures;
using Criipto.Signatures.Models;
using System.Collections.Generic;
using System.IO;
using System;
namespace Criipto.Signatures.IntegrationTests;

public class ExtendSignatureOrderTests
{
[Fact]
public async void MutationReturnsSignatureOrder()
{
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
}
}
}
}
);

// Act
var actual = await client.ExtendSignatureOrder(
signatureOrder,
new ExtendSignatureOrderInput
{
additionalExpirationInDays = 7
}
);

// Assert
Assert.NotNull(actual?.id);
Assert.Equal(DateTimeOffset.Parse(actual!.expiresAt), DateTimeOffset.Parse(signatureOrder.expiresAt).AddDays(7));
}
}
}
14 changes: 11 additions & 3 deletions Criipto.Signatures/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,18 @@ public async Task<SignatureOrder> ExtendSignatureOrder(ExtendSignatureOrderInput

var data = await SendMutation(
ExtendSignatureOrderMutation.Request(new { input = input }),
() => new { extendSignatureOrderDocument = new ExtendSignatureOrderOutput() }
() => new { extendSignatureOrder = new ExtendSignatureOrderOutput() }
).ConfigureAwait(false);

return data.extendSignatureOrderDocument.signatureOrder;

return data.extendSignatureOrder.signatureOrder;
}
public async Task<SignatureOrder> ExtendSignatureOrder(SignatureOrder signatureOrder, ExtendSignatureOrderInput input)
{
if (signatureOrder == null) throw new ArgumentNullException(nameof(signatureOrder));
if (input == null) throw new ArgumentNullException(nameof(input));

input.signatureOrderId = signatureOrder.id;
return await ExtendSignatureOrder(input).ConfigureAwait(false);
}

public async Task<SignatureOrder> CloseSignatureOrder(CloseSignatureOrderInput input)
Expand Down
1 change: 0 additions & 1 deletion Criipto.Signatures/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public override bool CanConvert(Type objectType)
if (reader.TokenType == JsonToken.String)
{
string? enumText = reader.Value?.ToString();
Console.WriteLine(enumText);

if (!string.IsNullOrEmpty(enumText))
{
Expand Down
16 changes: 16 additions & 0 deletions Criipto.Signatures/Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
Expand Down Expand Up @@ -140,6 +142,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
Expand Down Expand Up @@ -382,6 +386,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
Expand Down Expand Up @@ -454,6 +460,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
Expand Down Expand Up @@ -610,6 +618,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
Expand Down Expand Up @@ -671,6 +681,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
Expand Down Expand Up @@ -755,6 +767,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
Expand Down Expand Up @@ -819,6 +833,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt
signatories {
...BasicSignatory
}
Expand Down
2 changes: 2 additions & 0 deletions Criipto.Signatures/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ fragment BasicSignatory on Signatory {
fragment BasicSignatureOrder on SignatureOrder {
id
status
closedAt
expiresAt

signatories {
...BasicSignatory
Expand Down

0 comments on commit e109320

Please sign in to comment.