minfraud 1.0.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +46 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +127 -0
- data/.travis.yml +20 -3
- data/CHANGELOG.md +56 -0
- data/CODE_OF_CONDUCT.md +4 -4
- data/Gemfile +11 -2
- data/LICENSE.txt +2 -1
- data/README.dev.md +4 -0
- data/README.md +107 -36
- data/Rakefile +18 -3
- data/bin/console +4 -3
- data/lib/maxmind/geoip2/model/city.rb +99 -0
- data/lib/maxmind/geoip2/model/country.rb +94 -0
- data/lib/maxmind/geoip2/model/insights.rb +38 -0
- data/lib/maxmind/geoip2/record/abstract.rb +46 -0
- data/lib/maxmind/geoip2/record/city.rb +62 -0
- data/lib/maxmind/geoip2/record/continent.rb +61 -0
- data/lib/maxmind/geoip2/record/country.rb +78 -0
- data/lib/maxmind/geoip2/record/location.rb +97 -0
- data/lib/maxmind/geoip2/record/maxmind.rb +41 -0
- data/lib/maxmind/geoip2/record/place.rb +52 -0
- data/lib/maxmind/geoip2/record/postal.rb +54 -0
- data/lib/maxmind/geoip2/record/represented_country.rb +47 -0
- data/lib/maxmind/geoip2/record/subdivision.rb +72 -0
- data/lib/maxmind/geoip2/record/traits.rb +224 -0
- data/lib/minfraud.rb +33 -8
- data/lib/minfraud/assessments.rb +25 -10
- data/lib/minfraud/components/account.rb +3 -1
- data/lib/minfraud/components/addressable.rb +11 -9
- data/lib/minfraud/components/base.rb +29 -5
- data/lib/minfraud/components/billing.rb +2 -0
- data/lib/minfraud/components/credit_card.rb +8 -1
- data/lib/minfraud/components/custom_inputs.rb +16 -0
- data/lib/minfraud/components/device.rb +13 -0
- data/lib/minfraud/components/email.rb +2 -0
- data/lib/minfraud/components/event.rb +15 -8
- data/lib/minfraud/components/order.rb +4 -1
- data/lib/minfraud/components/payment.rb +138 -14
- data/lib/minfraud/components/report/transaction.rb +69 -0
- data/lib/minfraud/components/shipping.rb +2 -4
- data/lib/minfraud/components/shopping_cart.rb +4 -1
- data/lib/minfraud/components/shopping_cart_item.rb +2 -2
- data/lib/minfraud/enum.rb +7 -4
- data/lib/minfraud/error_handler.rb +29 -9
- data/lib/minfraud/errors.rb +2 -0
- data/lib/minfraud/http_service.rb +13 -4
- data/lib/minfraud/http_service/request.rb +4 -1
- data/lib/minfraud/http_service/response.rb +40 -6
- data/lib/minfraud/model/abstract.rb +20 -0
- data/lib/minfraud/model/address.rb +52 -0
- data/lib/minfraud/model/billing_address.rb +11 -0
- data/lib/minfraud/model/credit_card.rb +75 -0
- data/lib/minfraud/model/device.rb +54 -0
- data/lib/minfraud/model/disposition.rb +35 -0
- data/lib/minfraud/model/email.rb +54 -0
- data/lib/minfraud/model/email_domain.rb +24 -0
- data/lib/minfraud/model/error.rb +28 -0
- data/lib/minfraud/model/factors.rb +24 -0
- data/lib/minfraud/model/geoip2_location.rb +25 -0
- data/lib/minfraud/model/insights.rb +68 -0
- data/lib/minfraud/model/ip_address.rb +82 -0
- data/lib/minfraud/model/issuer.rb +49 -0
- data/lib/minfraud/model/score.rb +76 -0
- data/lib/minfraud/model/score_ip_address.rb +23 -0
- data/lib/minfraud/model/shipping_address.rb +30 -0
- data/lib/minfraud/model/subscores.rb +175 -0
- data/lib/minfraud/model/warning.rb +63 -0
- data/lib/minfraud/report.rb +40 -0
- data/lib/minfraud/resolver.rb +16 -13
- data/lib/minfraud/version.rb +3 -1
- data/minfraud.gemspec +21 -15
- metadata +84 -19
data/Rakefile
CHANGED
@@ -1,6 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
3
6
|
|
4
7
|
RSpec::Core::RakeTask.new(:spec)
|
5
8
|
|
6
|
-
|
9
|
+
RuboCop::RakeTask.new
|
10
|
+
|
11
|
+
task default: :spec
|
12
|
+
|
13
|
+
# The current version of rubocop supports Ruby 2.4+. While we could run its
|
14
|
+
# older versions, the config isn't backwards compatible. Let's run it only for
|
15
|
+
# 2.4+. This isn't perfect, but as long as 1.9+ tests pass we should be okay.
|
16
|
+
version_pieces = RUBY_VERSION.split('.')
|
17
|
+
major_version = version_pieces[0]
|
18
|
+
minor_version = version_pieces[1]
|
19
|
+
if major_version == '2' && minor_version.to_i >= 4
|
20
|
+
task default: :rubocop
|
21
|
+
end
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'minfraud'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "minfraud"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
@@ -0,0 +1,99 @@
|
|
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
|
@@ -0,0 +1,94 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
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
|
@@ -0,0 +1,46 @@
|
|
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
|
+
module MaxMind
|
24
|
+
module GeoIP2
|
25
|
+
module Record
|
26
|
+
# @!visibility private
|
27
|
+
class Abstract
|
28
|
+
def initialize(record)
|
29
|
+
@record = record
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def get(key)
|
35
|
+
if @record.nil? || !@record.key?(key)
|
36
|
+
return false if key.start_with?('is_')
|
37
|
+
|
38
|
+
return nil
|
39
|
+
end
|
40
|
+
|
41
|
+
@record[key]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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
|
+
# City-level data associated with an IP address.
|
29
|
+
#
|
30
|
+
# This record is returned by all location services and databases besides
|
31
|
+
# Country.
|
32
|
+
#
|
33
|
+
# See {MaxMind::GeoIP2::Record::Place} for inherited methods.
|
34
|
+
class City < Place
|
35
|
+
# A value from 0-100 indicating MaxMind's confidence that the city is
|
36
|
+
# correct. This attribute is only available from the Insights service and
|
37
|
+
# the GeoIP2 Enterprise database.
|
38
|
+
#
|
39
|
+
# @return [Integer, nil]
|
40
|
+
def confidence
|
41
|
+
get('confidence')
|
42
|
+
end
|
43
|
+
|
44
|
+
# The GeoName ID for the city. This attribute is returned by all location
|
45
|
+
# services and databases.
|
46
|
+
#
|
47
|
+
# @return [Integer, nil]
|
48
|
+
def geoname_id
|
49
|
+
get('geoname_id')
|
50
|
+
end
|
51
|
+
|
52
|
+
# A Hash where the keys are locale codes and the values are names. This
|
53
|
+
# attribute is returned by all location services and databases.
|
54
|
+
#
|
55
|
+
# @return [Hash<String, String>, nil]
|
56
|
+
def names
|
57
|
+
get('names')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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 continent record associated with an IP address.
|
29
|
+
#
|
30
|
+
# This record is returned by all location services and databases.
|
31
|
+
#
|
32
|
+
# See {MaxMind::GeoIP2::Record::Place} for inherited methods.
|
33
|
+
class Continent < Place
|
34
|
+
# A two character continent code like "NA" (North America) or "OC"
|
35
|
+
# (Oceania). This attribute is returned by all location services and
|
36
|
+
# databases.
|
37
|
+
#
|
38
|
+
# @return [String, nil]
|
39
|
+
def code
|
40
|
+
get('code')
|
41
|
+
end
|
42
|
+
|
43
|
+
# The GeoName ID for the continent. This attribute is returned by all
|
44
|
+
# location services and databases.
|
45
|
+
#
|
46
|
+
# @return [String, nil]
|
47
|
+
def geoname_id
|
48
|
+
get('geoname_id')
|
49
|
+
end
|
50
|
+
|
51
|
+
# A Hash where the keys are locale codes and the values are names. This
|
52
|
+
# attribute is returned by all location services and databases.
|
53
|
+
#
|
54
|
+
# @return [Hash<String, String>, nil]
|
55
|
+
def names
|
56
|
+
get('names')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|