From 667fc458b712804ed52781927571d428aaa8afb4 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 27 Jun 2024 14:21:22 -0700 Subject: [PATCH] Add new phone outputs --- .../Response/InsightsTest.cs | 4 ++ .../Response/PhoneTest.cs | 32 ++++++++++++ .../TestData/factors-response.json | 12 +++++ .../TestData/insights-response.json | 12 +++++ MaxMind.MinFraud/Response/Insights.cs | 18 ++++++- MaxMind.MinFraud/Response/Phone.cs | 52 +++++++++++++++++++ releasenotes.md | 5 ++ 7 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 MaxMind.MinFraud.UnitTest/Response/PhoneTest.cs create mode 100644 MaxMind.MinFraud/Response/Phone.cs diff --git a/MaxMind.MinFraud.UnitTest/Response/InsightsTest.cs b/MaxMind.MinFraud.UnitTest/Response/InsightsTest.cs index e58fbe20..d7eabd18 100644 --- a/MaxMind.MinFraud.UnitTest/Response/InsightsTest.cs +++ b/MaxMind.MinFraud.UnitTest/Response/InsightsTest.cs @@ -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, @@ -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); diff --git a/MaxMind.MinFraud.UnitTest/Response/PhoneTest.cs b/MaxMind.MinFraud.UnitTest/Response/PhoneTest.cs new file mode 100644 index 00000000..8125e67d --- /dev/null +++ b/MaxMind.MinFraud.UnitTest/Response/PhoneTest.cs @@ -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( + @$" + {{ + ""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); + } + } +} diff --git a/MaxMind.MinFraud.UnitTest/TestData/factors-response.json b/MaxMind.MinFraud.UnitTest/TestData/factors-response.json index 9b72986d..42cd59b7 100644 --- a/MaxMind.MinFraud.UnitTest/TestData/factors-response.json +++ b/MaxMind.MinFraud.UnitTest/TestData/factors-response.json @@ -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", @@ -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, diff --git a/MaxMind.MinFraud.UnitTest/TestData/insights-response.json b/MaxMind.MinFraud.UnitTest/TestData/insights-response.json index 3b078af3..9373980c 100644 --- a/MaxMind.MinFraud.UnitTest/TestData/insights-response.json +++ b/MaxMind.MinFraud.UnitTest/TestData/insights-response.json @@ -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", @@ -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", diff --git a/MaxMind.MinFraud/Response/Insights.cs b/MaxMind.MinFraud/Response/Insights.cs index 46f99ab2..59d822d1 100644 --- a/MaxMind.MinFraud/Response/Insights.cs +++ b/MaxMind.MinFraud/Response/Insights.cs @@ -42,6 +42,13 @@ public class Insights : Score [JsonPropertyName("shipping_address")] public ShippingAddress ShippingAddress { get; init; } = new ShippingAddress(); + /// + /// An object containing minFraud data related to the shipping phone + /// used in the transaction. + /// + [JsonPropertyName("shipping_phone")] + public Phone ShippingPhone { get; init; } = new Phone(); + /// /// An object containing minFraud data related to the billing address /// used in the transaction. @@ -49,13 +56,20 @@ public class Insights : Score [JsonPropertyName("billing_address")] public BillingAddress BillingAddress { get; init; } = new BillingAddress(); + /// + /// An object containing minFraud data related to the billing phone + /// used in the transaction. + /// + [JsonPropertyName("billing_phone")] + public Phone BillingPhone { get; init; } = new Phone(); + /// /// Returns a string that represents the current object. /// /// A string that represents the current object. 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}"; } } -} \ No newline at end of file +} diff --git a/MaxMind.MinFraud/Response/Phone.cs b/MaxMind.MinFraud/Response/Phone.cs new file mode 100644 index 00000000..f47d480b --- /dev/null +++ b/MaxMind.MinFraud/Response/Phone.cs @@ -0,0 +1,52 @@ +using System.Text.Json.Serialization; + +namespace MaxMind.MinFraud.Response +{ + /// + /// This object contains information about the billing or shipping phone. + /// + public sealed class Phone + { + /// + /// A two-character ISO 3166-1 country code for the country associated + /// with the phone number. + /// + [JsonPropertyName("country")] + public string? Country { get; init; } + + /// + /// This is true if the phone number is a Voice over Internet + /// Protocol (VoIP) number allocated by a regulator. It is false + /// 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. + /// + [JsonPropertyName("is_voip")] + public bool? IsVoip { get; init; } + + /// + /// 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. + /// + [JsonPropertyName("network_operator")] + public string? NetworkOperator { get; init; } + + /// + /// One of the following values: fixed or mobile. + /// Additional values may be added in the future. + /// + [JsonPropertyName("number_type")] + public string? NumberType { get; init; } + + /// + /// Returns a string that represents the current object. + /// + public override string ToString() + { + return $"Country: {Country}, IsVoip: {IsVoip}, " + + $"NetworkOperator: {NetworkOperator}, NumberType: {NumberType}"; + } + } +} diff --git a/releasenotes.md b/releasenotes.md index 1e2d1310..5f183f5f 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -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) ------------------