Skip to content

Commit

Permalink
Add new phone outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Jun 27, 2024
1 parent c71bed9 commit 667fc45
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 2 deletions.
4 changes: 4 additions & 0 deletions MaxMind.MinFraud.UnitTest/Response/InsightsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public void TestInsights()
""is_free"": true
}},
""shipping_address"": {{""is_in_ip_country"": true}},
""shipping_phone"": {{""is_voip"": true}},
""billing_address"": {{""is_in_ip_country"": true}},
""billing_phone"": {{""is_voip"": false}},
""funds_remaining"": 1.20,
""queries_remaining"": 123,
""risk_score"": 0.01,
Expand All @@ -40,7 +42,9 @@ public void TestInsights()
Assert.Equal("accept", insights.Disposition.Action);
Assert.True(insights.Email.IsFree);
Assert.True(insights.ShippingAddress.IsInIPCountry);
Assert.True(insights.ShippingPhone.IsVoip);
Assert.True(insights.BillingAddress.IsInIPCountry);
Assert.False(insights.BillingPhone.IsVoip);
Assert.Equal(id, insights.Id.ToString());
Assert.Equal(1.20m, insights.FundsRemaining);
Assert.Equal(123, insights.QueriesRemaining);
Expand Down
32 changes: 32 additions & 0 deletions MaxMind.MinFraud.UnitTest/Response/PhoneTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Text.Json;
using Xunit;
using Phone = MaxMind.MinFraud.Response.Phone;

namespace MaxMind.MinFraud.UnitTest.Response
{
public class PhoneTest
{
[Fact]
public void TestPhone()
{
var country = "US";
var networkOperator = "Verizon";
var numberType = "mobile";
var phone = JsonSerializer.Deserialize<Phone>(
@$"
{{
""country"": ""{country}"",
""is_voip"": true,
""network_operator"": ""{networkOperator}"",
""number_type"": ""{numberType }""
}}
")!;

Assert.Equal(country, phone.Country);
Assert.True(phone.IsVoip);
Assert.Equal(networkOperator, phone.NetworkOperator);
Assert.Equal(numberType, phone.NumberType);
}
}
}
12 changes: 12 additions & 0 deletions MaxMind.MinFraud.UnitTest/TestData/factors-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
"distance_to_ip_location": 5465,
"is_in_ip_country": false
},
"billing_phone": {
"country": "US",
"is_voip": true,
"network_operator": "Verizon/1",
"number_type": "fixed"
},
"credit_card": {
"issuer": {
"name": "Bank of No Hope",
Expand Down Expand Up @@ -185,6 +191,12 @@
"latitude": 35.704729,
"longitude": -97.568619
},
"shipping_phone": {
"country": "CA",
"is_voip": true,
"network_operator": "Telus Mobility-SVR/2",
"number_type": "mobile"
},
"subscores": {
"avs_result": 0.01,
"billing_address": 0.02,
Expand Down
12 changes: 12 additions & 0 deletions MaxMind.MinFraud.UnitTest/TestData/insights-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
"distance_to_ip_location": 5465,
"is_in_ip_country": false
},
"billing_phone": {
"country": "US",
"is_voip": true,
"network_operator": "Verizon/1",
"number_type": "fixed"
},
"credit_card": {
"issuer": {
"name": "Bank of No Hope",
Expand Down Expand Up @@ -185,6 +191,12 @@
"latitude": 35.704729,
"longitude": -97.568619
},
"shipping_phone": {
"country": "CA",
"is_voip": true,
"network_operator": "Telus Mobility-SVR/2",
"number_type": "mobile"
},
"warnings": [
{
"code": "INPUT_INVALID",
Expand Down
18 changes: 16 additions & 2 deletions MaxMind.MinFraud/Response/Insights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,34 @@ public class Insights : Score
[JsonPropertyName("shipping_address")]
public ShippingAddress ShippingAddress { get; init; } = new ShippingAddress();

/// <summary>
/// An object containing minFraud data related to the shipping phone
/// used in the transaction.
/// </summary>
[JsonPropertyName("shipping_phone")]
public Phone ShippingPhone { get; init; } = new Phone();

/// <summary>
/// An object containing minFraud data related to the billing address
/// used in the transaction.
/// </summary>
[JsonPropertyName("billing_address")]
public BillingAddress BillingAddress { get; init; } = new BillingAddress();

/// <summary>
/// An object containing minFraud data related to the billing phone
/// used in the transaction.
/// </summary>
[JsonPropertyName("billing_phone")]
public Phone BillingPhone { get; init; } = new Phone();

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return $"{base.ToString()}, IPAddress: {IPAddress}, CreditCard: {CreditCard}, Device: {Device}, Email: {Email}, ShippingAddress: {ShippingAddress}, BillingAddress: {BillingAddress}";
return $"{base.ToString()}, IPAddress: {IPAddress}, CreditCard: {CreditCard}, Device: {Device}, Email: {Email}, ShippingAddress: {ShippingAddress}, ShippingPhone: {ShippingPhone}, BillingAddress: {BillingAddress}, BillingPhone: {BillingPhone}";
}
}
}
}
52 changes: 52 additions & 0 deletions MaxMind.MinFraud/Response/Phone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Text.Json.Serialization;

namespace MaxMind.MinFraud.Response
{
/// <summary>
/// This object contains information about the billing or shipping phone.
/// </summary>
public sealed class Phone
{
/// <summary>
/// A two-character ISO 3166-1 country code for the country associated
/// with the phone number.
/// </summary>
[JsonPropertyName("country")]
public string? Country { get; init; }

/// <summary>
/// This is <c>true</c> if the phone number is a Voice over Internet
/// Protocol (VoIP) number allocated by a regulator. It is <c>false</c>
/// if the phone number is not a VoIP number allocated by a regulator.
/// The property is null if a valid phone number has not been provided
/// or if we have data for the phone number.
/// </summary>
[JsonPropertyName("is_voip")]
public bool? IsVoip { get; init; }

/// <summary>
/// The name of the original network operator associated with the
/// phone number. This property does not reflect phone numbers that
/// have been ported from the original operator to another, nor does
/// it identify mobile virtual network operators.
/// </summary>
[JsonPropertyName("network_operator")]
public string? NetworkOperator { get; init; }

/// <summary>
/// One of the following values: <c>fixed</c> or <c>mobile</c>.
/// Additional values may be added in the future.
/// </summary>
[JsonPropertyName("number_type")]
public string? NumberType { get; init; }

/// <summary>
/// Returns a string that represents the current object.
/// </summary>
public override string ToString()
{
return $"Country: {Country}, IsVoip: {IsVoip}, " +
$"NetworkOperator: {NetworkOperator}, NumberType: {NumberType}";
}
}
}
5 changes: 5 additions & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Release Notes
* Updated `TransactionReport` to make the `ipAddress` parameter optional. Now
the `tag` and at least one of the following parameters must be supplied:
`ipAddress`, `maxmindId`, `minfraudID`, `transactionID`.
* Added `BillingPhone` and `ShippingPhone` properties to the minFraud Insights
and Factors response models. These contain objects with information about
the respective phone numbers. Please see [our developer
site](https://dev.maxmind.com/minfraud/api-documentation/responses/) for
more information.

4.3.0 (2024-04-16)
------------------
Expand Down

0 comments on commit 667fc45

Please sign in to comment.