Skip to content

Commit 23203cb

Browse files
authored
Merge pull request #1362 from maxmind/greg/phone-ouputs
Add new phone outputs
2 parents df26ea7 + a5d8501 commit 23203cb

File tree

6 files changed

+100
-2
lines changed

6 files changed

+100
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ CHANGELOG
77
* **Breaking** Updated `TransactionReport` to make the `ipAddress` parameter
88
optional. Now the `tag` and at least one of the following paramters must be
99
supplied: `ipAddress`, `maxmindId`, `minfraudId`, `transactionId`.
10+
* Added `billingPhone` and `shippingPhone` properties to the minFraud Insights
11+
and Factors response models. These contain objects with information about
12+
the respective phone numbers. Please see [our developer
13+
site](https://dev.maxmind.com/minfraud/api-documentation/responses/) for
14+
more information.
1015

1116
6.1.0 (2024-04-16)
1217
------------------

fixtures/insights.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@
195195
"is_in_ip_country": true
196196
},
197197

198+
"shipping_phone": {
199+
"country": "CA",
200+
"is_voip": true,
201+
"network_operator": "Telus Mobility-SVR/2",
202+
"number_type": "mobile"
203+
},
204+
198205
"billing_address": {
199206
"is_postal_in_city": true,
200207
"latitude": 37.545,
@@ -203,6 +210,13 @@
203210
"is_in_ip_country": true
204211
},
205212

213+
"billing_phone": {
214+
"country": "US",
215+
"is_voip": false,
216+
"network_operator": "Verizon/1",
217+
"number_type": "fixed"
218+
},
219+
206220
"disposition": {
207221
"action": "accept",
208222
"reason": "default",

src/response/models/insights.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ export default class Insights extends Score {
1010
* the transaction.
1111
*/
1212
public readonly billingAddress?: records.BillingAddress;
13+
/**
14+
* An object containing minFraud data related to the billing phone used in
15+
* the transaction.
16+
*/
17+
public readonly billingPhone?: records.Phone;
1318
/**
1419
* An object containing minFraud data about the credit card used in the
1520
* transaction.
@@ -33,6 +38,11 @@ export default class Insights extends Score {
3338
* An object containing minFraud data related to the shipping address used in the transaction.
3439
*/
3540
public readonly shippingAddress?: records.ShippingAddress;
41+
/**
42+
* An object containing minFraud data related to the shipping phone used in
43+
* the transaction.
44+
*/
45+
public readonly shippingPhone?: records.Phone;
3646

3747
public constructor(response: webRecords.InsightsResponse) {
3848
super(response);
@@ -41,6 +51,7 @@ export default class Insights extends Score {
4151
response,
4252
'billing_address'
4353
);
54+
this.billingPhone = this.maybeGet<records.Phone>(response, 'billing_phone');
4455
this.creditCard = this.maybeGet<records.CreditCardRecord>(
4556
response,
4657
'credit_card'
@@ -52,6 +63,10 @@ export default class Insights extends Score {
5263
response,
5364
'shipping_address'
5465
);
66+
this.shippingPhone = this.maybeGet<records.Phone>(
67+
response,
68+
'shipping_phone'
69+
);
5570
}
5671

5772
private maybeGet<T>(

src/response/records.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,37 @@ export interface Email {
234234
readonly isHighRisk?: boolean;
235235
}
236236

237+
/**
238+
* This object contains information about the billing or shipping phone passed
239+
* in the request.
240+
*/
241+
export interface Phone {
242+
/**
243+
* A two-character ISO 3166-1 country code for the country associated with
244+
* the phone number.
245+
*/
246+
readonly country: string;
247+
/**
248+
* This is `true` if the phone number is a Voice over Internet Protocol (VoIP)
249+
* number allocated by a regulator. It is `false` if the phone number is not a
250+
* VoIP number allocated by a regulator. The property is `null` if a valid
251+
* number has not been provided or we do not have data for it.
252+
*/
253+
readonly isVoip?: boolean;
254+
/**
255+
* The name of the original network operator associated with the phone
256+
* number. This property does not reflect phone numbers that have been ported
257+
* from the original operator to another, nor does it identify mobile
258+
* virtual network operators.
259+
*/
260+
readonly networkOperator: string;
261+
/**
262+
* One of the following values: `fixed` or `mobile`. Additional values may
263+
* be added in the future.
264+
*/
265+
readonly numberType: string;
266+
}
267+
237268
/**
238269
* Information about the shipping address.
239270
*/

src/response/web-records.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ export interface DispositionWebRecord {
114114
readonly rule_label?: string;
115115
}
116116

117+
export interface PhoneWebRecord {
118+
readonly country?: string;
119+
readonly is_voip?: boolean;
120+
readonly network_operator?: string;
121+
readonly number_type?: string;
122+
}
123+
117124
export interface SubscoresWebRecord {
118125
readonly avs_result?: number;
119126
readonly billing_address?: number;
@@ -159,7 +166,9 @@ export interface InsightsResponse extends ScoreResponse {
159166
readonly device: DeviceWebRecord;
160167
readonly email?: EmailWebRecord;
161168
readonly shipping_address?: ShippingAddressWebRecord;
169+
readonly shipping_phone?: PhoneWebRecord;
162170
readonly billing_address?: BillingAddressWebRecord;
171+
readonly billing_phone?: PhoneWebRecord;
163172
}
164173

165174
export interface FactorsResponse extends InsightsResponse {

src/webServiceClient.spec.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('WebServiceClient', () => {
3636
});
3737

3838
it('handles "full" responses', async () => {
39-
expect.assertions(159);
39+
expect.assertions(167);
4040

4141
nockInstance
4242
.post(fullPath('factors'), factors.request.basic)
@@ -223,12 +223,24 @@ describe('WebServiceClient', () => {
223223
expect(got.shippingAddress?.distanceToBillingAddress).toEqual(22);
224224
expect(got.shippingAddress?.isInIpCountry).toEqual(true);
225225

226+
expect(got.shippingPhone?.country).toEqual('CA');
227+
expect(got.shippingPhone?.isVoip).toEqual(true);
228+
expect(got.shippingPhone?.networkOperator).toEqual(
229+
'Telus Mobility-SVR/2'
230+
);
231+
expect(got.shippingPhone?.numberType).toEqual('mobile');
232+
226233
expect(got.billingAddress?.isPostalInCity).toEqual(true);
227234
expect(got.billingAddress?.latitude).toEqual(37.545);
228235
expect(got.billingAddress?.longitude).toEqual(-122.421);
229236
expect(got.billingAddress?.distanceToIpLocation).toEqual(100);
230237
expect(got.billingAddress?.isInIpCountry).toEqual(true);
231238

239+
expect(got.billingPhone?.country).toEqual('US');
240+
expect(got.billingPhone?.isVoip).toEqual(false);
241+
expect(got.billingPhone?.networkOperator).toEqual('Verizon/1');
242+
expect(got.billingPhone?.numberType).toEqual('fixed');
243+
232244
expect(got.disposition?.action).toEqual('accept');
233245
expect(got.disposition?.reason).toEqual('default');
234246
expect(got.disposition?.ruleLabel).toEqual('the label');
@@ -270,7 +282,7 @@ describe('WebServiceClient', () => {
270282
});
271283

272284
it('handles "full" responses', async () => {
273-
expect.assertions(139);
285+
expect.assertions(147);
274286

275287
nockInstance
276288
.post(fullPath('insights'), insights.request.basic)
@@ -457,12 +469,24 @@ describe('WebServiceClient', () => {
457469
expect(got.shippingAddress?.distanceToBillingAddress).toEqual(22);
458470
expect(got.shippingAddress?.isInIpCountry).toEqual(true);
459471

472+
expect(got.shippingPhone?.country).toEqual('CA');
473+
expect(got.shippingPhone?.isVoip).toEqual(true);
474+
expect(got.shippingPhone?.networkOperator).toEqual(
475+
'Telus Mobility-SVR/2'
476+
);
477+
expect(got.shippingPhone?.numberType).toEqual('mobile');
478+
460479
expect(got.billingAddress?.isPostalInCity).toEqual(true);
461480
expect(got.billingAddress?.latitude).toEqual(37.545);
462481
expect(got.billingAddress?.longitude).toEqual(-122.421);
463482
expect(got.billingAddress?.distanceToIpLocation).toEqual(100);
464483
expect(got.billingAddress?.isInIpCountry).toEqual(true);
465484

485+
expect(got.billingPhone?.country).toEqual('US');
486+
expect(got.billingPhone?.isVoip).toEqual(false);
487+
expect(got.billingPhone?.networkOperator).toEqual('Verizon/1');
488+
expect(got.billingPhone?.numberType).toEqual('fixed');
489+
466490
expect(got.disposition?.action).toEqual('accept');
467491
expect(got.disposition?.reason).toEqual('default');
468492
expect(got.disposition?.ruleLabel).toEqual('the label');

0 commit comments

Comments
 (0)