minfraud 1.6.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -20
- data/CHANGELOG.md +48 -1
- data/Gemfile +0 -9
- data/README.md +2 -2
- data/lib/minfraud/assessments.rb +21 -16
- data/lib/minfraud/components/account.rb +1 -1
- data/lib/minfraud/components/billing.rb +1 -1
- data/lib/minfraud/components/credit_card.rb +1 -1
- data/lib/minfraud/components/custom_inputs.rb +1 -1
- data/lib/minfraud/components/device.rb +1 -1
- data/lib/minfraud/components/email.rb +1 -1
- data/lib/minfraud/components/event.rb +11 -11
- data/lib/minfraud/components/order.rb +1 -1
- data/lib/minfraud/components/payment.rb +152 -142
- data/lib/minfraud/components/report/transaction.rb +2 -2
- data/lib/minfraud/components/shipping.rb +2 -2
- data/lib/minfraud/components/shopping_cart.rb +1 -1
- data/lib/minfraud/components/shopping_cart_item.rb +3 -3
- data/lib/minfraud/http_service/response.rb +28 -21
- data/lib/minfraud/model/device.rb +1 -1
- data/lib/minfraud/model/disposition.rb +3 -3
- data/lib/minfraud/model/ip_address.rb +4 -47
- data/lib/minfraud/model/score.rb +1 -1
- data/lib/minfraud/model/subscores.rb +0 -22
- data/lib/minfraud/report.rb +19 -11
- data/lib/minfraud/validates.rb +2 -2
- data/lib/minfraud/version.rb +1 -1
- data/lib/minfraud.rb +18 -24
- data/minfraud.gemspec +8 -5
- metadata +21 -47
- data/lib/maxmind/geoip2/model/city.rb +0 -99
- data/lib/maxmind/geoip2/model/country.rb +0 -94
- data/lib/maxmind/geoip2/model/insights.rb +0 -38
- data/lib/maxmind/geoip2/record/abstract.rb +0 -46
- data/lib/maxmind/geoip2/record/city.rb +0 -62
- data/lib/maxmind/geoip2/record/continent.rb +0 -61
- data/lib/maxmind/geoip2/record/country.rb +0 -78
- data/lib/maxmind/geoip2/record/location.rb +0 -97
- data/lib/maxmind/geoip2/record/maxmind.rb +0 -41
- data/lib/maxmind/geoip2/record/place.rb +0 -52
- data/lib/maxmind/geoip2/record/postal.rb +0 -54
- data/lib/maxmind/geoip2/record/represented_country.rb +0 -47
- data/lib/maxmind/geoip2/record/subdivision.rb +0 -72
- data/lib/maxmind/geoip2/record/traits.rb +0 -233
- data/lib/minfraud/http_service/request.rb +0 -38
- data/lib/minfraud/http_service.rb +0 -45
@@ -1,54 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020 by MaxMind, Inc.
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
# SOFTWARE.
|
20
|
-
|
21
|
-
# frozen_string_literal: true
|
22
|
-
|
23
|
-
require 'maxmind/geoip2/record/abstract'
|
24
|
-
|
25
|
-
module MaxMind
|
26
|
-
module GeoIP2
|
27
|
-
module Record
|
28
|
-
# Contains data for the postal record associated with an IP address.
|
29
|
-
#
|
30
|
-
# This record is returned by all location services and databases besides
|
31
|
-
# Country.
|
32
|
-
class Postal < Abstract
|
33
|
-
# The postal code of the location. Postal codes are not available for all
|
34
|
-
# countries. In some countries, this will only contain part of the postal
|
35
|
-
# code. This attribute is returned by all location databases and services
|
36
|
-
# besides Country.
|
37
|
-
#
|
38
|
-
# @return [String, nil]
|
39
|
-
def code
|
40
|
-
get('code')
|
41
|
-
end
|
42
|
-
|
43
|
-
# A value from 0-100 indicating MaxMind's confidence that the postal code
|
44
|
-
# is correct. This attribute is only available from the Insights service
|
45
|
-
# and the GeoIP2 Enterprise database.
|
46
|
-
#
|
47
|
-
# @return [Integer, nil]
|
48
|
-
def confidence
|
49
|
-
get('confidence')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020 by MaxMind, Inc.
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
# SOFTWARE.
|
20
|
-
|
21
|
-
# frozen_string_literal: true
|
22
|
-
|
23
|
-
require 'maxmind/geoip2/record/country'
|
24
|
-
|
25
|
-
module MaxMind
|
26
|
-
module GeoIP2
|
27
|
-
module Record
|
28
|
-
# Contains data for the represented country associated with an IP address.
|
29
|
-
#
|
30
|
-
# This class contains the country-level data associated with an IP address
|
31
|
-
# for the IP's represented country. The represented country is the country
|
32
|
-
# represented by something like a military base.
|
33
|
-
#
|
34
|
-
# See {MaxMind::GeoIP2::Record::Country} for inherited methods.
|
35
|
-
class RepresentedCountry < Country
|
36
|
-
# A string indicating the type of entity that is representing the country.
|
37
|
-
# Currently we only return +military+ but this could expand to include
|
38
|
-
# other types in the future.
|
39
|
-
#
|
40
|
-
# @return [String, nil]
|
41
|
-
def type
|
42
|
-
get('type')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020 by MaxMind, Inc.
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
# SOFTWARE.
|
20
|
-
|
21
|
-
# frozen_string_literal: true
|
22
|
-
|
23
|
-
require 'maxmind/geoip2/record/place'
|
24
|
-
|
25
|
-
module MaxMind
|
26
|
-
module GeoIP2
|
27
|
-
module Record
|
28
|
-
# Contains data for the subdivisions associated with an IP address.
|
29
|
-
#
|
30
|
-
# This record is returned by all location databases and services besides
|
31
|
-
# Country.
|
32
|
-
#
|
33
|
-
# See {MaxMind::GeoIP2::Record::Place} for inherited methods.
|
34
|
-
class Subdivision < Place
|
35
|
-
# This is a value from 0-100 indicating MaxMind's confidence that the
|
36
|
-
# subdivision is correct. This attribute is only available from the
|
37
|
-
# Insights service and the GeoIP2 Enterprise database.
|
38
|
-
#
|
39
|
-
# @return [Integer, nil]
|
40
|
-
def confidence
|
41
|
-
get('confidence')
|
42
|
-
end
|
43
|
-
|
44
|
-
# This is a GeoName ID for the subdivision. This attribute is returned by
|
45
|
-
# all location databases and services besides Country.
|
46
|
-
#
|
47
|
-
# @return [Integer, nil]
|
48
|
-
def geoname_id
|
49
|
-
get('geoname_id')
|
50
|
-
end
|
51
|
-
|
52
|
-
# This is a string up to three characters long contain the subdivision
|
53
|
-
# portion of the ISO 3166-2 code. See
|
54
|
-
# https://en.wikipedia.org/wiki/ISO_3166-2. This attribute is returned by
|
55
|
-
# all location databases and services except Country.
|
56
|
-
#
|
57
|
-
# @return [String, nil]
|
58
|
-
def iso_code
|
59
|
-
get('iso_code')
|
60
|
-
end
|
61
|
-
|
62
|
-
# A Hash where the keys are locale codes and the values are names. This attribute is returned by all location services and
|
63
|
-
# databases besides country.
|
64
|
-
#
|
65
|
-
# @return [Hash<String, String>, nil]
|
66
|
-
def names
|
67
|
-
get('names')
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,233 +0,0 @@
|
|
1
|
-
# Copyright (c) 2020 by MaxMind, Inc.
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
# of this software and associated documentation files (the "Software"), to deal
|
5
|
-
# in the Software without restriction, including without limitation the rights
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
8
|
-
# furnished to do so, subject to the following conditions:
|
9
|
-
#
|
10
|
-
# The above copyright notice and this permission notice shall be included in
|
11
|
-
# all copies or substantial portions of the Software.
|
12
|
-
#
|
13
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
# SOFTWARE.
|
20
|
-
|
21
|
-
# frozen_string_literal: true
|
22
|
-
|
23
|
-
require 'ipaddr'
|
24
|
-
require 'maxmind/geoip2/record/abstract'
|
25
|
-
|
26
|
-
module MaxMind
|
27
|
-
module GeoIP2
|
28
|
-
module Record
|
29
|
-
# Contains data for the traits record associated with an IP address.
|
30
|
-
#
|
31
|
-
# This record is returned by all location services and databases.
|
32
|
-
class Traits < Abstract
|
33
|
-
# @!visibility private
|
34
|
-
def initialize(record)
|
35
|
-
super(record)
|
36
|
-
if record && !record.key?('network') && record.key?('ip_address') &&
|
37
|
-
record.key?('prefix_length')
|
38
|
-
ip = IPAddr.new(record['ip_address']).mask(record['prefix_length'])
|
39
|
-
# We could use ip.prefix instead of record['prefix_length'], but that
|
40
|
-
# method only becomes available in Ruby 2.5+.
|
41
|
-
record['network'] = format('%s/%d', ip.to_s, record['prefix_length'])
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# The autonomous system number associated with the IP address. See
|
46
|
-
# Wikipedia[https://en.wikipedia.org/wiki/Autonomous_system_(Internet)].
|
47
|
-
# This attribute is only available from the City and Insights web service
|
48
|
-
# and the GeoIP2 Enterprise database.
|
49
|
-
#
|
50
|
-
# @return [Integer, nil]
|
51
|
-
def autonomous_system_number
|
52
|
-
get('autonomous_system_number')
|
53
|
-
end
|
54
|
-
|
55
|
-
# The organization associated with the registered autonomous system number
|
56
|
-
# for the IP address. See
|
57
|
-
# Wikipedia[https://en.wikipedia.org/wiki/Autonomous_system_(Internet)].
|
58
|
-
# This attribute is only available from the City and Insights web service
|
59
|
-
# and the GeoIP2 Enterprise database.
|
60
|
-
#
|
61
|
-
# @return [String, nil]
|
62
|
-
def autonomous_system_organization
|
63
|
-
get('autonomous_system_organization')
|
64
|
-
end
|
65
|
-
|
66
|
-
# The connection type may take the following values: "Dialup",
|
67
|
-
# "Cable/DSL", "Corporate", "Cellular". Additional values may be added in
|
68
|
-
# the future. This attribute is only available in the GeoIP2 Enterprise
|
69
|
-
# database.
|
70
|
-
#
|
71
|
-
# @return [String, nil]
|
72
|
-
def connection_type
|
73
|
-
get('connection_type')
|
74
|
-
end
|
75
|
-
|
76
|
-
# The second level domain associated with the IP address. This will be
|
77
|
-
# something like "example.com" or "example.co.uk", not "foo.example.com".
|
78
|
-
# This attribute is only available from the City and Insights web service
|
79
|
-
# and the GeoIP2 Enterprise database.
|
80
|
-
#
|
81
|
-
# @return [String, nil]
|
82
|
-
def domain
|
83
|
-
get('domain')
|
84
|
-
end
|
85
|
-
|
86
|
-
# The IP address that the data in the model is for. If you performed a "me"
|
87
|
-
# lookup against the web service, this will be the externally routable IP
|
88
|
-
# address for the system the code is running on. If the system is behind a
|
89
|
-
# NAT, this may differ from the IP address locally assigned to it. This
|
90
|
-
# attribute is returned by all end points.
|
91
|
-
#
|
92
|
-
# @return [String, nil]
|
93
|
-
def ip_address
|
94
|
-
get('ip_address')
|
95
|
-
end
|
96
|
-
|
97
|
-
# This is true if the IP address belongs to any sort of anonymous network.
|
98
|
-
# This property is only available from GeoIP2 Precision Insights.
|
99
|
-
#
|
100
|
-
# @return [Boolean]
|
101
|
-
def anonymous?
|
102
|
-
get('is_anonymous')
|
103
|
-
end
|
104
|
-
|
105
|
-
# This is true if the IP address is registered to an anonymous VPN
|
106
|
-
# provider. If a VPN provider does not register subnets under names
|
107
|
-
# associated with them, we will likely only flag their IP ranges using the
|
108
|
-
# hosting_provider? property. This property is only available from GeoIP2
|
109
|
-
# Precision Insights.
|
110
|
-
#
|
111
|
-
# @return [Boolean]
|
112
|
-
def anonymous_vpn?
|
113
|
-
get('is_anonymous_vpn')
|
114
|
-
end
|
115
|
-
|
116
|
-
# This is true if the IP address belongs to a hosting or VPN provider (see
|
117
|
-
# description of the anonymous_vpn? property). This property is only
|
118
|
-
# available from GeoIP2 Precision Insights.
|
119
|
-
#
|
120
|
-
# @return [Boolean]
|
121
|
-
def hosting_provider?
|
122
|
-
get('is_hosting_provider')
|
123
|
-
end
|
124
|
-
|
125
|
-
# This attribute is true if MaxMind believes this IP address to be a
|
126
|
-
# legitimate proxy, such as an internal VPN used by a corporation. This
|
127
|
-
# attribute is only available in the GeoIP2 Enterprise database.
|
128
|
-
#
|
129
|
-
# @return [Boolean]
|
130
|
-
def legitimate_proxy?
|
131
|
-
get('is_legitimate_proxy')
|
132
|
-
end
|
133
|
-
|
134
|
-
# This is true if the IP address belongs to a public proxy. This property
|
135
|
-
# is only available from GeoIP2 Precision Insights.
|
136
|
-
#
|
137
|
-
# @return [Boolean]
|
138
|
-
def public_proxy?
|
139
|
-
get('is_public_proxy')
|
140
|
-
end
|
141
|
-
|
142
|
-
# This is true if the IP address is on a suspected anonymizing network
|
143
|
-
# and belongs to a residential ISP. This property is only available
|
144
|
-
# from GeoIP2 Precision Insights.
|
145
|
-
#
|
146
|
-
# @return [Boolean]
|
147
|
-
def residential_proxy?
|
148
|
-
get('is_residential_proxy')
|
149
|
-
end
|
150
|
-
|
151
|
-
# This is true if the IP address is a Tor exit node. This property is only
|
152
|
-
# available from GeoIP2 Precision Insights.
|
153
|
-
#
|
154
|
-
# @return [Boolean]
|
155
|
-
def tor_exit_node?
|
156
|
-
get('is_tor_exit_node')
|
157
|
-
end
|
158
|
-
|
159
|
-
# The name of the ISP associated with the IP address. This attribute is
|
160
|
-
# only available from the City and Insights web services and the GeoIP2
|
161
|
-
# Enterprise database.
|
162
|
-
#
|
163
|
-
# @return [String, nil]
|
164
|
-
def isp
|
165
|
-
get('isp')
|
166
|
-
end
|
167
|
-
|
168
|
-
# The network in CIDR notation associated with the record. In particular,
|
169
|
-
# this is the largest network where all of the fields besides ip_address
|
170
|
-
# have the same value.
|
171
|
-
#
|
172
|
-
# @return [String, nil]
|
173
|
-
def network
|
174
|
-
get('network')
|
175
|
-
end
|
176
|
-
|
177
|
-
# The name of the organization associated with the IP address. This
|
178
|
-
# attribute is only available from the City and Insights web services and
|
179
|
-
# the GeoIP2 Enterprise database.
|
180
|
-
#
|
181
|
-
# @return [String, nil]
|
182
|
-
def organization
|
183
|
-
get('organization')
|
184
|
-
end
|
185
|
-
|
186
|
-
# An indicator of how static or dynamic an IP address is. This property is
|
187
|
-
# only available from GeoIP2 Precision Insights.
|
188
|
-
#
|
189
|
-
# @return [Float, nil]
|
190
|
-
def static_ip_score
|
191
|
-
get('static_ip_score')
|
192
|
-
end
|
193
|
-
|
194
|
-
# The estimated number of users sharing the IP/network during the past 24
|
195
|
-
# hours. For IPv4, the count is for the individual IP. For IPv6, the count
|
196
|
-
# is for the /64 network. This property is only available from GeoIP2
|
197
|
-
# Precision Insights.
|
198
|
-
#
|
199
|
-
# @return [Integer, nil]
|
200
|
-
def user_count
|
201
|
-
get('user_count')
|
202
|
-
end
|
203
|
-
|
204
|
-
# The user type associated with the IP address. This can be one of the
|
205
|
-
# following values:
|
206
|
-
#
|
207
|
-
# * business
|
208
|
-
# * cafe
|
209
|
-
# * cellular
|
210
|
-
# * college
|
211
|
-
# * content_delivery_network
|
212
|
-
# * dialup
|
213
|
-
# * government
|
214
|
-
# * hosting
|
215
|
-
# * library
|
216
|
-
# * military
|
217
|
-
# * residential
|
218
|
-
# * router
|
219
|
-
# * school
|
220
|
-
# * search_engine_spider
|
221
|
-
# * traveler
|
222
|
-
#
|
223
|
-
# This attribute is only available from the Insights web service and the
|
224
|
-
# GeoIP2 Enterprise database.
|
225
|
-
#
|
226
|
-
# @return [String, nil]
|
227
|
-
def user_type
|
228
|
-
get('user_type')
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
|
5
|
-
module Minfraud
|
6
|
-
module HTTPService
|
7
|
-
# Request performs HTTP requests.
|
8
|
-
class Request
|
9
|
-
# A proc containing Faraday configuration.
|
10
|
-
#
|
11
|
-
# @return [Proc, nil]
|
12
|
-
attr_reader :middleware
|
13
|
-
|
14
|
-
# The API endpoint.
|
15
|
-
#
|
16
|
-
# @return [String, nil]
|
17
|
-
attr_reader :server
|
18
|
-
|
19
|
-
# @param params [Hash] Hash of parameters. Each key/value should
|
20
|
-
# correspond to one of the available attributes.
|
21
|
-
def initialize(params = {})
|
22
|
-
@middleware = params[:middleware]
|
23
|
-
@server = params[:server]
|
24
|
-
end
|
25
|
-
|
26
|
-
# Perform an HTTP request to the specified endpoint with given body.
|
27
|
-
#
|
28
|
-
# @param params [Hash] Hash of parameters, including +:verb+,
|
29
|
-
# +:endpoint+, and +:body+.
|
30
|
-
#
|
31
|
-
# @return [Farday::Response]
|
32
|
-
def perform(params)
|
33
|
-
connection = Minfraud.connection
|
34
|
-
connection.send(*params.values_at(:verb, :endpoint, :body))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
require 'faraday_middleware'
|
5
|
-
|
6
|
-
module Minfraud
|
7
|
-
# HTTPService holds the HTTP client configuration.
|
8
|
-
module HTTPService
|
9
|
-
class << self
|
10
|
-
# The default HTTPService configuration.
|
11
|
-
#
|
12
|
-
# @return [Hash]
|
13
|
-
def configuration
|
14
|
-
server = DEFAULT_SERVER
|
15
|
-
if !Minfraud.host.nil?
|
16
|
-
server = "https://#{Minfraud.host}/minfraud/v2.0"
|
17
|
-
end
|
18
|
-
|
19
|
-
{
|
20
|
-
middleware: DEFAULT_MIDDLEWARE,
|
21
|
-
server: server,
|
22
|
-
}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# @!visibility private
|
27
|
-
DEFAULT_MIDDLEWARE = proc do |builder|
|
28
|
-
builder.request :json
|
29
|
-
|
30
|
-
account_id = Minfraud.account_id
|
31
|
-
account_id = Minfraud.user_id if account_id.nil?
|
32
|
-
|
33
|
-
builder.basic_auth account_id, Minfraud.license_key
|
34
|
-
|
35
|
-
builder.response :json, content_type: /\bjson$/
|
36
|
-
|
37
|
-
builder.adapter :net_http_persistent, pool_size: 5 do |http|
|
38
|
-
http.idle_timeout = 30
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Default base URL for minFraud.
|
43
|
-
DEFAULT_SERVER = 'https://minfraud.maxmind.com/minfraud/v2.0'
|
44
|
-
end
|
45
|
-
end
|