Skip to content

Commit a115b27

Browse files
authored
Merge pull request #176 from maxmind/greg/eng-1670
Add support for phone matches postal outputs
2 parents f6bf7e3 + 972ad90 commit a115b27

File tree

7 files changed

+906
-861
lines changed

7 files changed

+906
-861
lines changed

HISTORY.rst

+3
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

+10
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

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [
88
dependencies = [
99
"aiohttp>=3.6.2,<4.0.0",
1010
"email_validator>=2.0.0,<3.0.0",
11-
"geoip2>=5.0.1,<6.0.0",
11+
"geoip2>=5.1.0,<6.0.0",
1212
"requests>=2.24.0,<3.0.0",
1313
"typing-extensions>=4.13.2",
1414
"voluptuous",

tests/data/factors-response.json

+2
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

+2
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

+2
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

uv.lock

+886-860
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)