minfraud 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +46 -0
- data/.rubocop.yml +127 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +4 -2
- data/README.md +1 -1
- data/Rakefile +18 -3
- data/bin/console +4 -3
- data/lib/maxmind/geoip2/model/city.rb +3 -3
- data/lib/maxmind/geoip2/model/country.rb +5 -5
- data/lib/maxmind/geoip2/record/traits.rb +1 -1
- data/lib/minfraud.rb +29 -6
- data/lib/minfraud/assessments.rb +6 -2
- data/lib/minfraud/components/account.rb +2 -0
- data/lib/minfraud/components/addressable.rb +9 -7
- data/lib/minfraud/components/base.rb +6 -4
- data/lib/minfraud/components/billing.rb +2 -0
- data/lib/minfraud/components/credit_card.rb +4 -2
- data/lib/minfraud/components/custom_inputs.rb +2 -0
- data/lib/minfraud/components/device.rb +4 -2
- data/lib/minfraud/components/email.rb +2 -0
- data/lib/minfraud/components/event.rb +13 -11
- data/lib/minfraud/components/order.rb +3 -1
- data/lib/minfraud/components/payment.rb +14 -2
- data/lib/minfraud/components/report/transaction.rb +6 -6
- data/lib/minfraud/components/shipping.rb +2 -0
- data/lib/minfraud/components/shopping_cart.rb +4 -1
- data/lib/minfraud/components/shopping_cart_item.rb +2 -2
- data/lib/minfraud/enum.rb +6 -3
- data/lib/minfraud/error_handler.rb +15 -15
- data/lib/minfraud/errors.rb +2 -0
- data/lib/minfraud/http_service.rb +14 -4
- data/lib/minfraud/http_service/request.rb +3 -0
- data/lib/minfraud/http_service/response.rb +4 -2
- data/lib/minfraud/model/address.rb +4 -4
- data/lib/minfraud/model/credit_card.rb +7 -7
- data/lib/minfraud/model/device.rb +2 -2
- data/lib/minfraud/model/email.rb +4 -4
- data/lib/minfraud/model/error.rb +1 -1
- data/lib/minfraud/model/insights.rb +5 -5
- data/lib/minfraud/model/issuer.rb +3 -3
- data/lib/minfraud/model/score.rb +6 -6
- data/lib/minfraud/model/shipping_address.rb +1 -1
- data/lib/minfraud/model/subscores.rb +35 -16
- data/lib/minfraud/model/warning.rb +2 -2
- data/lib/minfraud/report.rb +5 -3
- data/lib/minfraud/resolver.rb +14 -12
- data/lib/minfraud/version.rb +3 -1
- data/minfraud.gemspec +4 -1
- metadata +18 -2
@@ -42,10 +42,10 @@ module Minfraud
|
|
42
42
|
super(record)
|
43
43
|
|
44
44
|
@distance_to_ip_location = get('distance_to_ip_location')
|
45
|
-
@is_in_ip_country
|
46
|
-
@is_postal_in_city
|
47
|
-
@latitude
|
48
|
-
@longitude
|
45
|
+
@is_in_ip_country = get('is_in_ip_country')
|
46
|
+
@is_postal_in_city = get('is_postal_in_city')
|
47
|
+
@latitude = get('latitude')
|
48
|
+
@longitude = get('longitude')
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -59,16 +59,16 @@ module Minfraud
|
|
59
59
|
def initialize(record)
|
60
60
|
super(record)
|
61
61
|
|
62
|
-
@brand
|
63
|
-
@country
|
64
|
-
@is_business
|
62
|
+
@brand = get('brand')
|
63
|
+
@country = get('country')
|
64
|
+
@is_business = get('is_business')
|
65
65
|
@is_issued_in_billing_address_country = get(
|
66
66
|
'is_issued_in_billing_address_country'
|
67
67
|
)
|
68
|
-
@is_prepaid
|
69
|
-
@is_virtual
|
70
|
-
@issuer
|
71
|
-
@type
|
68
|
+
@is_prepaid = get('is_prepaid')
|
69
|
+
@is_virtual = get('is_virtual')
|
70
|
+
@issuer = Minfraud::Model::Issuer.new(get('issuer'))
|
71
|
+
@type = get('type')
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
data/lib/minfraud/model/email.rb
CHANGED
@@ -43,11 +43,11 @@ module Minfraud
|
|
43
43
|
def initialize(record)
|
44
44
|
super(record)
|
45
45
|
|
46
|
-
@domain
|
47
|
-
@first_seen
|
46
|
+
@domain = Minfraud::Model::EmailDomain.new(get('domain'))
|
47
|
+
@first_seen = get('first_seen')
|
48
48
|
@is_disposable = get('is_disposable')
|
49
|
-
@is_free
|
50
|
-
@is_high_risk
|
49
|
+
@is_free = get('is_free')
|
50
|
+
@is_high_risk = get('is_high_risk')
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/lib/minfraud/model/error.rb
CHANGED
@@ -52,13 +52,13 @@ module Minfraud
|
|
52
52
|
def initialize(record, locales)
|
53
53
|
super(record, locales)
|
54
54
|
|
55
|
-
@billing_address
|
55
|
+
@billing_address = Minfraud::Model::BillingAddress.new(
|
56
56
|
get('billing_address')
|
57
57
|
)
|
58
|
-
@credit_card
|
59
|
-
@device
|
60
|
-
@email
|
61
|
-
@ip_address
|
58
|
+
@credit_card = Minfraud::Model::CreditCard.new(get('credit_card'))
|
59
|
+
@device = Minfraud::Model::Device.new(get('device'))
|
60
|
+
@email = Minfraud::Model::Email.new(get('email'))
|
61
|
+
@ip_address = Minfraud::Model::IPAddress.new(get('ip_address'), locales)
|
62
62
|
@shipping_address = Minfraud::Model::ShippingAddress.new(
|
63
63
|
get('shipping_address')
|
64
64
|
)
|
@@ -39,9 +39,9 @@ module Minfraud
|
|
39
39
|
def initialize(record)
|
40
40
|
super(record)
|
41
41
|
|
42
|
-
@name
|
43
|
-
@phone_number
|
44
|
-
@matches_provided_name
|
42
|
+
@name = get('name')
|
43
|
+
@phone_number = get('phone_number')
|
44
|
+
@matches_provided_name = get('matches_provided_name')
|
45
45
|
@matches_provided_phone_number = get('matches_provided_phone_number')
|
46
46
|
end
|
47
47
|
end
|
data/lib/minfraud/model/score.rb
CHANGED
@@ -58,13 +58,13 @@ module Minfraud
|
|
58
58
|
def initialize(record, _locales)
|
59
59
|
super(record)
|
60
60
|
|
61
|
-
@disposition
|
62
|
-
@funds_remaining
|
63
|
-
@id
|
64
|
-
@ip_address
|
61
|
+
@disposition = Minfraud::Model::Disposition.new(get('disposition'))
|
62
|
+
@funds_remaining = get('funds_remaining')
|
63
|
+
@id = get('id')
|
64
|
+
@ip_address = Minfraud::Model::ScoreIPAddress.new(get('ip_address'))
|
65
65
|
@queries_remaining = get('queries_remaining')
|
66
|
-
@risk_score
|
67
|
-
@warnings
|
66
|
+
@risk_score = get('risk_score')
|
67
|
+
@warnings = []
|
68
68
|
if record && record.key?('warnings')
|
69
69
|
record['warnings'].each do |w|
|
70
70
|
@warnings << Minfraud::Model::Warning.new(w)
|
@@ -59,6 +59,11 @@ module Minfraud
|
|
59
59
|
# @return [Float, nil]
|
60
60
|
attr_reader :cvv_result
|
61
61
|
|
62
|
+
# The risk associated with the device. If present, this is a value in the
|
63
|
+
# range of 0.01 to 99.
|
64
|
+
# @return [Float, nil]
|
65
|
+
attr_reader :device
|
66
|
+
|
62
67
|
# The risk associated with the particular email address. If present, this
|
63
68
|
# is a value in the range 0.01 to 99.
|
64
69
|
#
|
@@ -71,6 +76,12 @@ module Minfraud
|
|
71
76
|
# @return [Float, nil]
|
72
77
|
attr_reader :email_domain
|
73
78
|
|
79
|
+
# The risk associated with the email address local part (the part of
|
80
|
+
# the email address before the @ symbol). If present, this is a value
|
81
|
+
# in the range 0.01 to 99.
|
82
|
+
# @return [Float, nil]
|
83
|
+
attr_reader :email_local_part
|
84
|
+
|
74
85
|
# The risk associated with the issuer ID number on the email domain. If
|
75
86
|
# present, this is a value in the range 0.01 to 99.
|
76
87
|
#
|
@@ -111,6 +122,11 @@ module Minfraud
|
|
111
122
|
# @return [Float, nil]
|
112
123
|
attr_reader :phone_number
|
113
124
|
|
125
|
+
# The risk associated with the shipping address. If present, this is a
|
126
|
+
# value in the range 0.01 to 99.
|
127
|
+
# @return [Float, nil]
|
128
|
+
attr_reader :shipping_address
|
129
|
+
|
114
130
|
# The risk associated with the distance between the shipping address and
|
115
131
|
# the IP location for the given IP address. If present, this is a value
|
116
132
|
# in the range 0.01 to 99.
|
@@ -129,27 +145,30 @@ module Minfraud
|
|
129
145
|
def initialize(record)
|
130
146
|
super(record)
|
131
147
|
|
132
|
-
@avs_result
|
133
|
-
@billing_address
|
134
|
-
@billing_address_distance_to_ip_location
|
148
|
+
@avs_result = get('avs_result')
|
149
|
+
@billing_address = get('billing_address')
|
150
|
+
@billing_address_distance_to_ip_location = get(
|
135
151
|
'billing_address_distance_to_ip_location'
|
136
152
|
)
|
137
|
-
@browser
|
138
|
-
@chargeback
|
139
|
-
@country
|
140
|
-
@country_mismatch
|
141
|
-
@cvv_result
|
142
|
-
@
|
143
|
-
@
|
144
|
-
@
|
145
|
-
@
|
146
|
-
@
|
147
|
-
@
|
148
|
-
@
|
153
|
+
@browser = get('browser')
|
154
|
+
@chargeback = get('chargeback')
|
155
|
+
@country = get('country')
|
156
|
+
@country_mismatch = get('country_mismatch')
|
157
|
+
@cvv_result = get('cvv_result')
|
158
|
+
@device = get('device')
|
159
|
+
@email_address = get('email_address')
|
160
|
+
@email_domain = get('email_domain')
|
161
|
+
@email_local_part = get('email_local_part')
|
162
|
+
@email_tenure = get('email_tenure')
|
163
|
+
@ip_tenure = get('ip_tenure')
|
164
|
+
@issuer_id_number = get('issuer_id_number')
|
165
|
+
@order_amount = get('order_amount')
|
166
|
+
@phone_number = get('phone_number')
|
167
|
+
@shipping_address = get('shipping_address')
|
149
168
|
@shipping_address_distance_to_ip_location = get(
|
150
169
|
'shipping_address_distance_to_ip_location'
|
151
170
|
)
|
152
|
-
@time_of_day
|
171
|
+
@time_of_day = get('time_of_day')
|
153
172
|
end
|
154
173
|
end
|
155
174
|
end
|
data/lib/minfraud/report.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
class Report
|
3
5
|
include ::Minfraud::HTTPService
|
@@ -20,13 +22,13 @@ module Minfraud
|
|
20
22
|
raw = request.perform(verb: :post, endpoint: 'transactions/report', body: @transaction.to_json)
|
21
23
|
|
22
24
|
response = ::Minfraud::HTTPService::Response.new(
|
23
|
-
status:
|
24
|
-
body:
|
25
|
+
status: raw.status.to_i,
|
26
|
+
body: raw.body,
|
25
27
|
headers: raw.headers
|
26
28
|
)
|
27
29
|
::Minfraud::ErrorHandler.examine(response)
|
28
30
|
|
29
|
-
|
31
|
+
nil
|
30
32
|
end
|
31
33
|
|
32
34
|
# Creates memoized Minfraud::HTTPService::Request instance
|
data/lib/minfraud/resolver.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Resolver
|
3
5
|
class << self
|
@@ -17,17 +19,17 @@ module Minfraud
|
|
17
19
|
|
18
20
|
# Mapping between components & minFraud request keys
|
19
21
|
MAPPING = {
|
20
|
-
account:
|
21
|
-
billing:
|
22
|
-
credit_card:
|
23
|
-
custom_inputs:
|
24
|
-
device:
|
25
|
-
email:
|
26
|
-
event:
|
27
|
-
order:
|
28
|
-
payment:
|
29
|
-
shipping:
|
30
|
-
shopping_cart:
|
31
|
-
}
|
22
|
+
account: ::Minfraud::Components::Account,
|
23
|
+
billing: ::Minfraud::Components::Billing,
|
24
|
+
credit_card: ::Minfraud::Components::CreditCard,
|
25
|
+
custom_inputs: ::Minfraud::Components::CustomInputs,
|
26
|
+
device: ::Minfraud::Components::Device,
|
27
|
+
email: ::Minfraud::Components::Email,
|
28
|
+
event: ::Minfraud::Components::Event,
|
29
|
+
order: ::Minfraud::Components::Order,
|
30
|
+
payment: ::Minfraud::Components::Payment,
|
31
|
+
shipping: ::Minfraud::Components::Shipping,
|
32
|
+
shopping_cart: ::Minfraud::Components::ShoppingCart,
|
33
|
+
}.freeze
|
32
34
|
end
|
33
35
|
end
|
data/lib/minfraud/version.rb
CHANGED
data/minfraud.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', File.dirname(File.realpath(__FILE__)))
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
|
@@ -9,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
9
11
|
spec.authors = ['kushnir.yb']
|
10
12
|
spec.email = ['support@maxmind.com']
|
11
13
|
|
12
|
-
spec.summary =
|
14
|
+
spec.summary = 'Ruby interface to the MaxMind minFraud v2.0 API services'
|
13
15
|
spec.homepage = 'https://github.com/maxmind/minfraud-api-ruby'
|
14
16
|
spec.license = 'MIT'
|
15
17
|
|
@@ -26,4 +28,5 @@ Gem::Specification.new do |spec|
|
|
26
28
|
spec.add_development_dependency 'bundler', '>= 1.16'
|
27
29
|
spec.add_development_dependency 'rake'
|
28
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
spec.add_development_dependency 'rubocop'
|
29
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minfraud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kushnir.yb
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -92,6 +92,20 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '3.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rubocop
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
95
109
|
description:
|
96
110
|
email:
|
97
111
|
- support@maxmind.com
|
@@ -99,8 +113,10 @@ executables: []
|
|
99
113
|
extensions: []
|
100
114
|
extra_rdoc_files: []
|
101
115
|
files:
|
116
|
+
- ".github/workflows/test.yml"
|
102
117
|
- ".gitignore"
|
103
118
|
- ".rspec"
|
119
|
+
- ".rubocop.yml"
|
104
120
|
- ".travis.yml"
|
105
121
|
- CHANGELOG.md
|
106
122
|
- CODE_OF_CONDUCT.md
|