5
5
This module contains models for the minFraud response object.
6
6
7
7
"""
8
+ #pylint:disable=too-many-lines
8
9
from collections import namedtuple
9
10
from functools import update_wrapper
10
11
@@ -25,8 +26,9 @@ def _inflate_to_namedtuple(orig_cls):
25
26
ntup = namedtuple (name , keys )
26
27
ntup .__name__ = name + 'NamedTuple'
27
28
ntup .__new__ .__defaults__ = (None , ) * len (keys )
28
- new_cls = type (name , (ntup , orig_cls ), {'__slots__' : (),
29
- '__doc__' : orig_cls .__doc__ })
29
+ new_cls = type (name , (ntup , orig_cls ),
30
+ {'__slots__' : (),
31
+ '__doc__' : orig_cls .__doc__ })
30
32
update_wrapper (_inflate_to_namedtuple , new_cls )
31
33
orig_new = new_cls .__new__
32
34
@@ -81,8 +83,8 @@ class GeoIP2Location(geoip2.records.Location):
81
83
"""
82
84
83
85
__doc__ += geoip2 .records .Location .__doc__
84
- _valid_attributes = geoip2 .records .Location ._valid_attributes .union (set (
85
- ['local_time' ]))
86
+ _valid_attributes = geoip2 .records .Location ._valid_attributes .union (
87
+ set ( ['local_time' ]))
86
88
87
89
88
90
class GeoIP2Country (geoip2 .records .Country ):
@@ -103,8 +105,8 @@ class GeoIP2Country(geoip2.records.Country):
103
105
"""
104
106
105
107
__doc__ += geoip2 .records .Country .__doc__
106
- _valid_attributes = geoip2 .records .Country ._valid_attributes .union (set (
107
- ['is_high_risk' ]))
108
+ _valid_attributes = geoip2 .records .Country ._valid_attributes .union (
109
+ set ( ['is_high_risk' ]))
108
110
109
111
110
112
class IPAddress (geoip2 .models .Insights ):
@@ -274,7 +276,7 @@ class Device(object):
274
276
This number represents our confidence that the ``device_id`` refers to
275
277
a unique device as opposed to a cluster of similar devices. A confidence
276
278
of 0.01 indicates very low confidence that the device is unique, whereas
277
- 99 indicates very high confidence.
279
+ 99 indicates very high confidence.
278
280
279
281
:type: float | None
280
282
@@ -297,7 +299,42 @@ class Device(object):
297
299
"""
298
300
299
301
__slots__ = ()
300
- _fields = {'confidence' : None , 'id' : None , 'last_seen' : None , }
302
+ _fields = {
303
+ 'confidence' : None ,
304
+ 'id' : None ,
305
+ 'last_seen' : None ,
306
+ }
307
+
308
+
309
+ @_inflate_to_namedtuple
310
+ class Disposition (object ):
311
+ """Information about disposition for the request as set by custom rules.
312
+
313
+ In order to receive a disposition, you must be use the minFraud custom
314
+ rules.
315
+
316
+ .. attribute:: action
317
+
318
+ The action to take on the transaction as defined by your custom rules.
319
+ The current set of values are "accept", "manual_review", and "reject".
320
+ If you do not have custom rules set up, ``None`` will be returned.
321
+
322
+ :type: str | None
323
+
324
+ .. attribute:: reason
325
+
326
+ The reason for the action. The current possible values are
327
+ "custom_rule", "block_list", and "default". If you do not have custom
328
+ rules set up, ``None`` will be returned.
329
+
330
+ :type: str | None
331
+ """
332
+
333
+ __slots__ = ()
334
+ _fields = {
335
+ 'action' : None ,
336
+ 'reason' : None ,
337
+ }
301
338
302
339
303
340
@_inflate_to_namedtuple
@@ -322,7 +359,10 @@ class Email(object):
322
359
"""
323
360
324
361
__slots__ = ()
325
- _fields = {'is_free' : None , 'is_high_risk' : None , }
362
+ _fields = {
363
+ 'is_free' : None ,
364
+ 'is_high_risk' : None ,
365
+ }
326
366
327
367
328
368
@_inflate_to_namedtuple
@@ -467,7 +507,8 @@ class ShippingAddress(object):
467
507
This property is ``True`` if the postal code
468
508
provided with the address is in the city for the address. The property is
469
509
``False`` when the postal code is not in the city. If the address was
470
- not provided, could not be parsed, or was not in USA, the property will be ``None``.
510
+ not provided, could not be parsed, or was not in USA, the property will
511
+ be ``None``.
471
512
472
513
:type: bool | None
473
514
@@ -546,7 +587,11 @@ class ServiceWarning(object):
546
587
"""
547
588
548
589
__slots__ = ()
549
- _fields = {'code' : None , 'warning' : None , 'input_pointer' : None , }
590
+ _fields = {
591
+ 'code' : None ,
592
+ 'warning' : None ,
593
+ 'input_pointer' : None ,
594
+ }
550
595
551
596
552
597
@_inflate_to_namedtuple
@@ -762,6 +807,13 @@ class Factors(object):
762
807
763
808
:type: Device
764
809
810
+ .. attribute:: disposition
811
+
812
+ A :class:`.Disposition` object containing the disposition for the
813
+ request as set by custom rules.
814
+
815
+ :type: Disposition
816
+
765
817
.. attribute:: email
766
818
767
819
A :class:`.Email` object containing information about the email address
@@ -798,6 +850,7 @@ class Factors(object):
798
850
_fields = {
799
851
'billing_address' : BillingAddress ,
800
852
'credit_card' : CreditCard ,
853
+ 'disposition' : Disposition ,
801
854
'funds_remaining' : None ,
802
855
'device' : Device ,
803
856
'email' : Email ,
@@ -870,6 +923,13 @@ class Insights(object):
870
923
871
924
:type: Device
872
925
926
+ .. attribute:: disposition
927
+
928
+ A :class:`.Disposition` object containing the disposition for the
929
+ request as set by custom rules.
930
+
931
+ :type: Disposition
932
+
873
933
.. attribute:: email
874
934
875
935
A :class:`.Email` object containing information about the email address
@@ -902,6 +962,7 @@ class Insights(object):
902
962
'billing_address' : BillingAddress ,
903
963
'credit_card' : CreditCard ,
904
964
'device' : Device ,
965
+ 'disposition' : Disposition ,
905
966
'email' : Email ,
906
967
'funds_remaining' : None ,
907
968
'id' : None ,
@@ -958,6 +1019,13 @@ class Score(object):
958
1019
959
1020
:type: float
960
1021
1022
+ .. attribute:: disposition
1023
+
1024
+ A :class:`.Disposition` object containing the disposition for the
1025
+ request as set by custom rules.
1026
+
1027
+ :type: Disposition
1028
+
961
1029
.. attribute:: ip_address
962
1030
963
1031
A :class:`.ScoreIPAddress` object containing IP address risk.
@@ -967,6 +1035,7 @@ class Score(object):
967
1035
968
1036
__slots__ = ()
969
1037
_fields = {
1038
+ 'disposition' : Disposition ,
970
1039
'funds_remaining' : None ,
971
1040
'id' : None ,
972
1041
'ip_address' : ScoreIPAddress ,
0 commit comments