Skip to content

Commit 7dc67b2

Browse files
authored
Merge pull request #100 from maxmind/greg/phone-outputs
Add new phone outputs
2 parents 05b0d86 + 10a1b42 commit 7dc67b2

File tree

5 files changed

+92
-1
lines changed

5 files changed

+92
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
`minfraud_id`, `transaction_id`.
99
* Updated the validation for the Report Transactions API to check that
1010
`ip_address`, `maxmind_id`, and `minfraud_id` contain valid values.
11+
* Added `billing_phone` and `shipping_phone` attributes to the minFraud
12+
Insights and Factors response models. These contain objects with
13+
information about the respective phone numbers. Please see [our developer
14+
site](https://dev.maxmind.com/minfraud/api-documentation/responses/) for
15+
more information.
1116

1217
## v2.5.0 (2024-04-16)
1318

lib/minfraud/model/insights.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require 'minfraud/model/device'
66
require 'minfraud/model/email'
77
require 'minfraud/model/ip_address'
8+
require 'minfraud/model/phone'
89
require 'minfraud/model/score'
910
require 'minfraud/model/shipping_address'
1011

@@ -18,6 +19,12 @@ class Insights < Score
1819
# @return [Minfraud::Model::BillingAddress]
1920
attr_reader :billing_address
2021

22+
# An object containing minFraud data related to the billing phone
23+
# number used in the transaction.
24+
#
25+
# @return [Minfraud::Model::Phone]
26+
attr_reader :billing_phone
27+
2128
# An object containing minFraud data about the credit card used in the
2229
# transaction.
2330
#
@@ -48,20 +55,28 @@ class Insights < Score
4855
# @return [Minfraud::Model::ShippingAddress]
4956
attr_reader :shipping_address
5057

58+
# An object containing minFraud data related to the shipping phone
59+
# number used in the transaction.
60+
#
61+
# @return [Minfraud::Model::Phone]
62+
attr_reader :shipping_phone
63+
5164
# @!visibility private
5265
def initialize(record, locales)
5366
super
5467

5568
@billing_address = Minfraud::Model::BillingAddress.new(
5669
get('billing_address')
5770
)
71+
@billing_phone = Minfraud::Model::Phone.new(get('billing_phone'))
5872
@credit_card = Minfraud::Model::CreditCard.new(get('credit_card'))
5973
@device = Minfraud::Model::Device.new(get('device'))
6074
@email = Minfraud::Model::Email.new(get('email'))
6175
@ip_address = Minfraud::Model::IPAddress.new(get('ip_address'), locales)
6276
@shipping_address = Minfraud::Model::ShippingAddress.new(
6377
get('shipping_address')
6478
)
79+
@shipping_phone = Minfraud::Model::Phone.new(get('shipping_phone'))
6580
end
6681
end
6782
end

lib/minfraud/model/phone.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# frozen_string_literal: true
2+
3+
require 'minfraud/model/abstract'
4+
5+
module Minfraud
6+
module Model
7+
# Model with information about the billing or shipping phone number.
8+
class Phone < Abstract
9+
# The two-character ISO 3166-1 country code for the country associated
10+
# with the phone number.
11+
#
12+
# @return [String, nil]
13+
attr_reader :country
14+
15+
# This is true if the phone number is a Voice over Internet Protocol
16+
# (VoIP) number allocated by a regulator. It is false if the phone
17+
# number is not a VoIP number allocated by a regulator. The attribute
18+
# is nil when a valid phone number has not been provided or we do not
19+
# have data for the phone number.
20+
#
21+
# @return [Boolean, nil]
22+
attr_reader :is_voip
23+
24+
# The name of the original network operator associated with the phone
25+
# number. This attribute does not reflect phone numbers that have been
26+
# ported from the original operator to another, nor does it identify
27+
# mobile virtual network operators.
28+
#
29+
# @return [String, nil]
30+
attr_reader :network_operator
31+
32+
# One of the following values: fixed or mobile. Additional values may
33+
# be added in the future.
34+
#
35+
# @return [String, nil]
36+
attr_reader :number_type
37+
38+
# @!visibility private
39+
def initialize(record)
40+
super
41+
42+
@country = get('country')
43+
@is_voip = get('is_voip')
44+
@network_operator = get('network_operator')
45+
@number_type = get('number_type')
46+
end
47+
end
48+
end
49+
end

spec/fixtures/files/insights-response1.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@
150150
"distance_to_ip_location": 5465,
151151
"is_in_ip_country": false
152152
},
153+
"billing_phone": {
154+
"country": "US",
155+
"is_voip": false,
156+
"network_operator": "Verizon/1",
157+
"number_type": "fixed"
158+
},
153159
"credit_card": {
154160
"issuer": {
155161
"name": "Bank of No Hope",
@@ -189,6 +195,12 @@
189195
"latitude": 35.704729,
190196
"longitude": -97.568619
191197
},
198+
"shipping_phone": {
199+
"country": "CA",
200+
"is_voip": true,
201+
"network_operator": "Telus Mobility-SVR/2",
202+
"number_type": "mobile"
203+
},
192204
"warnings": [
193205
{
194206
"code": "INPUT_INVALID",
@@ -201,4 +213,4 @@
201213
"warning": "Encountered value at /account/username_md5 that does meet the required constraints"
202214
}
203215
]
204-
}
216+
}

spec/model/insights_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
expect(m.billing_address.distance_to_ip_location).to eq 5_465
9595
expect(m.billing_address.is_in_ip_country).to eq false
9696

97+
expect(m.billing_phone.country).to eq 'US'
98+
expect(m.billing_phone.is_voip).to eq false
99+
expect(m.billing_phone.network_operator).to eq 'Verizon/1'
100+
expect(m.billing_phone.number_type).to eq 'fixed'
101+
97102
expect(m.credit_card.issuer.name).to eq 'Bank of No Hope'
98103
expect(m.credit_card.issuer.matches_provided_name).to eq true
99104
expect(m.credit_card.issuer.phone_number).to eq '8003421232'
@@ -126,6 +131,11 @@
126131
expect(m.shipping_address.latitude).to eq 35.704729
127132
expect(m.shipping_address.longitude).to eq(-97.568619)
128133

134+
expect(m.shipping_phone.country).to eq 'CA'
135+
expect(m.shipping_phone.is_voip).to eq true
136+
expect(m.shipping_phone.network_operator).to eq 'Telus Mobility-SVR/2'
137+
expect(m.shipping_phone.number_type).to eq 'mobile'
138+
129139
expect(m.warnings[0].code).to eq 'INPUT_INVALID'
130140
expect(m.warnings[0].warning).to eq 'Encountered value at /account/user_id that does meet the required constraints'
131141
expect(m.warnings[0].input_pointer).to eq '/account/user_id'

0 commit comments

Comments
 (0)