Skip to content

Commit 6af7814

Browse files
authored
Merge pull request #71 from maxmind/horgh/ip-optional
Update for IP being optional
2 parents 2cbf58b + a4f168d commit 6af7814

7 files changed

Lines changed: 40 additions & 21 deletions

File tree

HISTORY.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
History
44
-------
55

6+
2.2.0
7+
++++++++++++++++++
8+
9+
* The device IP address is no longer a required input.
10+
611
2.1.0 (2020-09-25)
712
++++++++++++++++++
813

@@ -73,7 +78,7 @@ History
7378
+++++++++++++++++++
7479

7580
* Added support for the Report Transactions API. We encourage use of this API
76-
as we use data recieved through this channel to continually improve the
81+
as we use data received through this channel to continually improve the
7782
accuracy of our fraud detection algorithms.
7883

7984
1.11.0 (2020-04-06)

README.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Documentation
3030
-------------
3131

3232
Complete API documentation is available on `Read the Docs
33-
<http://minfraud.readthedocs.io/>`_.
33+
<https://minfraud.readthedocs.io/>`_.
3434

3535
Usage
3636
-----
@@ -72,8 +72,7 @@ Each of these methods takes a dictionary representing the transaction to be sent
7272
to the web service. The structure of this dictionary should be in `the format
7373
specified in the REST API documentation
7474
<https://dev.maxmind.com/minfraud/#Request_Body>`__.
75-
The ``ip_address`` in the ``device`` sub-dictionary is required. All other
76-
fields are optional.
75+
All fields are optional.
7776

7877
Report Transactions Usage
7978
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -114,9 +113,9 @@ The possible errors are:
114113
is unable to authenticate the request, e.g., if the license key or account
115114
ID is invalid.
116115
* ``minfraud.InvalidRequestError`` - This will be raised when the server
117-
rejects the request as invalid for another reason, such as a missing or
118-
reserved IP address. It is also raised if validation of the request before
119-
it is sent to the server fails.
116+
rejects the request as invalid for another reason, such as a reserved IP
117+
address. It is also raised if validation of the request before it is sent to
118+
the server fails.
120119
* ``minfraud.HttpError`` - This will be raised when an unexpected HTTP
121120
error occurs such as a firewall interfering with the request to the server.
122121
* ``minfraud.MinFraudError`` - This will be raised when some other error
@@ -303,7 +302,7 @@ Python 3.6 or greater is required. Older versions are not supported.
303302
Versioning
304303
----------
305304

306-
The minFraud Python API uses `Semantic Versioning <http://semver.org/>`_.
305+
The minFraud Python API uses `Semantic Versioning <https://semver.org/>`_.
307306

308307
Support
309308
-------
@@ -312,7 +311,7 @@ Please report all issues with this code using the `GitHub issue tracker
312311
<https://github.com/maxmind/minfraud-api-python/issues>`_.
313312

314313
If you are having an issue with a MaxMind service that is not specific to the
315-
client API, please contact `MaxMind support <http://www.maxmind.com/en/support>`_
314+
client API, please contact `MaxMind support <https://www.maxmind.com/en/support>`_
316315
for assistance.
317316

318317
Copyright and License

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@
244244

245245
# Example configuration for intersphinx: refer to the Python standard library.
246246
intersphinx_mapping = {
247-
"python": ("http://python.readthedocs.org/en/latest/", None),
248-
"geoip2": ("http://geoip2.readthedocs.org/en/latest/", None),
247+
"python": ("https://python.readthedocs.org/en/latest/", None),
248+
"geoip2": ("https://geoip2.readthedocs.org/en/latest/", None),
249249
}
250250

251251
autoclass_content = "both"

minfraud/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class GeoIP2Location(geoip2.records.Location):
6969
7070
The date and time of the transaction in the time
7171
zone associated with the IP address. The value is formatted according to
72-
`RFC 3339 <http://tools.ietf.org/html/rfc3339>`_. For instance, the
72+
`RFC 3339 <https://tools.ietf.org/html/rfc3339>`_. For instance, the
7373
local time in Boston might be returned as 2015-04-27T19:17:24-04:00.
7474
7575
:type: str | None
@@ -463,7 +463,7 @@ class CreditCard:
463463
.. attribute:: country
464464
465465
This property contains the `ISO 3166-1 alpha-2 country code
466-
<http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>`_ associated with the
466+
<https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>`_ associated with the
467467
location of the majority of customers using this credit card as
468468
determined by their billing address. In cases where the location of
469469
customers is highly mixed, this defaults to the country of the bank

minfraud/validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _email_or_md5(s: str) -> str:
6262

6363

6464
# based off of:
65-
# http://stackoverflow.com/questions/2532053/validate-a-hostname-string
65+
# https://stackoverflow.com/questions/2532053/validate-a-hostname-string
6666
def _hostname(hostname: str) -> str:
6767
if len(hostname) > 255:
6868
raise ValueError
@@ -294,9 +294,9 @@ def _uri(s: str) -> str:
294294
"token": _credit_card_token,
295295
},
296296
"custom_inputs": {_custom_input_key: _custom_input_value},
297-
Required("device"): {
297+
"device": {
298298
"accept_language": str,
299-
Required("ip_address"): _ip_address,
299+
"ip_address": _ip_address,
300300
"session_age": All(_any_number, Range(min=0)),
301301
"session_id": str,
302302
"user_agent": str,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
long_description=_readme,
3939
author="Gregory Oschwald",
4040
author_email="goschwald@maxmind.com",
41-
url="http://www.maxmind.com/",
41+
url="https://www.maxmind.com/",
4242
packages=["minfraud"],
4343
package_data={"minfraud": ["py.typed"]},
4444
include_package_data=True,

tests/test_validation.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ def check_report_str_type(self, key):
6666
self.check_invalid_report({key: 12})
6767

6868

69+
class TestTransaction(unittest.TestCase, ValidationBase):
70+
def test_transaction_without_device(self):
71+
transaction = {
72+
"account": {
73+
"user_id": "usr",
74+
}
75+
}
76+
validate_transaction(transaction)
77+
78+
6979
class TestAccount(unittest.TestCase, ValidationBase):
7080
def test_account_user_id(self):
7181
self.check_transaction({"account": {"user_id": "usr"}})
@@ -209,12 +219,17 @@ def test_ip_address(self):
209219
self.check_invalid_transaction({"device": {"ip_address": invalid}})
210220

211221
def test_missing_ip(self):
212-
with self.assertRaises(MultipleInvalid):
213-
validate_transaction({"device": {}})
222+
validate_transaction({"device": {}})
223+
validate_transaction(
224+
{
225+
"device": {
226+
"user_agent": "foo",
227+
}
228+
}
229+
)
214230

215231
def test_missing_device(self):
216-
with self.assertRaises(MultipleInvalid):
217-
validate_transaction({})
232+
validate_transaction({})
218233

219234
def test_user_agent(self):
220235
self.check_transaction_str_type("device", "user_agent")

0 commit comments

Comments
 (0)