Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
History
-------

2.2.0
++++++++++++++++++

* The device IP address is no longer a required input.

2.1.0 (2020-09-25)
++++++++++++++++++

Expand Down Expand Up @@ -73,7 +78,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)
Expand Down
15 changes: 7 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Documentation
-------------

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

Usage
-----
Expand Down Expand Up @@ -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
<https://dev.maxmind.com/minfraud/#Request_Body>`__.
The ``ip_address`` in the ``device`` sub-dictionary is required. All other
fields are optional.
All fields are optional.

Report Transactions Usage
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -303,7 +302,7 @@ Python 3.6 or greater is required. Older versions are not supported.
Versioning
----------

The minFraud Python API uses `Semantic Versioning <http://semver.org/>`_.
The minFraud Python API uses `Semantic Versioning <https://semver.org/>`_.

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

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

Copyright and License
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions minfraud/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://tools.ietf.org/html/rfc3339>`_. For instance, the
`RFC 3339 <https://tools.ietf.org/html/rfc3339>`_. For instance, the
local time in Boston might be returned as 2015-04-27T19:17:24-04:00.

:type: str | None
Expand Down Expand Up @@ -463,7 +463,7 @@ class CreditCard:
.. attribute:: country

This property contains the `ISO 3166-1 alpha-2 country code
<http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>`_ associated with the
<https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>`_ 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
Expand Down
6 changes: 3 additions & 3 deletions minfraud/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 19 additions & 4 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}})
Expand Down Expand Up @@ -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")
Expand Down