-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: setup base structure for Number Insight V2
- Loading branch information
Showing
11 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Vonage.Common; | ||
using Vonage.Common.Test; | ||
using Vonage.Test.Unit.TestHelpers; | ||
|
||
namespace Vonage.Test.Unit.NumberInsightsV2 | ||
{ | ||
public abstract class E2EBase | ||
{ | ||
protected E2EBase(string serializationNamespace) | ||
{ | ||
this.Helper = E2EHelper.WithBasicCredentials("Vonage.Url.Api"); | ||
this.Serialization = | ||
new SerializationTestHelper(serializationNamespace, JsonSerializer.BuildWithSnakeCase()); | ||
} | ||
|
||
internal readonly E2EHelper Helper; | ||
internal readonly SerializationTestHelper Serialization; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...mberInsightsV2/FraudCheck/Data/ShouldDeserialize200WithFraudScoreAndSimSwap-response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"request_id": "6cb4c489-0fc8-4c40-8c3d-95e7e74f9450", | ||
"type": "phone", | ||
"phone": { | ||
"phone": "16197363066", | ||
"carrier": "Orange France", | ||
"type": "MOBILE" | ||
}, | ||
"fraud_score": { | ||
"risk_score": "54", | ||
"risk_recommendation": "flag", | ||
"label": "medium", | ||
"status": "completed" | ||
}, | ||
"sim_swap": { | ||
"status": "failed", | ||
"reason": "Mobile Network Operator Not Supported" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using Vonage.Common.Test.Extensions; | ||
using Vonage.NumberInsightV2.FraudCheck; | ||
using WireMock.ResponseBuilders; | ||
using Xunit; | ||
|
||
namespace Vonage.Test.Unit.NumberInsightsV2.FraudCheck | ||
{ | ||
[Trait("Category", "E2E")] | ||
public class E2ETest : E2EBase | ||
{ | ||
public E2ETest() : base(typeof(E2ETest).Namespace) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task CreateEmptyUser() | ||
{ | ||
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create() | ||
.WithPath("/v2/ni") | ||
.WithHeader("Authorization", "Basic NzkwZmM1ZTU6QWEzNDU2Nzg5") | ||
.WithBody(this.Serialization.GetRequestJson(nameof(SerializationTest | ||
.ShouldDeserialize200WithFraudScoreAndSimSwap))) | ||
.UsingPost()) | ||
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)); | ||
await this.Helper.VonageClient.NumberInsightV2Client | ||
.PerformFraudCheckAsync(FraudCheckRequest.Build()) | ||
.Should() | ||
.BeSuccessAsync(); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Vonage.Test.Unit/NumberInsightsV2/FraudCheck/SerializationTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using Vonage.Common; | ||
using Vonage.Common.Test; | ||
using Xunit; | ||
|
||
namespace Vonage.Test.Unit.NumberInsightsV2.FraudCheck | ||
{ | ||
public class SerializationTest | ||
{ | ||
private readonly SerializationTestHelper helper = new SerializationTestHelper( | ||
typeof(SerializationTest).Namespace, | ||
JsonSerializer.BuildWithSnakeCase()); | ||
|
||
[Fact] | ||
public void ShouldDeserialize200WithFraudScoreAndSimSwap() => throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Net.Http; | ||
using Vonage.Common.Client; | ||
using Vonage.Common.Monads; | ||
|
||
namespace Vonage.NumberInsightV2.FraudCheck; | ||
|
||
public struct FraudCheckRequest : IVonageRequest | ||
{ | ||
public static Result<FraudCheckRequest> Build() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public HttpRequestMessage BuildRequestMessage() => throw new NotImplementedException(); | ||
|
||
public string GetEndpointPath() => throw new NotImplementedException(); | ||
} |
51 changes: 51 additions & 0 deletions
51
Vonage/NumberInsightV2/FraudCheck/FraudCheckRequestBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using Vonage.Common.Client; | ||
using Vonage.Common.Monads; | ||
|
||
namespace Vonage.NumberInsightV2.FraudCheck; | ||
|
||
internal class FraudCheckRequestBuilder : IBuilderForPhone, IBuilderForOptional | ||
{ | ||
/// <inheritdoc /> | ||
public Result<FraudCheckRequest> Create() => throw new NotImplementedException(); | ||
|
||
/// <inheritdoc /> | ||
public IBuilderForOptional WithFraudScore() => throw new NotImplementedException(); | ||
|
||
/// <inheritdoc /> | ||
public IBuilderForOptional WithPhone(string value) => throw new NotImplementedException(); | ||
|
||
/// <inheritdoc /> | ||
public IBuilderForOptional WithSimSwap() => throw new NotImplementedException(); | ||
} | ||
|
||
/// <summary> | ||
/// Represents a builder for Phone. | ||
/// </summary> | ||
public interface IBuilderForPhone | ||
{ | ||
/// <summary> | ||
/// Sets the Phone. | ||
/// </summary> | ||
/// <param name="value">The phone.</param> | ||
/// <returns>The builder.</returns> | ||
IBuilderForOptional WithPhone(string value); | ||
} | ||
|
||
/// <summary> | ||
/// Represents a builder for optional values. | ||
/// </summary> | ||
public interface IBuilderForOptional : IVonageRequestBuilder<FraudCheckRequest> | ||
{ | ||
/// <summary> | ||
/// Enables Fraud Score in the response. | ||
/// </summary> | ||
/// <returns>The builder.</returns> | ||
IBuilderForOptional WithFraudScore(); | ||
|
||
/// <summary> | ||
/// Enables Sim Swap in the response. | ||
/// </summary> | ||
/// <returns>The builder.</returns> | ||
IBuilderForOptional WithSimSwap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace Vonage.NumberInsightV2.FraudCheck; | ||
|
||
public class FraudCheckResponse | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Threading.Tasks; | ||
using Vonage.Common.Monads; | ||
using Vonage.NumberInsightV2.FraudCheck; | ||
|
||
namespace Vonage.NumberInsightV2; | ||
|
||
/// <summary> | ||
/// Exposes Number Insight V2 features. | ||
/// </summary> | ||
public interface INumberInsightV2Client | ||
{ | ||
/// <summary> | ||
/// Performs a fraud check request with a phone number. | ||
/// </summary> | ||
/// <param name="request">The request.</param> | ||
/// <returns>A result indicating if the request whether succeeded or failed.</returns> | ||
Task<Result<FraudCheckResponse>> PerformFraudCheckAsync(Result<FraudCheckRequest> request); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Vonage.Common.Client; | ||
using Vonage.Common.Monads; | ||
using Vonage.NumberInsightV2.FraudCheck; | ||
|
||
namespace Vonage.NumberInsightV2; | ||
|
||
internal class NumberInsightV2Client : INumberInsightV2Client | ||
{ | ||
public NumberInsightV2Client(VonageHttpClientConfiguration buildConfiguration) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<Result<FraudCheckResponse>> PerformFraudCheckAsync(Result<FraudCheckRequest> request) => | ||
throw new NotImplementedException(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters