maxmind 0.4.5 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -4
- data/README.md +5 -6
- data/lib/maxmind/request.rb +5 -8
- data/lib/maxmind/version.rb +1 -1
- data/spec/maxmind/request_spec.rb +31 -16
- data/spec/maxmind/response_spec.rb +16 -16
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4608e9c60c8244b7b82c9a95add791a1b0d4f718
|
4
|
+
data.tar.gz: 7e2da7ff1682d4db6c238b0a56480b3014265fdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a9e248e97806a9391aa3e25d3c5c68e323d08b3ba28525bcf9da55fd2b0eecafe01c7ba071ff0db5ad9c0f1a13e66d4e0afce2e7db14abe7427f7ae7912a939
|
7
|
+
data.tar.gz: 17a3e05790a99d970ec19b08b0b932f5798bd4be29f47fc595c8437a33245c60540b71cdc5b2a18e2afe04f6440ff219df61c9009e1aea92d2cfc8d015a86b07
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
maxmind
|
2
2
|
==========
|
3
3
|
|
4
|
-
|
4
|
+
An unofficial wrapper around MaxMind's minFraud anti-fraud service.
|
5
5
|
|
6
|
+
For MaxMind's Proxy Detection Service, see this gem: [https://github.com/eric-smartlove/maxmind\_proxy\_detection](https://github.com/eric-smartlove/maxmind_proxy_detection)
|
6
7
|
|
7
8
|
Installation
|
8
9
|
------------
|
@@ -38,11 +39,7 @@ These are the only required fields to acquire a response from MaxMind.
|
|
38
39
|
require 'maxmind'
|
39
40
|
Maxmind.license_key = 'LICENSE_KEY'
|
40
41
|
request = Maxmind::Request.new(
|
41
|
-
:client_ip => '24.24.24.24'
|
42
|
-
:city => 'New York',
|
43
|
-
:region => 'NY',
|
44
|
-
:postal => '11434',
|
45
|
-
:country => 'US'
|
42
|
+
:client_ip => '24.24.24.24'
|
46
43
|
)
|
47
44
|
|
48
45
|
response = request.process!
|
@@ -164,6 +161,8 @@ Contributors
|
|
164
161
|
* Thomas Morgan
|
165
162
|
* Tinu Cleatus <tinu.cleatus@me.com>
|
166
163
|
* Don Pflaster <dpflaster@gmail.com>
|
164
|
+
* Igor Pstyga
|
165
|
+
* Jack Kelly <jack@trikeapps.com>
|
167
166
|
|
168
167
|
Thanks to all :)
|
169
168
|
|
data/lib/maxmind/request.rb
CHANGED
@@ -105,7 +105,8 @@ module Maxmind
|
|
105
105
|
:avs_result => @avs_result,
|
106
106
|
:cvv_result => @cvv_result,
|
107
107
|
:txn_type => @txn_type,
|
108
|
-
:order_amount => @order_amount
|
108
|
+
:order_amount => @order_amount,
|
109
|
+
:order_currency => @order_currency
|
109
110
|
}
|
110
111
|
|
111
112
|
field_set = required_fields.merge(optional_fields)
|
@@ -120,14 +121,14 @@ module Maxmind
|
|
120
121
|
def post(query_params)
|
121
122
|
servers ||= SERVERS.map{|hostname| "https://#{hostname}/app/ccv2r"}
|
122
123
|
url = URI.parse(servers.shift)
|
123
|
-
|
124
|
+
|
124
125
|
req = Net::HTTP::Post.new(url.path)
|
125
126
|
req.set_form_data(query_params)
|
126
127
|
|
127
128
|
h = Net::HTTP.new(url.host, url.port)
|
128
129
|
h.use_ssl = true
|
129
130
|
h.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
130
|
-
|
131
|
+
|
131
132
|
# set some timeouts
|
132
133
|
h.open_timeout = 60 # this blocks forever by default, lets be a bit less crazy.
|
133
134
|
h.read_timeout = self.class.timeout || DefaultTimeout
|
@@ -147,15 +148,11 @@ module Maxmind
|
|
147
148
|
Digest::MD5.hexdigest(value.downcase)
|
148
149
|
end
|
149
150
|
end
|
150
|
-
|
151
|
+
|
151
152
|
protected
|
152
153
|
def validate
|
153
154
|
raise ArgumentError, 'License key is required' unless Maxmind::license_key
|
154
155
|
raise ArgumentError, 'IP address is required' unless client_ip
|
155
|
-
raise ArgumentError, 'City is required' unless city
|
156
|
-
raise ArgumentError, 'Region is required' unless region
|
157
|
-
raise ArgumentError, 'Postal code is required' unless postal
|
158
|
-
raise ArgumentError, 'Country is required' unless country
|
159
156
|
end
|
160
157
|
end
|
161
158
|
end
|
data/lib/maxmind/version.rb
CHANGED
@@ -14,57 +14,72 @@ describe Maxmind::Request do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "requires client IP" do
|
17
|
-
expect {
|
17
|
+
expect {
|
18
|
+
@request.client_ip = nil; @request.send(:validate)
|
19
|
+
}.to raise_exception(ArgumentError)
|
18
20
|
end
|
19
21
|
|
20
|
-
it "
|
21
|
-
expect {
|
22
|
+
it "doesn't require city" do
|
23
|
+
expect {
|
24
|
+
@request.city = nil; @request.send(:validate)
|
25
|
+
}.not_to raise_error
|
22
26
|
end
|
23
27
|
|
24
|
-
it "
|
25
|
-
expect {
|
28
|
+
it "doesn't require region" do
|
29
|
+
expect {
|
30
|
+
@request.region = nil; @request.send(:validate)
|
31
|
+
}.not_to raise_error
|
26
32
|
end
|
27
33
|
|
28
|
-
it "
|
29
|
-
expect {
|
34
|
+
it "doesn't require postal" do
|
35
|
+
expect {
|
36
|
+
@request.postal = nil; @request.send(:validate)
|
37
|
+
}.not_to raise_error
|
30
38
|
end
|
31
39
|
|
32
|
-
it "
|
33
|
-
expect {
|
40
|
+
it "doesn't require country" do
|
41
|
+
expect {
|
42
|
+
@request.country = nil; @request.send(:validate)
|
43
|
+
}.not_to raise_error
|
44
|
+
end
|
45
|
+
|
46
|
+
it "saves order currency" do
|
47
|
+
@request.order_currency = 'GBP'
|
48
|
+
expect(@request.query[:order_currency]).to eq 'GBP'
|
34
49
|
end
|
35
50
|
|
36
51
|
it "converts username to MD5" do
|
37
52
|
@request.username = 'testuser'
|
38
|
-
@request.username.
|
53
|
+
expect(@request.username).to eq '5d9c68c6c50ed3d02a2fcf54f63993b6'
|
39
54
|
end
|
40
55
|
|
41
56
|
it "converts password to MD5" do
|
42
57
|
@request.password = 'testpassword'
|
43
|
-
@request.password.
|
58
|
+
expect(@request.password).to eq 'e16b2ab8d12314bf4efbd6203906ea6c'
|
44
59
|
end
|
45
60
|
|
46
61
|
it "converts email to MD5" do
|
47
62
|
@request.email = 'test@test.com'
|
48
|
-
@request.email.
|
63
|
+
expect(@request.email).to eq 'b642b4217b34b1e8d3bd915fc65c4452'
|
49
64
|
end
|
50
65
|
|
51
66
|
it "does not double convert an md5 username" do
|
52
67
|
@request.username = 'b642b4217b34b1e8d3bd915fc65c4452'
|
53
|
-
@request.username.
|
68
|
+
expect(@request.username).to eq 'b642b4217b34b1e8d3bd915fc65c4452'
|
54
69
|
end
|
55
70
|
|
56
71
|
it "does not double convert an md5 password" do
|
57
72
|
@request.password = 'b642b4217b34b1e8d3bd915fc65c4452'
|
58
|
-
@request.password.
|
73
|
+
expect(@request.password).to eq 'b642b4217b34b1e8d3bd915fc65c4452'
|
59
74
|
end
|
60
75
|
|
61
76
|
it "does not double convert an md5 email" do
|
62
77
|
@request.email = 'b642b4217b34b1e8d3bd915fc65c4452'
|
63
|
-
@request.email.
|
78
|
+
expect(@request.email).to eq 'b642b4217b34b1e8d3bd915fc65c4452'
|
64
79
|
end
|
65
80
|
|
66
81
|
it "exposes the query parameters" do
|
67
|
-
@request.query.
|
82
|
+
expect(@request.query).to be_a Hash
|
68
83
|
end
|
69
84
|
|
70
85
|
end
|
@@ -22,59 +22,59 @@ describe Maxmind::Response do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "exposes its attributes" do
|
25
|
-
@response.attributes.
|
25
|
+
expect(@response.attributes).to be_a Hash
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "exposes the raw response body" do
|
29
|
-
@response.body.
|
29
|
+
expect(@response.body).to eq @response_body
|
30
30
|
end
|
31
31
|
|
32
32
|
it "exposes the http response code" do
|
33
|
-
@response.http_code.
|
33
|
+
expect(@response.http_code).to eq 200
|
34
34
|
end
|
35
35
|
|
36
36
|
it "has a distance" do
|
37
|
-
@response.distance.
|
37
|
+
expect(@response.distance).to eq 329
|
38
38
|
end
|
39
39
|
|
40
40
|
it "has a maxmind ID" do
|
41
|
-
@response.maxmind_id.
|
41
|
+
expect(@response.maxmind_id).to eq '9VSOSDE2'
|
42
42
|
end
|
43
43
|
|
44
44
|
it "has a risk score" do
|
45
|
-
@response.risk_score.
|
45
|
+
expect(@response.risk_score).to eq 2.0
|
46
46
|
end
|
47
47
|
|
48
48
|
it "has a score" do
|
49
|
-
@response.score.
|
49
|
+
expect(@response.score).to eq 7.66
|
50
50
|
end
|
51
51
|
|
52
52
|
it "has queries remaining" do
|
53
|
-
@response.queries_remaining.
|
53
|
+
expect(@response.queries_remaining).to eq 955
|
54
54
|
end
|
55
55
|
|
56
56
|
it "has an explanation" do
|
57
|
-
@response.explanation.
|
57
|
+
expect(@response.explanation).to be_a String
|
58
58
|
end
|
59
59
|
|
60
60
|
it "has a country match" do
|
61
|
-
@response.country_match.
|
61
|
+
expect(@response.country_match).not_to be_nil
|
62
62
|
end
|
63
63
|
|
64
64
|
it "has a boolean country match" do
|
65
|
-
@response.country_match.
|
66
|
-
@response.country_match.
|
65
|
+
expect(@response.country_match).not_to eq "Yes"
|
66
|
+
expect(@response.country_match).to be_truthy
|
67
67
|
end
|
68
68
|
|
69
69
|
it "has a phone in billing location" do
|
70
|
-
@response.phone_in_billing_location.
|
70
|
+
expect(@response.phone_in_billing_location).to be_falsey
|
71
71
|
end
|
72
72
|
|
73
73
|
it "has a phone in billing location ? method" do
|
74
|
-
@response.phone_in_billing_location
|
74
|
+
expect(@response.phone_in_billing_location?).to be_falsey
|
75
75
|
end
|
76
76
|
|
77
77
|
it "has a high risk email" do
|
78
|
-
@response.high_risk_email.
|
78
|
+
expect(@response.high_risk_email).to be_truthy
|
79
79
|
end
|
80
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxmind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Daniels
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "A wrapper around MaxMind's minFraud anti-fraud service. \n\nhttp://www.maxmind.com/app/ccv_overview\n"
|
14
14
|
email: adam@mediadrive.ca
|
@@ -18,8 +18,8 @@ extra_rdoc_files:
|
|
18
18
|
- LICENSE
|
19
19
|
- README.md
|
20
20
|
files:
|
21
|
-
- .gitignore
|
22
|
-
- .travis.yml
|
21
|
+
- ".gitignore"
|
22
|
+
- ".travis.yml"
|
23
23
|
- Gemfile
|
24
24
|
- Guardfile
|
25
25
|
- LICENSE
|
@@ -53,17 +53,17 @@ require_paths:
|
|
53
53
|
- lib
|
54
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- -
|
56
|
+
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.
|
66
|
+
rubygems_version: 2.4.8
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Wrapper for MaxMind's minFraud service
|