Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Apr 15, 2024
2 parents fd02cd5 + 73d9366 commit 2d9aad7
Show file tree
Hide file tree
Showing 7 changed files with 741 additions and 605 deletions.
1,230 changes: 628 additions & 602 deletions CHANGELOG.md

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions Vonage.Test/VerifyV2/NextWorkflow/E2ETest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Net;
using System.Threading.Tasks;
using Vonage.Test.Common.Extensions;
using Vonage.VerifyV2.NextWorkflow;
using WireMock.ResponseBuilders;
using Xunit;

namespace Vonage.Test.VerifyV2.NextWorkflow;

[Trait("Category", "E2E")]
public class E2ETest : E2EBase
{
[Fact]
public async Task NextWorkflow()
{
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create()
.WithPath("/v2/verify/68c2b32e-55ba-4a8e-b3fa-43b3ae6cd1fb/next_workflow")
.WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue)
.UsingPost())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK));
await this.Helper.VonageClient.VerifyV2Client.NextWorkflowAsync(
NextWorkflowRequest.Parse(Guid.Parse("68c2b32e-55ba-4a8e-b3fa-43b3ae6cd1fb")))
.Should()
.BeSuccessAsync();
}
}
30 changes: 30 additions & 0 deletions Vonage.Test/VerifyV2/NextWorkflow/RequestTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Vonage.Test.Common.Extensions;
using Vonage.VerifyV2.NextWorkflow;
using Xunit;

namespace Vonage.Test.VerifyV2.NextWorkflow;

[Trait("Category", "Request")]
public class RequestTest
{
[Fact]
public void GetEndpointPath_ShouldReturnApiEndpoint() =>
NextWorkflowRequest.Parse(new Guid("f3a065af-ac5a-47a4-8dfe-819561a7a287"))
.Map(request => request.GetEndpointPath())
.Should()
.BeSuccess("/v2/verify/f3a065af-ac5a-47a4-8dfe-819561a7a287/next_workflow");

[Fact]
public void Parse_ShouldReturnFailure_GivenRequestIsEmpty() =>
NextWorkflowRequest.Parse(Guid.Empty)
.Should()
.BeParsingFailure("RequestId cannot be empty.");

[Fact]
public void Parse_ShouldReturnSuccess() =>
NextWorkflowRequest.Parse(new Guid("f3a065af-ac5a-47a4-8dfe-819561a7a287"))
.Map(request => request.RequestId)
.Should()
.BeSuccess(new Guid("f3a065af-ac5a-47a4-8dfe-819561a7a287"));
}
8 changes: 8 additions & 0 deletions Vonage/VerifyV2/IVerifyV2Client.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Vonage.Common.Monads;
using Vonage.VerifyV2.Cancel;
using Vonage.VerifyV2.NextWorkflow;
using Vonage.VerifyV2.StartVerification;
using Vonage.VerifyV2.VerifyCode;

Expand All @@ -18,6 +19,13 @@ public interface IVerifyV2Client
/// <returns>Success or Failure.</returns>
Task<Result<Unit>> CancelAsync(Result<CancelRequest> request);

/// <summary>
/// Move the request onto the next workflow, if available.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>Success or Failure.</returns>
Task<Result<Unit>> NextWorkflowAsync(Result<NextWorkflowRequest> request);

/// <summary>
/// Requests a verification to be sent to a user.
/// </summary>
Expand Down
40 changes: 40 additions & 0 deletions Vonage/VerifyV2/NextWorkflow/NextWorkflowRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Net.Http;
using Vonage.Common.Client;
using Vonage.Common.Monads;
using Vonage.Common.Validation;

namespace Vonage.VerifyV2.NextWorkflow;

/// <inheritdoc />
public readonly struct NextWorkflowRequest : IVonageRequest
{
private NextWorkflowRequest(Guid requestId) => this.RequestId = requestId;

/// <summary>
/// ID of the verify request.
/// </summary>
public Guid RequestId { get; internal init; }

/// <inheritdoc />
public HttpRequestMessage BuildRequestMessage() => VonageRequestBuilder
.Initialize(HttpMethod.Post, this.GetEndpointPath())
.Build();

/// <inheritdoc />
public string GetEndpointPath() => $"/v2/verify/{this.RequestId}/next_workflow";

/// <summary>
/// Parses the input into a NextWorkflowRequest.
/// </summary>
/// <param name="requestId">The verify request identifier.</param>
/// <returns>A success state with the request if the parsing succeeded. A failure state with an error if it failed.</returns>
public static Result<NextWorkflowRequest> Parse(Guid requestId) =>
Result<NextWorkflowRequest>
.FromSuccess(new NextWorkflowRequest(requestId))
.Map(InputEvaluation<NextWorkflowRequest>.Evaluate)
.Bind(evaluation => evaluation.WithRules(VerifyRequestId));

private static Result<NextWorkflowRequest> VerifyRequestId(NextWorkflowRequest request) =>
InputValidation.VerifyNotEmpty(request, request.RequestId, nameof(RequestId));
}
5 changes: 5 additions & 0 deletions Vonage/VerifyV2/VerifyV2Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Vonage.Common.Monads;
using Vonage.Serialization;
using Vonage.VerifyV2.Cancel;
using Vonage.VerifyV2.NextWorkflow;
using Vonage.VerifyV2.StartVerification;
using Vonage.VerifyV2.VerifyCode;

Expand All @@ -23,6 +24,10 @@ internal class VerifyV2Client : IVerifyV2Client
public Task<Result<Unit>> CancelAsync(Result<CancelRequest> request) =>
this.vonageClient.SendAsync(request);

/// <inheritdoc />
public Task<Result<Unit>> NextWorkflowAsync(Result<NextWorkflowRequest> request) =>
this.vonageClient.SendAsync(request);

/// <inheritdoc />
public Task<Result<StartVerificationResponse>> StartVerificationAsync(Result<StartVerificationRequest> request) =>
this.vonageClient.SendWithResponseAsync<StartVerificationRequest, StartVerificationResponse>(request);
Expand Down
6 changes: 3 additions & 3 deletions Vonage/Vonage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>7.1.0</Version>
<Version>7.2.0</Version>
<PackageLicenseExpression/>
<PackageProjectUrl>https://github.com/Vonage/vonage-dotnet</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/Vonage/vonage-dotnet-sdk/releases/tag/v7.1.0</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/Vonage/vonage-dotnet-sdk/releases/tag/v7.2.0</PackageReleaseNotes>
<PackageTags>SMS voice telephony phone Vonage</PackageTags>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NoWarn>701;1702;1572</NoWarn>
Expand All @@ -29,7 +29,7 @@
<RepositoryType>git</RepositoryType>
<PackageIcon>VonageLogo_Symbol_Black.png</PackageIcon>
<PackageIconUrl/>
<Description>Official C#/.NET wrapper for the Vonage API. To use it you will need a Vonage account. Sign up for free at vonage.com. For full API documentation refer to developer.vonage.com.
<Description>Official C#/.NET wrapper for the Vonage API. To use it you will need a Vonage account. Sign up for free at vonage.com. For full API documentation refer to developer.vonage.com.&#xD;
</Description>
<LangVersion>latest</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down

0 comments on commit 2d9aad7

Please sign in to comment.