Skip to content

Commit 972ad90

Browse files
committed
Add new matches_postal phone attribute
1 parent 34a7582 commit 972ad90

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

HISTORY.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ History
66
3.1.0
77
++++++++++++++++++
88

9+
* Added support for the ``/billing_phone/matches_postal`` and
10+
``/shipping_phone/matches_postal`` outputs. These are available as the
11+
``matches_postal`` attribute on ``minfraud.model.Phone``.
912
* Added ``cryptomus`` to the ``/payment/processor`` validation.
1013

1114
3.0.0 (2025-02-10)

minfraud/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,14 @@ class Phone(_Serializable):
509509
``False`` when the number is not VoIP. If the phone number was not
510510
provided or we do not have data for it, the property will be ``None``."""
511511

512+
matches_postal: Optional[bool]
513+
"""This is ```True``` if the phone number's prefix is commonly
514+
associated with the postal code. It is ```False``` if the prefix is not
515+
associated with the postal code. It is non-```None``` only when the phone
516+
number is in the US, the number prefix is in our database, and the
517+
postal code and country are provided in the request.
518+
"""
519+
512520
network_operator: Optional[str]
513521
"""The name of the original network operator associated with the phone
514522
number. This field does not reflect phone numbers that have been ported
@@ -524,13 +532,15 @@ def __init__(
524532
*,
525533
country: Optional[str] = None,
526534
is_voip: Optional[bool] = None,
535+
matches_postal: Optional[bool] = None,
527536
network_operator: Optional[str] = None,
528537
number_type: Optional[str] = None,
529538
**_,
530539
) -> None:
531540
"""Initialize a Phone instance."""
532541
self.country = country
533542
self.is_voip = is_voip
543+
self.matches_postal = matches_postal
534544
self.network_operator = network_operator
535545
self.number_type = number_type
536546

tests/data/factors-response.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"billing_phone": {
126126
"country": "US",
127127
"is_voip": true,
128+
"matches_postal": true,
128129
"network_operator": "Verizon/1",
129130
"number_type": "fixed"
130131
},
@@ -168,6 +169,7 @@
168169
"shipping_phone": {
169170
"country": "CA",
170171
"is_voip": true,
172+
"matches_postal": true,
171173
"network_operator": "Telus Mobility-SVR/2",
172174
"number_type": "mobile"
173175
},

tests/data/insights-response.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"billing_phone": {
126126
"country": "US",
127127
"is_voip": true,
128+
"matches_postal": true,
128129
"network_operator": "Verizon/1",
129130
"number_type": "fixed"
130131
},
@@ -168,6 +169,7 @@
168169
"shipping_phone": {
169170
"country": "CA",
170171
"is_voip": true,
172+
"matches_postal": true,
171173
"network_operator": "Telus Mobility-SVR/2",
172174
"number_type": "mobile"
173175
},

tests/test_models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ def test_phone(self) -> None:
234234
phone = Phone(
235235
country="US",
236236
is_voip=True,
237+
matches_postal=True,
237238
network_operator="Verizon/1",
238239
number_type="fixed",
239240
)
240241

241242
self.assertEqual("US", phone.country)
242243
self.assertEqual(True, phone.is_voip)
244+
self.assertEqual(True, phone.matches_postal)
243245
self.assertEqual("Verizon/1", phone.network_operator)
244246
self.assertEqual("fixed", phone.number_type)
245247

0 commit comments

Comments
 (0)