Skip to content

Commit

Permalink
feat: FraudCheck without FraudScore or SimSwap
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Dec 1, 2023
1 parent 4ae4dda commit 4309d11
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"request_id": "6cb4c489-0fc8-4c40-8c3d-95e7e74f9450",
"type": "phone",
"phone": {
"phone": "16197363066",
"carrier": "Orange France",
"type": "MOBILE"
},
"sim_swap": {
"status": "completed",
"swapped": true,
"reason": "Mobile Network Operator Not Supported"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"request_id": "6cb4c489-0fc8-4c40-8c3d-95e7e74f9450",
"type": "phone",
"phone": {
"phone": "16197363066",
"carrier": "Orange France",
"type": "MOBILE"
},
"fraud_score": {
"risk_score": "54",
"risk_recommendation": "block",
"label": "low",
"status": "completed"
}
}
38 changes: 32 additions & 6 deletions Vonage.Test.Unit/NumberInsightsV2/FraudCheck/SerializationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ public void ShouldDeserialize200() => this.helper.Serializer
.Should()
.BeSuccess(GetExpectedFraudCheckResponse());

[Fact]
public void ShouldDeserialize200WithoutFraudScore() => this.helper.Serializer
.DeserializeObject<FraudCheckResponse>(this.helper.GetResponseJson())
.Should()
.BeSuccess(GetExpectedFraudCheckResponseWithoutFraudScore());

[Fact]
public void ShouldDeserialize200WithoutSimSwap() => this.helper.Serializer
.DeserializeObject<FraudCheckResponse>(this.helper.GetResponseJson())
.Should()
.BeSuccess(GetExpectedFraudCheckResponseWithoutSimSwap());

[Fact]
public void ShouldSerializeWithFraudScore() => BuildRequestWithFraudScore()
.GetStringContent()
Expand All @@ -38,6 +50,26 @@ public void ShouldSerializeWithSimSwap() => BuildRequestWithSimSwap()
.Should()
.BeSuccess(this.helper.GetRequestJson());

private static FraudCheckResponse GetExpectedFraudCheckResponseWithoutFraudScore() => new FraudCheckResponse(
new Guid("6cb4c489-0fc8-4c40-8c3d-95e7e74f9450"),
"phone",
new PhoneData("16197363066", "Orange France", "MOBILE"),
Maybe<FraudScore>.None,
Maybe<SimSwap>.Some(new SimSwap(SimSwapStatus.Completed, true, "Mobile Network Operator Not Supported")));

private static FraudCheckResponse GetExpectedFraudCheckResponseWithoutSimSwap() => new FraudCheckResponse(
new Guid("6cb4c489-0fc8-4c40-8c3d-95e7e74f9450"),
"phone",
new PhoneData("16197363066", "Orange France", "MOBILE"),
Maybe<FraudScore>.Some(new FraudScore("54", RiskRecommendation.Block, FraudScoreLabel.Low, "completed")),
Maybe<SimSwap>.None);

internal static Result<FraudCheckRequest> BuildRequestWithFraudScore() =>
FraudCheckRequest.Build()
.WithPhone("447009000000")
.WithFraudScore()
.Create();

internal static Result<FraudCheckRequest> BuildRequestWithFraudScoreAndSimSwap() =>
FraudCheckRequest.Build()
.WithPhone("447009000000")
Expand All @@ -57,11 +89,5 @@ internal static Result<FraudCheckRequest> BuildRequestWithSimSwap() =>
new PhoneData("16197363066", "Orange France", "MOBILE"),
Maybe<FraudScore>.Some(new FraudScore("54", RiskRecommendation.Flag, FraudScoreLabel.Medium, "completed")),
Maybe<SimSwap>.Some(new SimSwap(SimSwapStatus.Failed, true, "Mobile Network Operator Not Supported")));

internal static Result<FraudCheckRequest> BuildRequestWithFraudScore() =>
FraudCheckRequest.Build()
.WithPhone("447009000000")
.WithFraudScore()
.Create();
}
}
6 changes: 6 additions & 0 deletions Vonage.Test.Unit/Vonage.Test.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,12 @@
<None Update="NumberInsightsV2\FraudCheck\Data\ShouldSerializeWithSimSwap-request.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="NumberInsightsV2\FraudCheck\Data\ShouldDeserialize200WithoutFraudScore-response.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="NumberInsightsV2\FraudCheck\Data\ShouldDeserialize200WithoutSimSwap-response.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="node ../.scripts/init.js"/>
Expand Down

0 comments on commit 4309d11

Please sign in to comment.