minfraud 1.6.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +1 -1
  3. data/.github/workflows/test.yml +1 -0
  4. data/.rubocop.yml +1 -20
  5. data/CHANGELOG.md +80 -4
  6. data/Gemfile +0 -9
  7. data/LICENSE.txt +1 -1
  8. data/README.md +4 -4
  9. data/lib/minfraud/assessments.rb +21 -16
  10. data/lib/minfraud/components/account.rb +1 -1
  11. data/lib/minfraud/components/billing.rb +1 -1
  12. data/lib/minfraud/components/credit_card.rb +40 -8
  13. data/lib/minfraud/components/custom_inputs.rb +1 -1
  14. data/lib/minfraud/components/device.rb +1 -1
  15. data/lib/minfraud/components/email.rb +1 -1
  16. data/lib/minfraud/components/event.rb +11 -11
  17. data/lib/minfraud/components/order.rb +1 -1
  18. data/lib/minfraud/components/payment.rb +153 -142
  19. data/lib/minfraud/components/report/transaction.rb +2 -2
  20. data/lib/minfraud/components/shipping.rb +2 -2
  21. data/lib/minfraud/components/shopping_cart.rb +1 -1
  22. data/lib/minfraud/components/shopping_cart_item.rb +3 -3
  23. data/lib/minfraud/http_service/response.rb +28 -21
  24. data/lib/minfraud/model/device.rb +1 -1
  25. data/lib/minfraud/model/disposition.rb +3 -3
  26. data/lib/minfraud/model/factors.rb +1 -1
  27. data/lib/minfraud/model/ip_address.rb +4 -47
  28. data/lib/minfraud/model/score.rb +1 -1
  29. data/lib/minfraud/model/subscores.rb +1 -23
  30. data/lib/minfraud/report.rb +19 -11
  31. data/lib/minfraud/validates.rb +2 -2
  32. data/lib/minfraud/version.rb +1 -1
  33. data/lib/minfraud.rb +18 -24
  34. data/minfraud.gemspec +13 -10
  35. metadata +47 -67
  36. data/lib/maxmind/geoip2/model/city.rb +0 -99
  37. data/lib/maxmind/geoip2/model/country.rb +0 -94
  38. data/lib/maxmind/geoip2/model/insights.rb +0 -38
  39. data/lib/maxmind/geoip2/record/abstract.rb +0 -46
  40. data/lib/maxmind/geoip2/record/city.rb +0 -62
  41. data/lib/maxmind/geoip2/record/continent.rb +0 -61
  42. data/lib/maxmind/geoip2/record/country.rb +0 -78
  43. data/lib/maxmind/geoip2/record/location.rb +0 -97
  44. data/lib/maxmind/geoip2/record/maxmind.rb +0 -41
  45. data/lib/maxmind/geoip2/record/place.rb +0 -52
  46. data/lib/maxmind/geoip2/record/postal.rb +0 -54
  47. data/lib/maxmind/geoip2/record/represented_country.rb +0 -47
  48. data/lib/maxmind/geoip2/record/subdivision.rb +0 -72
  49. data/lib/maxmind/geoip2/record/traits.rb +0 -233
  50. data/lib/minfraud/http_service/request.rb +0 -38
  51. data/lib/minfraud/http_service.rb +0 -45
@@ -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.6.0'
5
+ VERSION = '2.2.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,7 +8,7 @@ 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'
@@ -22,14 +22,17 @@ Gem::Specification.new do |spec|
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'
28
- spec.add_runtime_dependency 'simpleidn', '>= 0.1.1'
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', '>= 0.1.1'
29
29
 
30
- spec.add_development_dependency 'bundler', '>= 1.16'
31
- spec.add_development_dependency 'rake'
30
+ spec.add_development_dependency 'bundler', '~> 2.2'
31
+ spec.add_development_dependency 'rake', '~> 13.0'
32
32
  spec.add_development_dependency 'rspec', '~> 3.0'
33
- spec.add_development_dependency 'rubocop'
34
- spec.add_development_dependency 'webmock'
33
+ spec.add_development_dependency 'rubocop', '~> 1.23'
34
+ spec.add_development_dependency 'webmock', '~> 3.14'
35
+ spec.metadata = {
36
+ 'rubygems_mfa_required' => 'true'
37
+ }
35
38
  end
metadata CHANGED
@@ -1,79 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minfraud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 2.2.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: 2021-08-19 00:00:00.000000000 Z
12
+ date: 2022-03-28 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
66
58
  requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 2.0.0
70
- - - "<"
59
+ - - "~>"
71
60
  - !ruby/object:Gem::Version
72
- version: '5.0'
61
+ version: '1.1'
73
62
  - !ruby/object:Gem::Dependency
74
63
  name: simpleidn
75
64
  requirement: !ruby/object:Gem::Requirement
76
65
  requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
77
69
  - - ">="
78
70
  - !ruby/object:Gem::Version
79
71
  version: 0.1.1
@@ -81,6 +73,9 @@ dependencies:
81
73
  prerelease: false
82
74
  version_requirements: !ruby/object:Gem::Requirement
83
75
  requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '0.1'
84
79
  - - ">="
85
80
  - !ruby/object:Gem::Version
86
81
  version: 0.1.1
@@ -88,30 +83,30 @@ dependencies:
88
83
  name: bundler
89
84
  requirement: !ruby/object:Gem::Requirement
90
85
  requirements:
91
- - - ">="
86
+ - - "~>"
92
87
  - !ruby/object:Gem::Version
93
- version: '1.16'
88
+ version: '2.2'
94
89
  type: :development
95
90
  prerelease: false
96
91
  version_requirements: !ruby/object:Gem::Requirement
97
92
  requirements:
98
- - - ">="
93
+ - - "~>"
99
94
  - !ruby/object:Gem::Version
100
- version: '1.16'
95
+ version: '2.2'
101
96
  - !ruby/object:Gem::Dependency
102
97
  name: rake
103
98
  requirement: !ruby/object:Gem::Requirement
104
99
  requirements:
105
- - - ">="
100
+ - - "~>"
106
101
  - !ruby/object:Gem::Version
107
- version: '0'
102
+ version: '13.0'
108
103
  type: :development
109
104
  prerelease: false
110
105
  version_requirements: !ruby/object:Gem::Requirement
111
106
  requirements:
112
- - - ">="
107
+ - - "~>"
113
108
  - !ruby/object:Gem::Version
114
- version: '0'
109
+ version: '13.0'
115
110
  - !ruby/object:Gem::Dependency
116
111
  name: rspec
117
112
  requirement: !ruby/object:Gem::Requirement
@@ -130,31 +125,31 @@ dependencies:
130
125
  name: rubocop
131
126
  requirement: !ruby/object:Gem::Requirement
132
127
  requirements:
133
- - - ">="
128
+ - - "~>"
134
129
  - !ruby/object:Gem::Version
135
- version: '0'
130
+ version: '1.23'
136
131
  type: :development
137
132
  prerelease: false
138
133
  version_requirements: !ruby/object:Gem::Requirement
139
134
  requirements:
140
- - - ">="
135
+ - - "~>"
141
136
  - !ruby/object:Gem::Version
142
- version: '0'
137
+ version: '1.23'
143
138
  - !ruby/object:Gem::Dependency
144
139
  name: webmock
145
140
  requirement: !ruby/object:Gem::Requirement
146
141
  requirements:
147
- - - ">="
142
+ - - "~>"
148
143
  - !ruby/object:Gem::Version
149
- version: '0'
144
+ version: '3.14'
150
145
  type: :development
151
146
  prerelease: false
152
147
  version_requirements: !ruby/object:Gem::Requirement
153
148
  requirements:
154
- - - ">="
149
+ - - "~>"
155
150
  - !ruby/object:Gem::Version
156
- version: '0'
157
- description:
151
+ version: '3.14'
152
+ description:
158
153
  email:
159
154
  - support@maxmind.com
160
155
  executables: []
@@ -176,20 +171,6 @@ files:
176
171
  - Rakefile
177
172
  - bin/console
178
173
  - bin/setup
179
- - lib/maxmind/geoip2/model/city.rb
180
- - lib/maxmind/geoip2/model/country.rb
181
- - lib/maxmind/geoip2/model/insights.rb
182
- - lib/maxmind/geoip2/record/abstract.rb
183
- - lib/maxmind/geoip2/record/city.rb
184
- - lib/maxmind/geoip2/record/continent.rb
185
- - lib/maxmind/geoip2/record/country.rb
186
- - lib/maxmind/geoip2/record/location.rb
187
- - lib/maxmind/geoip2/record/maxmind.rb
188
- - lib/maxmind/geoip2/record/place.rb
189
- - lib/maxmind/geoip2/record/postal.rb
190
- - lib/maxmind/geoip2/record/represented_country.rb
191
- - lib/maxmind/geoip2/record/subdivision.rb
192
- - lib/maxmind/geoip2/record/traits.rb
193
174
  - lib/minfraud.rb
194
175
  - lib/minfraud/assessments.rb
195
176
  - lib/minfraud/components/account.rb
@@ -210,8 +191,6 @@ files:
210
191
  - lib/minfraud/enum.rb
211
192
  - lib/minfraud/error_handler.rb
212
193
  - lib/minfraud/errors.rb
213
- - lib/minfraud/http_service.rb
214
- - lib/minfraud/http_service/request.rb
215
194
  - lib/minfraud/http_service/response.rb
216
195
  - lib/minfraud/model/abstract.rb
217
196
  - lib/minfraud/model/address.rb
@@ -241,8 +220,9 @@ files:
241
220
  homepage: https://github.com/maxmind/minfraud-api-ruby
242
221
  licenses:
243
222
  - MIT
244
- metadata: {}
245
- post_install_message:
223
+ metadata:
224
+ rubygems_mfa_required: 'true'
225
+ post_install_message:
246
226
  rdoc_options: []
247
227
  require_paths:
248
228
  - lib
@@ -257,8 +237,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
237
  - !ruby/object:Gem::Version
258
238
  version: '0'
259
239
  requirements: []
260
- rubygems_version: 3.1.2
261
- signing_key:
240
+ rubygems_version: 3.3.3
241
+ signing_key:
262
242
  specification_version: 4
263
243
  summary: Ruby API for the minFraud Score, Insights, Factors, and Report Transactions
264
244
  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