emailage 1.0.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/LICENSE +9 -0
- data/README.md +17 -16
- data/emailage.gemspec +3 -2
- data/lib/emailage.rb +1 -1
- data/lib/emailage/client.rb +2 -3
- data/lib/emailage/signature.rb +7 -6
- data/lib/emailage/validation.rb +9 -3
- data/lib/emailage/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 53cc92c38a1b39c95e934b0a1f5747c02b7399a3f9193633e3fd5d1f505f25f7
|
4
|
+
data.tar.gz: 4966fda4f32f73a4ad67e73ac88098c5a5566c09d82b190775c3ca0f6f87f268
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6688d1ce525bacae5ea034049ce628171d57ae1d393cbba7f93e0e634dce418014c3d6b14586b90d4e205b4f062091aa25fcf52c9fa98090e6a18a4a9d29e358
|
7
|
+
data.tar.gz: aeb4f42fbe5d21b3d6ccfc2e6e79119682d2993d177f7af9d4bc886d0a59faac13b79174a385ca9497e72540325de684c4166c3a427bf31ea2cd46aa73190ff7
|
data/.gitignore
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright 2016-2017 Emailage Corp
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ emailage = Emailage::Client.new('My account SID', 'My auth token')
|
|
30
30
|
emailage = Emailage::Client.new('My account SID', 'My auth token', sandbox: true)
|
31
31
|
```
|
32
32
|
|
33
|
-
Query
|
33
|
+
Query risk score information for the provided email address, IP address, or a combination
|
34
34
|
```ruby
|
35
35
|
# For an email address
|
36
36
|
emailage.query 'test@example.com'
|
@@ -56,20 +56,21 @@ emailage.query_email_and_ip_address 'test@example.com', '127.0.0.1', urid: 'My r
|
|
56
56
|
```
|
57
57
|
|
58
58
|
Mark an email address as fraud, good, or neutral.
|
59
|
-
All the listed forms are possible.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
59
|
+
All the listed forms are possible.
|
60
|
+
|
61
|
+
When you mark an email as fraud, you must pass the fraudCodeId:
|
62
|
+
1 - "Card Not Present Fraud"
|
63
|
+
2 - "Customer Dispute (Chargeback)"
|
64
|
+
3 - "First Party Fraud"
|
65
|
+
4 - "First Payment Default"
|
66
|
+
5 - "Identify Theft (Fraud Application)"
|
67
|
+
6 - "Identify Theft (Account Take Over)"
|
68
|
+
7 - "Suspected Fraud (Not Confirmed)"
|
69
|
+
8 - "Synthetic ID"
|
70
|
+
9 - "Other"
|
70
71
|
|
71
72
|
```ruby
|
72
|
-
# Mark an email address as fraud
|
73
|
+
# Mark an email address as fraud.
|
73
74
|
emailage.flag 'fraud', 'test@example.com', 8
|
74
75
|
emailage.flag_as_fraud 'test@example.com', 8
|
75
76
|
# Mark an email address as good.
|
@@ -82,8 +83,8 @@ emailage.remove_flag 'test@example.com'
|
|
82
83
|
|
83
84
|
### Exceptions
|
84
85
|
|
85
|
-
This gem can throw exceptions
|
86
|
+
This gem can throw exceptions for any of the following issues:
|
86
87
|
|
87
|
-
1. When Curl has an issue
|
88
|
-
2. When
|
88
|
+
1. When Curl has an issue and it's not possible to connect to the Emailage API
|
89
|
+
2. When improperly formatted JSON is received
|
89
90
|
3. When an incorrect email or IP address is passed to a flagging or explicitly querying method.
|
data/emailage.gemspec
CHANGED
@@ -6,9 +6,10 @@ require 'emailage/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "emailage"
|
8
8
|
spec.version = Emailage::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Emailage DEV Team"]
|
10
|
+
spec.email = ["devit@emailage.com"]
|
11
11
|
|
12
|
+
spec.license = "MIT"
|
12
13
|
spec.summary = "Emailage API client written in Ruby"
|
13
14
|
spec.description = "Emailage is a Fraud Prevention Solution. This gem implements a client for the Emailage web service."
|
14
15
|
spec.homepage = "https://emailage.com/"
|
data/lib/emailage.rb
CHANGED
data/lib/emailage/client.rb
CHANGED
@@ -12,7 +12,7 @@ module Emailage
|
|
12
12
|
# @param sandbox [Boolean] Whether to use a sandbox instead of a production server.
|
13
13
|
# Ensure the according secret and token are supplied.
|
14
14
|
#
|
15
|
-
# @note HMAC key is created according to Emailage docs
|
15
|
+
# @note HMAC key is created according to Emailage docs.
|
16
16
|
#
|
17
17
|
def initialize(secret, token, options={})
|
18
18
|
@secret, @token = secret, token
|
@@ -44,9 +44,8 @@ module Emailage
|
|
44
44
|
:oauth_version => 1.0
|
45
45
|
}.merge(params)
|
46
46
|
|
47
|
-
res = Typhoeus.get url, :params => params.merge(:oauth_signature => Signature.create('GET', url, params, @hmac_key))
|
47
|
+
res = Typhoeus.get url, :params => params.merge(:oauth_signature => Signature.create('GET', url, params, @hmac_key))
|
48
48
|
|
49
|
-
# For whatever reason Emailage dispatches JSON with unreadable symbls at the start, like \xEF\xBB\xBF.
|
50
49
|
json = res.body.sub(/^[^{]+/, '')
|
51
50
|
JSON.parse json
|
52
51
|
end
|
data/lib/emailage/signature.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
require 'cgi'
|
2
2
|
require 'openssl'
|
3
3
|
require 'base64'
|
4
|
+
require 'ERB'
|
4
5
|
|
5
6
|
module Emailage
|
6
7
|
module Signature
|
7
8
|
class << self
|
8
|
-
|
9
|
+
|
9
10
|
# 9.1.1. Normalize Request Parameters
|
10
11
|
def normalize_query_parameters(params)
|
11
|
-
params.sort.map {|k,v| [CGI.escape(k.to_s),
|
12
|
+
params.sort.map {|k,v| [CGI.escape(k.to_s), ERB::Util.url_encode(v.to_s)].join '='}.join '&'
|
12
13
|
end
|
13
|
-
|
14
|
+
|
14
15
|
# 9.1.3. Concatenate Request Elements
|
15
16
|
def concatenate_request_elements(method, url, query)
|
16
17
|
[method.to_s.upcase, url, query].map {|e| CGI.escape(e)}.join '&'
|
17
18
|
end
|
18
|
-
|
19
|
+
|
19
20
|
# 9.2. HMAC-SHA1
|
20
21
|
def hmac_sha1(base_string, hmac_key)
|
21
22
|
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), hmac_key, base_string)
|
@@ -38,7 +39,7 @@ module Emailage
|
|
38
39
|
# 9.2.1. Generating Signature
|
39
40
|
Base64.strict_encode64 digest
|
40
41
|
end
|
41
|
-
|
42
|
+
|
42
43
|
end
|
43
44
|
end
|
44
|
-
end
|
45
|
+
end
|
data/lib/emailage/validation.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "resolv"
|
2
|
+
|
1
3
|
module Emailage
|
2
4
|
module Validation
|
3
5
|
class << self
|
@@ -9,7 +11,7 @@ module Emailage
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def validate_ip!(ip)
|
12
|
-
unless ip =~
|
14
|
+
unless ((ip =~ Resolv::IPv4::Regex) || (ip =~ Resolv::IPv6::Regex))
|
13
15
|
raise ArgumentError, "#{ip} is not a valid IP address."
|
14
16
|
end
|
15
17
|
end
|
@@ -22,7 +24,8 @@ module Emailage
|
|
22
24
|
validate_email! email_or_ip.first
|
23
25
|
validate_ip! email_or_ip.last
|
24
26
|
else
|
25
|
-
|
27
|
+
regex_union = Regexp.union(URI::MailTo::EMAIL_REGEXP, Resolv::IPv4::Regex, Resolv::IPv6::Regex)
|
28
|
+
unless email_or_ip =~ regex_union
|
26
29
|
raise ArgumentError, "#{email_or_ip} is neither a valid IP address nor a valid email address."
|
27
30
|
end
|
28
31
|
end
|
@@ -30,4 +33,7 @@ module Emailage
|
|
30
33
|
|
31
34
|
end
|
32
35
|
end
|
33
|
-
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
data/lib/emailage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emailage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Emailage DEV Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -153,13 +153,14 @@ dependencies:
|
|
153
153
|
description: Emailage is a Fraud Prevention Solution. This gem implements a client
|
154
154
|
for the Emailage web service.
|
155
155
|
email:
|
156
|
-
-
|
156
|
+
- devit@emailage.com
|
157
157
|
executables: []
|
158
158
|
extensions: []
|
159
159
|
extra_rdoc_files: []
|
160
160
|
files:
|
161
161
|
- ".gitignore"
|
162
162
|
- Gemfile
|
163
|
+
- LICENSE
|
163
164
|
- README.md
|
164
165
|
- Rakefile
|
165
166
|
- bin/console
|
@@ -171,7 +172,8 @@ files:
|
|
171
172
|
- lib/emailage/validation.rb
|
172
173
|
- lib/emailage/version.rb
|
173
174
|
homepage: https://emailage.com/
|
174
|
-
licenses:
|
175
|
+
licenses:
|
176
|
+
- MIT
|
175
177
|
metadata: {}
|
176
178
|
post_install_message:
|
177
179
|
rdoc_options: []
|
@@ -189,9 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
191
|
version: '0'
|
190
192
|
requirements: []
|
191
193
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.7.1
|
193
195
|
signing_key:
|
194
196
|
specification_version: 4
|
195
197
|
summary: Emailage API client written in Ruby
|
196
198
|
test_files: []
|
197
|
-
has_rdoc:
|