minfraud 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/rubocop.yml +1 -1
- data/.github/workflows/test.yml +1 -4
- data/.rubocop.yml +4 -25
- data/CHANGELOG.md +82 -1
- data/Gemfile +0 -9
- data/LICENSE.txt +1 -1
- data/README.dev.md +1 -1
- data/README.md +13 -12
- 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 +21 -9
- data/lib/minfraud/components/custom_inputs.rb +1 -1
- data/lib/minfraud/components/device.rb +1 -1
- data/lib/minfraud/components/email.rb +93 -4
- data/lib/minfraud/components/event.rb +11 -11
- data/lib/minfraud/components/order.rb +1 -1
- data/lib/minfraud/components/payment.rb +152 -133
- data/lib/minfraud/components/report/transaction.rb +2 -2
- data/lib/minfraud/components/shipping.rb +2 -2
- data/lib/minfraud/components/shopping_cart.rb +2 -2
- 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 +13 -6
- data/lib/minfraud/model/ip_address.rb +20 -44
- data/lib/minfraud/model/ip_risk_reason.rb +48 -0
- 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 +10 -6
- metadata +40 -51
- 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,46 +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
|
-
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
|
@@ -1,62 +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
|
-
# 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
|
@@ -1,61 +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 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
|
@@ -1,78 +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 country 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 Country < Place
|
34
|
-
# A value from 0-100 indicating MaxMind's confidence that the country is
|
35
|
-
# correct. This attribute is only available from the Insights service and
|
36
|
-
# the GeoIP2 Enterprise database.
|
37
|
-
#
|
38
|
-
# @return [Integer, nil]
|
39
|
-
def confidence
|
40
|
-
get('confidence')
|
41
|
-
end
|
42
|
-
|
43
|
-
# The GeoName ID for the country. This attribute is returned by all
|
44
|
-
# location services and databases.
|
45
|
-
#
|
46
|
-
# @return [Integer, nil]
|
47
|
-
def geoname_id
|
48
|
-
get('geoname_id')
|
49
|
-
end
|
50
|
-
|
51
|
-
# This is true if the country is a member state of the European Union. This
|
52
|
-
# attribute is returned by all location services and databases.
|
53
|
-
#
|
54
|
-
# @return [Boolean]
|
55
|
-
def in_european_union?
|
56
|
-
get('is_in_european_union')
|
57
|
-
end
|
58
|
-
|
59
|
-
# The two-character ISO 3166-1 alpha code for the country. See
|
60
|
-
# https://en.wikipedia.org/wiki/ISO_3166-1. This attribute is returned by
|
61
|
-
# all location services and databases.
|
62
|
-
#
|
63
|
-
# @return [String, nil]
|
64
|
-
def iso_code
|
65
|
-
get('iso_code')
|
66
|
-
end
|
67
|
-
|
68
|
-
# A Hash where the keys are locale codes and the values are names. This
|
69
|
-
# attribute is returned by all location services and databases.
|
70
|
-
#
|
71
|
-
# @return [Hash<String, String>, nil]
|
72
|
-
def names
|
73
|
-
get('names')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,97 +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 location record associated with an IP address.
|
29
|
-
#
|
30
|
-
# This record is returned by all location services and databases besides
|
31
|
-
# Country.
|
32
|
-
class Location < Abstract
|
33
|
-
# The approximate accuracy radius in kilometers around the latitude and
|
34
|
-
# longitude for the IP address. This is the radius where we have a 67%
|
35
|
-
# confidence that the device using the IP address resides within the circle
|
36
|
-
# centered at the latitude and longitude with the provided radius.
|
37
|
-
#
|
38
|
-
# @return [Integer, nil]
|
39
|
-
def accuracy_radius
|
40
|
-
get('accuracy_radius')
|
41
|
-
end
|
42
|
-
|
43
|
-
# The average income in US dollars associated with the requested IP
|
44
|
-
# address. This attribute is only available from the Insights service.
|
45
|
-
#
|
46
|
-
# @return [Integer, nil]
|
47
|
-
def average_income
|
48
|
-
get('average_income')
|
49
|
-
end
|
50
|
-
|
51
|
-
# The approximate latitude of the location associated with the IP address.
|
52
|
-
# This value is not precise and should not be used to identify a particular
|
53
|
-
# address or household.
|
54
|
-
#
|
55
|
-
# @return [Float, nil]
|
56
|
-
def latitude
|
57
|
-
get('latitude')
|
58
|
-
end
|
59
|
-
|
60
|
-
# The approximate longitude of the location associated with the IP address.
|
61
|
-
# This value is not precise and should not be used to identify a particular
|
62
|
-
# address or household.
|
63
|
-
#
|
64
|
-
# @return [Float, nil]
|
65
|
-
def longitude
|
66
|
-
get('longitude')
|
67
|
-
end
|
68
|
-
|
69
|
-
# The metro code of the location if the location is in the US. MaxMind
|
70
|
-
# returns the same metro codes as the Google AdWords API. See
|
71
|
-
# https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions.
|
72
|
-
#
|
73
|
-
# @return [Integer, nil]
|
74
|
-
def metro_code
|
75
|
-
get('metro_code')
|
76
|
-
end
|
77
|
-
|
78
|
-
# The estimated population per square kilometer associated with the IP
|
79
|
-
# address. This attribute is only available from the Insights service.
|
80
|
-
#
|
81
|
-
# @return [Integer, nil]
|
82
|
-
def population_density
|
83
|
-
get('population_density')
|
84
|
-
end
|
85
|
-
|
86
|
-
# The time zone associated with location, as specified by the IANA Time
|
87
|
-
# Zone Database, e.g., "America/New_York". See
|
88
|
-
# https://www.iana.org/time-zones.
|
89
|
-
#
|
90
|
-
# @return [String, nil]
|
91
|
-
def time_zone
|
92
|
-
get('time_zone')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
@@ -1,41 +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 about your account.
|
29
|
-
#
|
30
|
-
# This record is returned by all location services.
|
31
|
-
class MaxMind < Abstract
|
32
|
-
# The number of remaining queries you have for the service you are calling.
|
33
|
-
#
|
34
|
-
# @return [Integer, nil]
|
35
|
-
def queries_remaining
|
36
|
-
get('queries_remaining')
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,52 +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
|
-
# Location data common to different location types.
|
29
|
-
class Place < Abstract
|
30
|
-
# @!visibility private
|
31
|
-
def initialize(record, locales)
|
32
|
-
super(record)
|
33
|
-
@locales = locales
|
34
|
-
end
|
35
|
-
|
36
|
-
# The first available localized name in order of preference.
|
37
|
-
#
|
38
|
-
# @return [String, nil]
|
39
|
-
def name
|
40
|
-
n = names
|
41
|
-
return nil if n.nil?
|
42
|
-
|
43
|
-
@locales.each do |locale|
|
44
|
-
return n[locale] if n.key?(locale)
|
45
|
-
end
|
46
|
-
|
47
|
-
nil
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -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
|