minfraud 1.4.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/rubocop.yml +1 -1
  4. data/.github/workflows/test.yml +1 -4
  5. data/.rubocop.yml +4 -25
  6. data/CHANGELOG.md +82 -1
  7. data/Gemfile +0 -9
  8. data/LICENSE.txt +1 -1
  9. data/README.dev.md +1 -1
  10. data/README.md +13 -12
  11. data/lib/minfraud/assessments.rb +21 -16
  12. data/lib/minfraud/components/account.rb +1 -1
  13. data/lib/minfraud/components/billing.rb +1 -1
  14. data/lib/minfraud/components/credit_card.rb +21 -9
  15. data/lib/minfraud/components/custom_inputs.rb +1 -1
  16. data/lib/minfraud/components/device.rb +1 -1
  17. data/lib/minfraud/components/email.rb +93 -4
  18. data/lib/minfraud/components/event.rb +11 -11
  19. data/lib/minfraud/components/order.rb +1 -1
  20. data/lib/minfraud/components/payment.rb +152 -133
  21. data/lib/minfraud/components/report/transaction.rb +2 -2
  22. data/lib/minfraud/components/shipping.rb +2 -2
  23. data/lib/minfraud/components/shopping_cart.rb +2 -2
  24. data/lib/minfraud/components/shopping_cart_item.rb +3 -3
  25. data/lib/minfraud/http_service/response.rb +28 -21
  26. data/lib/minfraud/model/device.rb +1 -1
  27. data/lib/minfraud/model/disposition.rb +13 -6
  28. data/lib/minfraud/model/ip_address.rb +20 -44
  29. data/lib/minfraud/model/ip_risk_reason.rb +48 -0
  30. data/lib/minfraud/model/score.rb +1 -1
  31. data/lib/minfraud/model/subscores.rb +0 -22
  32. data/lib/minfraud/report.rb +19 -11
  33. data/lib/minfraud/validates.rb +2 -2
  34. data/lib/minfraud/version.rb +1 -1
  35. data/lib/minfraud.rb +18 -24
  36. data/minfraud.gemspec +10 -6
  37. metadata +40 -51
  38. data/lib/maxmind/geoip2/model/city.rb +0 -99
  39. data/lib/maxmind/geoip2/model/country.rb +0 -94
  40. data/lib/maxmind/geoip2/model/insights.rb +0 -38
  41. data/lib/maxmind/geoip2/record/abstract.rb +0 -46
  42. data/lib/maxmind/geoip2/record/city.rb +0 -62
  43. data/lib/maxmind/geoip2/record/continent.rb +0 -61
  44. data/lib/maxmind/geoip2/record/country.rb +0 -78
  45. data/lib/maxmind/geoip2/record/location.rb +0 -97
  46. data/lib/maxmind/geoip2/record/maxmind.rb +0 -41
  47. data/lib/maxmind/geoip2/record/place.rb +0 -52
  48. data/lib/maxmind/geoip2/record/postal.rb +0 -54
  49. data/lib/maxmind/geoip2/record/represented_country.rb +0 -47
  50. data/lib/maxmind/geoip2/record/subdivision.rb +0 -72
  51. data/lib/maxmind/geoip2/record/traits.rb +0 -233
  52. data/lib/minfraud/http_service/request.rb +0 -38
  53. data/lib/minfraud/http_service.rb +0 -45
@@ -84,26 +84,6 @@ module Minfraud
84
84
  # @return [Float, nil]
85
85
  attr_reader :email_local_part
86
86
 
87
- # The risk associated with the issuer ID number on the email domain. If
88
- # present, this is a value in the range 0.01 to 99.
89
- #
90
- # Deprecated effective August 29, 2019. This subscore will default to 1
91
- # and will be removed in a future release. The user tenure on email is
92
- # reflected in the /subscores/email_address output.
93
- #
94
- # @return [Float, nil]
95
- attr_reader :email_tenure
96
-
97
- # The risk associated with the issuer ID number on the IP address. If
98
- # present, this is a value in the range 0.01 to 99.
99
- #
100
- # Deprecated effective August 29, 2019. This subscore will default to 1
101
- # and will be removed in a future release. The IP tenure is reflected in
102
- # the overall risk score.
103
- #
104
- # @return [Float, nil]
105
- attr_reader :ip_tenure
106
-
107
87
  # The risk associated with the particular issuer ID number (IIN) given
108
88
  # the billing location and the history of usage of the IIN on your
109
89
  # account and shop ID. If present, this is a value in the range 0.01 to
@@ -162,8 +142,6 @@ module Minfraud
162
142
  @email_address = get('email_address')
163
143
  @email_domain = get('email_domain')
164
144
  @email_local_part = get('email_local_part')
165
- @email_tenure = get('email_tenure')
166
- @ip_tenure = get('ip_tenure')
167
145
  @issuer_id_number = get('issuer_id_number')
168
146
  @order_amount = get('order_amount')
169
147
  @phone_number = get('phone_number')
@@ -3,10 +3,8 @@
3
3
  module Minfraud
4
4
  # Report is used to perform minFraud Report Transaction API requests.
5
5
  #
6
- # @see https://dev.maxmind.com/minfraud/report-transaction/
6
+ # @see https://dev.maxmind.com/minfraud/report-a-transaction?lang=en
7
7
  class Report
8
- include ::Minfraud::HTTPService
9
-
10
8
  # The Report::Transaction component.
11
9
  #
12
10
  # @return [Minfraud::Components::Report::Transaction, nil]
@@ -23,6 +21,8 @@ module Minfraud
23
21
  #
24
22
  # @return [nil]
25
23
  #
24
+ # @raise [JSON::ParserError] if there was invalid JSON in the response.
25
+ #
26
26
  # @raise [Minfraud::AuthorizationError] If there was an authentication
27
27
  # problem.
28
28
  #
@@ -32,16 +32,24 @@ module Minfraud
32
32
  # @raise [Minfraud::ServerError] If the server reported an error of some
33
33
  # kind.
34
34
  def report_transaction
35
- raw = request.perform(
36
- verb: :post,
37
- endpoint: 'transactions/report',
38
- body: @transaction.to_json,
39
- )
35
+ response = nil
36
+ body = nil
37
+ Minfraud.connection_pool.with do |client|
38
+ response = client.post(
39
+ '/minfraud/v2.0/transactions/report',
40
+ json: @transaction.to_json,
41
+ )
42
+
43
+ body = response.to_s
44
+ end
40
45
 
46
+ endpoint = nil
47
+ locales = nil
41
48
  response = ::Minfraud::HTTPService::Response.new(
42
- status: raw.status.to_i,
43
- body: raw.body,
44
- headers: raw.headers
49
+ endpoint,
50
+ locales,
51
+ response,
52
+ body,
45
53
  )
46
54
 
47
55
  ::Minfraud::ErrorHandler.examine(response)
@@ -114,7 +114,7 @@ module Minfraud
114
114
  raise InvalidInputError, "The #{field} value is not valid. It must be numeric."
115
115
  end
116
116
 
117
- if value < 0 || value > 1e13 - 1
117
+ if value.negative? || value > 1e13 - 1
118
118
  raise InvalidInputError, "The #{field} value is not valid. It must be at least 0 and at most 1e13 - 1."
119
119
  end
120
120
  end
@@ -126,7 +126,7 @@ module Minfraud
126
126
  raise InvalidInputError, "The #{field} is not valid. It must be an integer."
127
127
  end
128
128
 
129
- if value < 0 || value > 1e13 - 1
129
+ if value.negative? || value > 1e13 - 1
130
130
  raise InvalidInputError, "The #{field} is not valid. It must be at least 0 and at most 1e13 - 1."
131
131
  end
132
132
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Minfraud
4
4
  # The Gem version.
5
- VERSION = '1.4.0'
5
+ VERSION = '2.0.0'
6
6
  end
data/lib/minfraud.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'faraday'
3
+ require 'connection_pool'
4
+ require 'http'
4
5
  require 'minfraud'
5
6
  require 'minfraud/enum'
6
7
  require 'minfraud/validates'
@@ -22,8 +23,6 @@ require 'minfraud/components/shopping_cart_item'
22
23
  require 'minfraud/resolver'
23
24
  require 'minfraud/version'
24
25
  require 'minfraud/errors'
25
- require 'minfraud/http_service'
26
- require 'minfraud/http_service/request'
27
26
  require 'minfraud/http_service/response'
28
27
  require 'minfraud/error_handler'
29
28
  require 'minfraud/assessments'
@@ -48,21 +47,13 @@ module Minfraud
48
47
  # @return [String, nil]
49
48
  attr_accessor :host
50
49
 
51
- # The MaxMind account ID that is used for authorization.
52
- #
53
- # @deprecated Use {::account_id} instead. This will be removed in the next
54
- # major version.
55
- #
56
- # @return [Integer, nil]
57
- attr_accessor :user_id
58
-
59
50
  # The MaxMind license key that is used for authorization.
60
51
  #
61
52
  # @return [String, nil]
62
53
  attr_accessor :license_key
63
54
 
64
55
  # @!visibility private
65
- attr_reader :connection
56
+ attr_reader :connection_pool
66
57
 
67
58
  # Yield self to accept configuration settings.
68
59
  #
@@ -70,20 +61,23 @@ module Minfraud
70
61
  def configure
71
62
  yield self
72
63
 
73
- config = Minfraud::HTTPService.configuration
74
- @connection = Faraday.new(config[:server], {}, &config[:middleware])
64
+ pool_size = 5
65
+ host = @host.nil? ? 'minfraud.maxmind.com' : @host
66
+ @connection_pool = ConnectionPool.new(size: pool_size) do
67
+ make_http_client.persistent("https://#{host}")
68
+ end
75
69
  end
76
70
 
77
- # The current Minfraud configuration.
78
- #
79
- # @deprecated This will be removed in the next major version.
80
- #
81
- # @return [Hash]
82
- def configuration
83
- {
84
- user_id: @user_id,
85
- license_key: @license_key
86
- }
71
+ private
72
+
73
+ def make_http_client
74
+ HTTP.basic_auth(
75
+ user: @account_id,
76
+ pass: @license_key,
77
+ ).headers(
78
+ accept: 'application/json',
79
+ user_agent: "minfraud-api-ruby/#{Minfraud::VERSION}",
80
+ )
87
81
  end
88
82
  end
89
83
  end
data/minfraud.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', File.dirname(File.realpath(__FILE__)))
3
+ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  require 'minfraud/version'
@@ -8,27 +8,31 @@ require 'minfraud/version'
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = 'minfraud'
10
10
  spec.version = Minfraud::VERSION
11
- spec.authors = ['kushnir.yb']
11
+ spec.authors = ['kushnir.yb', 'William Storey']
12
12
  spec.email = ['support@maxmind.com']
13
13
 
14
14
  spec.summary = 'Ruby API for the minFraud Score, Insights, Factors, and Report Transactions services'
15
15
  spec.homepage = 'https://github.com/maxmind/minfraud-api-ruby'
16
16
  spec.license = 'MIT'
17
17
 
18
- spec.required_ruby_version = '>= 2.1'
18
+ spec.required_ruby_version = '>= 2.5.0'
19
19
 
20
20
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
21
  spec.bindir = 'exe'
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_runtime_dependency 'faraday', '>= 0.9.1', '< 2.0'
26
- spec.add_runtime_dependency 'faraday_middleware', '>= 0.9.1', '< 2.0'
27
- spec.add_runtime_dependency 'net-http-persistent', '>= 2.0.0', '< 5.0'
25
+ spec.add_runtime_dependency 'connection_pool', '~> 2.2'
26
+ spec.add_runtime_dependency 'http', '>= 4.3', '< 6.0'
27
+ spec.add_runtime_dependency 'maxmind-geoip2', '~> 1.1'
28
+ spec.add_runtime_dependency 'simpleidn', '>= 0.1.1'
28
29
 
29
30
  spec.add_development_dependency 'bundler', '>= 1.16'
30
31
  spec.add_development_dependency 'rake'
31
32
  spec.add_development_dependency 'rspec', '~> 3.0'
32
33
  spec.add_development_dependency 'rubocop'
33
34
  spec.add_development_dependency 'webmock'
35
+ spec.metadata = {
36
+ 'rubygems_mfa_required' => 'true'
37
+ }
34
38
  end
metadata CHANGED
@@ -1,75 +1,78 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minfraud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kushnir.yb
8
- autorequire:
8
+ - William Storey
9
+ autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2020-10-13 00:00:00.000000000 Z
12
+ date: 2021-12-06 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: faraday
15
+ name: connection_pool
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.9.1
20
- - - "<"
18
+ - - "~>"
21
19
  - !ruby/object:Gem::Version
22
- version: '2.0'
20
+ version: '2.2'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
24
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 0.9.1
30
- - - "<"
25
+ - - "~>"
31
26
  - !ruby/object:Gem::Version
32
- version: '2.0'
27
+ version: '2.2'
33
28
  - !ruby/object:Gem::Dependency
34
- name: faraday_middleware
29
+ name: http
35
30
  requirement: !ruby/object:Gem::Requirement
36
31
  requirements:
37
32
  - - ">="
38
33
  - !ruby/object:Gem::Version
39
- version: 0.9.1
34
+ version: '4.3'
40
35
  - - "<"
41
36
  - !ruby/object:Gem::Version
42
- version: '2.0'
37
+ version: '6.0'
43
38
  type: :runtime
44
39
  prerelease: false
45
40
  version_requirements: !ruby/object:Gem::Requirement
46
41
  requirements:
47
42
  - - ">="
48
43
  - !ruby/object:Gem::Version
49
- version: 0.9.1
44
+ version: '4.3'
50
45
  - - "<"
51
46
  - !ruby/object:Gem::Version
52
- version: '2.0'
47
+ version: '6.0'
53
48
  - !ruby/object:Gem::Dependency
54
- name: net-http-persistent
49
+ name: maxmind-geoip2
55
50
  requirement: !ruby/object:Gem::Requirement
56
51
  requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: 2.0.0
60
- - - "<"
52
+ - - "~>"
61
53
  - !ruby/object:Gem::Version
62
- version: '5.0'
54
+ version: '1.1'
63
55
  type: :runtime
64
56
  prerelease: false
65
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ - !ruby/object:Gem::Dependency
63
+ name: simpleidn
64
+ requirement: !ruby/object:Gem::Requirement
66
65
  requirements:
67
66
  - - ">="
68
67
  - !ruby/object:Gem::Version
69
- version: 2.0.0
70
- - - "<"
68
+ version: 0.1.1
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
71
74
  - !ruby/object:Gem::Version
72
- version: '5.0'
75
+ version: 0.1.1
73
76
  - !ruby/object:Gem::Dependency
74
77
  name: bundler
75
78
  requirement: !ruby/object:Gem::Requirement
@@ -140,13 +143,14 @@ dependencies:
140
143
  - - ">="
141
144
  - !ruby/object:Gem::Version
142
145
  version: '0'
143
- description:
146
+ description:
144
147
  email:
145
148
  - support@maxmind.com
146
149
  executables: []
147
150
  extensions: []
148
151
  extra_rdoc_files: []
149
152
  files:
153
+ - ".github/dependabot.yml"
150
154
  - ".github/workflows/rubocop.yml"
151
155
  - ".github/workflows/test.yml"
152
156
  - ".gitignore"
@@ -161,20 +165,6 @@ files:
161
165
  - Rakefile
162
166
  - bin/console
163
167
  - bin/setup
164
- - lib/maxmind/geoip2/model/city.rb
165
- - lib/maxmind/geoip2/model/country.rb
166
- - lib/maxmind/geoip2/model/insights.rb
167
- - lib/maxmind/geoip2/record/abstract.rb
168
- - lib/maxmind/geoip2/record/city.rb
169
- - lib/maxmind/geoip2/record/continent.rb
170
- - lib/maxmind/geoip2/record/country.rb
171
- - lib/maxmind/geoip2/record/location.rb
172
- - lib/maxmind/geoip2/record/maxmind.rb
173
- - lib/maxmind/geoip2/record/place.rb
174
- - lib/maxmind/geoip2/record/postal.rb
175
- - lib/maxmind/geoip2/record/represented_country.rb
176
- - lib/maxmind/geoip2/record/subdivision.rb
177
- - lib/maxmind/geoip2/record/traits.rb
178
168
  - lib/minfraud.rb
179
169
  - lib/minfraud/assessments.rb
180
170
  - lib/minfraud/components/account.rb
@@ -195,8 +185,6 @@ files:
195
185
  - lib/minfraud/enum.rb
196
186
  - lib/minfraud/error_handler.rb
197
187
  - lib/minfraud/errors.rb
198
- - lib/minfraud/http_service.rb
199
- - lib/minfraud/http_service/request.rb
200
188
  - lib/minfraud/http_service/response.rb
201
189
  - lib/minfraud/model/abstract.rb
202
190
  - lib/minfraud/model/address.rb
@@ -211,6 +199,7 @@ files:
211
199
  - lib/minfraud/model/geoip2_location.rb
212
200
  - lib/minfraud/model/insights.rb
213
201
  - lib/minfraud/model/ip_address.rb
202
+ - lib/minfraud/model/ip_risk_reason.rb
214
203
  - lib/minfraud/model/issuer.rb
215
204
  - lib/minfraud/model/score.rb
216
205
  - lib/minfraud/model/score_ip_address.rb
@@ -225,8 +214,9 @@ files:
225
214
  homepage: https://github.com/maxmind/minfraud-api-ruby
226
215
  licenses:
227
216
  - MIT
228
- metadata: {}
229
- post_install_message:
217
+ metadata:
218
+ rubygems_mfa_required: 'true'
219
+ post_install_message:
230
220
  rdoc_options: []
231
221
  require_paths:
232
222
  - lib
@@ -234,16 +224,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
234
224
  requirements:
235
225
  - - ">="
236
226
  - !ruby/object:Gem::Version
237
- version: '2.1'
227
+ version: 2.5.0
238
228
  required_rubygems_version: !ruby/object:Gem::Requirement
239
229
  requirements:
240
230
  - - ">="
241
231
  - !ruby/object:Gem::Version
242
232
  version: '0'
243
233
  requirements: []
244
- rubyforge_project:
245
- rubygems_version: 2.7.6.2
246
- signing_key:
234
+ rubygems_version: 3.2.22
235
+ signing_key:
247
236
  specification_version: 4
248
237
  summary: Ruby API for the minFraud Score, Insights, Factors, and Report Transactions
249
238
  services
@@ -1,99 +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/model/country'
24
- require 'maxmind/geoip2/record/city'
25
- require 'maxmind/geoip2/record/location'
26
- require 'maxmind/geoip2/record/postal'
27
- require 'maxmind/geoip2/record/subdivision'
28
-
29
- module MaxMind
30
- module GeoIP2
31
- module Model
32
- # Model class for the data returned by the GeoIP2 City web service and
33
- # database. It is also used for GeoLite2 City lookups.
34
- #
35
- # The only difference between the City and Insights model classes is which
36
- # fields in each record may be populated. See
37
- # https://dev.maxmind.com/geoip/geoip2/web-services for more details.
38
- #
39
- # See {MaxMind::GeoIP2::Model::Country} for inherited methods.
40
- class City < Country
41
- # City data for the IP address.
42
- #
43
- # @return [MaxMind::GeoIP2::Record::City]
44
- attr_reader :city
45
-
46
- # Location data for the IP address.
47
- #
48
- # @return [MaxMind::GeoIP2::Record::Location]
49
- attr_reader :location
50
-
51
- # Postal data for the IP address.
52
- #
53
- # @return [MaxMind::GeoIP2::Record::Postal]
54
- attr_reader :postal
55
-
56
- # The country subdivisions for the IP address.
57
- #
58
- # The number and type of subdivisions varies by country, but a subdivision
59
- # is typically a state, province, country, etc. Subdivisions are ordered
60
- # from most general (largest) to most specific (smallest).
61
- #
62
- # If the response did not contain any subdivisions, this attribute will be
63
- # an empty array.
64
- #
65
- # @return [Array<MaxMind::GeoIP2::Record::Subdivision>]
66
- attr_reader :subdivisions
67
-
68
- # @!visibility private
69
- def initialize(record, locales)
70
- super(record, locales)
71
- @city = MaxMind::GeoIP2::Record::City.new(record['city'], locales)
72
- @location = MaxMind::GeoIP2::Record::Location.new(record['location'])
73
- @postal = MaxMind::GeoIP2::Record::Postal.new(record['postal'])
74
- @subdivisions = create_subdivisions(record['subdivisions'], locales)
75
- end
76
-
77
- # The most specific subdivision returned.
78
- #
79
- # If the response did not contain any subdivisions, this method returns
80
- # nil.
81
- #
82
- # @return [MaxMind::GeoIP2::Record::Subdivision, nil]
83
- def most_specific_subdivision
84
- @subdivisions.last
85
- end
86
-
87
- private
88
-
89
- def create_subdivisions(subdivisions, locales)
90
- return [] if subdivisions.nil?
91
-
92
- subdivisions.map do |s|
93
- MaxMind::GeoIP2::Record::Subdivision.new(s, locales)
94
- end
95
- end
96
- end
97
- end
98
- end
99
- end
@@ -1,94 +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/continent'
24
- require 'maxmind/geoip2/record/country'
25
- require 'maxmind/geoip2/record/maxmind'
26
- require 'maxmind/geoip2/record/represented_country'
27
- require 'maxmind/geoip2/record/traits'
28
-
29
- module MaxMind
30
- module GeoIP2
31
- module Model
32
- # Model class for the data returned by the GeoIP2 Country web service and
33
- # database. It is also used for GeoLite2 Country lookups.
34
- class Country
35
- # Continent data for the IP address.
36
- #
37
- # @return [MaxMind::GeoIP2::Record::Continent]
38
- attr_reader :continent
39
-
40
- # Country data for the IP address. This object represents the country where
41
- # MaxMind believes the end user is located.
42
- #
43
- # @return [MaxMind::GeoIP2::Record::Country]
44
- attr_reader :country
45
-
46
- # Data related to your MaxMind account.
47
- #
48
- # @return [MaxMind::GeoIP2::Record::MaxMind]
49
- attr_reader :maxmind
50
-
51
- # Registered country data for the IP address. This record represents the
52
- # country where the ISP has registered a given IP block and may differ from
53
- # the user's country.
54
- #
55
- # @return [MaxMind::GeoIP2::Record::Country]
56
- attr_reader :registered_country
57
-
58
- # Represented country data for the IP address. The represented country is
59
- # used for things like military bases. It is only present when the
60
- # represented country differs from the country.
61
- #
62
- # @return [MaxMind::GeoIP2::Record::RepresentedCountry]
63
- attr_reader :represented_country
64
-
65
- # Data for the traits of the IP address.
66
- #
67
- # @return [MaxMind::GeoIP2::Record::Traits]
68
- attr_reader :traits
69
-
70
- # @!visibility private
71
- def initialize(record, locales)
72
- @continent = MaxMind::GeoIP2::Record::Continent.new(
73
- record['continent'],
74
- locales,
75
- )
76
- @country = MaxMind::GeoIP2::Record::Country.new(
77
- record['country'],
78
- locales,
79
- )
80
- @maxmind = MaxMind::GeoIP2::Record::MaxMind.new(record['maxmind'])
81
- @registered_country = MaxMind::GeoIP2::Record::Country.new(
82
- record['registered_country'],
83
- locales,
84
- )
85
- @represented_country = MaxMind::GeoIP2::Record::RepresentedCountry.new(
86
- record['represented_country'],
87
- locales,
88
- )
89
- @traits = MaxMind::GeoIP2::Record::Traits.new(record['traits'])
90
- end
91
- end
92
- end
93
- end
94
- end
@@ -1,38 +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/model/city'
24
-
25
- module MaxMind
26
- module GeoIP2
27
- module Model
28
- # Model class for the data returned by the GeoIP2 Precision Insights web
29
- # service.
30
- #
31
- # The only difference between the City and Insights model classes is which
32
- # fields in each record may be populated. See
33
- # https://dev.maxmind.com/geoip/geoip2/web-services for more details.
34
- class Insights < City
35
- end
36
- end
37
- end
38
- end