Skip to content

Commit 9b15e69

Browse files
committed
Add /device/session_age, /device/session_id and /email/first_seen
1 parent c88aee1 commit 9b15e69

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ History
55

66
* Added the following new values to the ``/payment/processor`` validation:
77
``ebs``, ``hipay``, and ``lemon_way``.
8+
* Added the following new values to the ``/device`` validation:
9+
``session_age`` and ``session_id``.
10+
* Added the following new values to the ``/email`` validation:
11+
``first_seen``.
812

913
1.3.2 (2016-12-08)
1014
++++++++++++++++++

minfraud/models.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,22 @@ class Device(object):
295295
This is the date and time of the last sighting of the device. This is an
296296
RFC 3339 date-time.
297297
298+
:type: str | None
299+
300+
.. attribute:: session_age
301+
302+
A floating point number. The number of seconds between the creation of
303+
the user's session and the time of the transaction. Note that session_age
304+
is not the duration of the current visit, but the time since the start of
305+
the first visit.
306+
307+
:type: float | None
308+
309+
.. attribute:: session_id
310+
311+
A string up to 255 characters in length. This is an ID which uniquely
312+
identifies a visitor's session on the site.
313+
298314
:type: str | None
299315
"""
300316

@@ -303,6 +319,8 @@ class Device(object):
303319
'confidence': None,
304320
'id': None,
305321
'last_seen': None,
322+
'session_age': None,
323+
'session_id': None,
306324
}
307325

308326

@@ -341,6 +359,14 @@ class Disposition(object):
341359
class Email(object):
342360
"""Information about the email address passed in the request.
343361
362+
.. attribute:: first_seen
363+
364+
A date string (e.g. 2017-04-24) to identify the date an email address
365+
was first seen by MaxMind. This is expressed using the ISO 8601 date
366+
format.
367+
368+
:type: str
369+
344370
.. attribute:: is_free
345371
346372
This field is true if MaxMind believes that this email is hosted by a
@@ -360,6 +386,7 @@ class Email(object):
360386

361387
__slots__ = ()
362388
_fields = {
389+
'first_seen': None,
363390
'is_free': None,
364391
'is_high_risk': None,
365392
}

tests/test_models.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,15 @@ def test_credit_card(self):
8383
def test_device(self):
8484
id = 'b643d445-18b2-4b9d-bad4-c9c4366e402a'
8585
last_seen = '2016-06-08T14:16:38Z'
86-
device = Device({'confidence': 99, 'id': id, 'last_seen': last_seen})
86+
session_age = 3600
87+
session_id = 'foobar'
88+
device = Device({'confidence': 99, 'id': id, 'last_seen': last_seen, 'session_age': session_age, 'session_id': session_id })
8789

8890
self.assertEqual(99, device.confidence)
8991
self.assertEqual(id, device.id)
9092
self.assertEqual(last_seen, device.last_seen)
93+
self.assertEqual(session_age, device.session_age)
94+
self.assertEqual(session_id, device.session_id)
9195

9296
def test_disposition(self):
9397
disposition = Disposition({'action': 'accept', 'reason': 'default'})
@@ -96,8 +100,10 @@ def test_disposition(self):
96100
self.assertEqual('default', disposition.reason)
97101

98102
def test_email(self):
99-
email = Email({'is_free': True, 'is_high_risk': False})
103+
first_seen = '2016-01-01';
104+
email = Email({'first_seen': first_seen, 'is_free': True, 'is_high_risk': False})
100105

106+
self.assertEqual(first_seen, email.first_seen)
101107
self.assertEqual(True, email.is_free)
102108
self.assertEqual(False, email.is_high_risk)
103109

0 commit comments

Comments
 (0)