From 6bc6db428b97119d53b82bf6285ddd0134e96fd9 Mon Sep 17 00:00:00 2001 From: William Storey Date: Wed, 7 Oct 2020 12:55:50 -0700 Subject: [PATCH 1/3] Fix typo --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index cb68783..a923ea1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -73,7 +73,7 @@ History +++++++++++++++++++ * Added support for the Report Transactions API. We encourage use of this API - as we use data recieved through this channel to continually improve the + as we use data received through this channel to continually improve the accuracy of our fraud detection algorithms. 1.11.0 (2020-04-06) From 25b4a93ea92f51e6dc49fa69569dd4b9a34ccd1c Mon Sep 17 00:00:00 2001 From: William Storey Date: Wed, 7 Oct 2020 12:56:21 -0700 Subject: [PATCH 2/3] Use https links --- README.rst | 6 +++--- docs/conf.py | 4 ++-- minfraud/models.py | 4 ++-- minfraud/validation.py | 2 +- setup.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index c134a5a..fb5bb62 100644 --- a/README.rst +++ b/README.rst @@ -30,7 +30,7 @@ Documentation ------------- Complete API documentation is available on `Read the Docs -`_. +`_. Usage ----- @@ -303,7 +303,7 @@ Python 3.6 or greater is required. Older versions are not supported. Versioning ---------- -The minFraud Python API uses `Semantic Versioning `_. +The minFraud Python API uses `Semantic Versioning `_. Support ------- @@ -312,7 +312,7 @@ Please report all issues with this code using the `GitHub issue tracker `_. If you are having an issue with a MaxMind service that is not specific to the -client API, please contact `MaxMind support `_ +client API, please contact `MaxMind support `_ for assistance. Copyright and License diff --git a/docs/conf.py b/docs/conf.py index cef0a6d..47b735d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -244,8 +244,8 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "geoip2": ("http://geoip2.readthedocs.org/en/latest/", None), + "python": ("https://python.readthedocs.org/en/latest/", None), + "geoip2": ("https://geoip2.readthedocs.org/en/latest/", None), } autoclass_content = "both" diff --git a/minfraud/models.py b/minfraud/models.py index a23d675..fe92456 100644 --- a/minfraud/models.py +++ b/minfraud/models.py @@ -69,7 +69,7 @@ class GeoIP2Location(geoip2.records.Location): The date and time of the transaction in the time zone associated with the IP address. The value is formatted according to - `RFC 3339 `_. For instance, the + `RFC 3339 `_. For instance, the local time in Boston might be returned as 2015-04-27T19:17:24-04:00. :type: str | None @@ -463,7 +463,7 @@ class CreditCard: .. attribute:: country This property contains the `ISO 3166-1 alpha-2 country code - `_ associated with the + `_ associated with the location of the majority of customers using this credit card as determined by their billing address. In cases where the location of customers is highly mixed, this defaults to the country of the bank diff --git a/minfraud/validation.py b/minfraud/validation.py index e687bae..b160617 100644 --- a/minfraud/validation.py +++ b/minfraud/validation.py @@ -62,7 +62,7 @@ def _email_or_md5(s: str) -> str: # based off of: -# http://stackoverflow.com/questions/2532053/validate-a-hostname-string +# https://stackoverflow.com/questions/2532053/validate-a-hostname-string def _hostname(hostname: str) -> str: if len(hostname) > 255: raise ValueError diff --git a/setup.py b/setup.py index 05ec838..958b12e 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ long_description=_readme, author="Gregory Oschwald", author_email="goschwald@maxmind.com", - url="http://www.maxmind.com/", + url="https://www.maxmind.com/", packages=["minfraud"], package_data={"minfraud": ["py.typed"]}, include_package_data=True, From a4f168d8873bd41f93b2f62935b5a20626c3cc5b Mon Sep 17 00:00:00 2001 From: William Storey Date: Wed, 7 Oct 2020 13:48:31 -0700 Subject: [PATCH 3/3] Do not require the IP address input --- HISTORY.rst | 5 +++++ README.rst | 9 ++++----- minfraud/validation.py | 4 ++-- tests/test_validation.py | 23 +++++++++++++++++++---- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index a923ea1..d23c737 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,11 @@ History ------- +2.2.0 +++++++++++++++++++ + +* The device IP address is no longer a required input. + 2.1.0 (2020-09-25) ++++++++++++++++++ diff --git a/README.rst b/README.rst index fb5bb62..cad7878 100644 --- a/README.rst +++ b/README.rst @@ -72,8 +72,7 @@ Each of these methods takes a dictionary representing the transaction to be sent to the web service. The structure of this dictionary should be in `the format specified in the REST API documentation `__. -The ``ip_address`` in the ``device`` sub-dictionary is required. All other -fields are optional. +All fields are optional. Report Transactions Usage ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,9 +113,9 @@ The possible errors are: is unable to authenticate the request, e.g., if the license key or account ID is invalid. * ``minfraud.InvalidRequestError`` - This will be raised when the server - rejects the request as invalid for another reason, such as a missing or - reserved IP address. It is also raised if validation of the request before - it is sent to the server fails. + rejects the request as invalid for another reason, such as a reserved IP + address. It is also raised if validation of the request before it is sent to + the server fails. * ``minfraud.HttpError`` - This will be raised when an unexpected HTTP error occurs such as a firewall interfering with the request to the server. * ``minfraud.MinFraudError`` - This will be raised when some other error diff --git a/minfraud/validation.py b/minfraud/validation.py index b160617..51b838c 100644 --- a/minfraud/validation.py +++ b/minfraud/validation.py @@ -294,9 +294,9 @@ def _uri(s: str) -> str: "token": _credit_card_token, }, "custom_inputs": {_custom_input_key: _custom_input_value}, - Required("device"): { + "device": { "accept_language": str, - Required("ip_address"): _ip_address, + "ip_address": _ip_address, "session_age": All(_any_number, Range(min=0)), "session_id": str, "user_agent": str, diff --git a/tests/test_validation.py b/tests/test_validation.py index fcc5583..f322df3 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -66,6 +66,16 @@ def check_report_str_type(self, key): self.check_invalid_report({key: 12}) +class TestTransaction(unittest.TestCase, ValidationBase): + def test_transaction_without_device(self): + transaction = { + "account": { + "user_id": "usr", + } + } + validate_transaction(transaction) + + class TestAccount(unittest.TestCase, ValidationBase): def test_account_user_id(self): self.check_transaction({"account": {"user_id": "usr"}}) @@ -209,12 +219,17 @@ def test_ip_address(self): self.check_invalid_transaction({"device": {"ip_address": invalid}}) def test_missing_ip(self): - with self.assertRaises(MultipleInvalid): - validate_transaction({"device": {}}) + validate_transaction({"device": {}}) + validate_transaction( + { + "device": { + "user_agent": "foo", + } + } + ) def test_missing_device(self): - with self.assertRaises(MultipleInvalid): - validate_transaction({}) + validate_transaction({}) def test_user_agent(self): self.check_transaction_str_type("device", "user_agent")