emailage 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/emailage.gemspec +1 -2
- data/lib/emailage/client.rb +24 -24
- data/lib/emailage/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c01f8a02f808ca338b0e70b8a2c58d094a29904a24aeaba4901044b5b041fb
|
4
|
+
data.tar.gz: 9cce0af02bc2834c600891ea2fd45c2530762d00be97dd28a12d21d7c318cfe2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 750f705edf2a9202ad03f54dfccf1c72f27b17652332d491caae5abb1b8096b964b348a5ee22882b4f590c3d1e3197afbc57efe2512922599195b666cf3e3a04
|
7
|
+
data.tar.gz: 2fd43dba8286d828ab9ee0b9163cc0c39239e5b6caf43ad75082d7df65fe567c0a76729d15f9cc2c6b482ed428846fc41760f4a44613a33bac77b117d3a5daab
|
data/emailage.gemspec
CHANGED
data/lib/emailage/client.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'typhoeus'
|
2
|
-
require '
|
2
|
+
require 'securerandom'
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module Emailage
|
6
6
|
class Client
|
7
7
|
attr_reader :secret, :token, :hmac_key, :sandbox
|
8
8
|
attr_accessor :raise_errors
|
9
|
-
|
9
|
+
|
10
10
|
# @param secret [String] Consumer secret, e.g. SID or API key.
|
11
11
|
# @param token [String] Consumer OAuth token.
|
12
12
|
# @param sandbox [Boolean] Whether to use a sandbox instead of a production server.
|
@@ -18,13 +18,13 @@ module Emailage
|
|
18
18
|
@secret, @token = secret, token
|
19
19
|
@sandbox = options.fetch :sandbox, false
|
20
20
|
@raise_errors = options.fetch :raise_errors, false
|
21
|
-
|
21
|
+
|
22
22
|
# @hmac_key = [@secret, @token].map {|e| CGI.escape(e)}.join '&'
|
23
23
|
@hmac_key = @token + '&'
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
private
|
27
|
-
|
27
|
+
|
28
28
|
# Basic request method utilized by #query and #flag.
|
29
29
|
#
|
30
30
|
# @param endpoint [String] Currently, either an empty string or "/flag".
|
@@ -36,22 +36,22 @@ module Emailage
|
|
36
36
|
base_url = "https://#{@sandbox ? 'sandbox' : 'api'}.emailage.com/emailagevalidator"
|
37
37
|
url = "#{base_url}#{endpoint}/"
|
38
38
|
params = {
|
39
|
-
:format => 'json',
|
39
|
+
:format => 'json',
|
40
40
|
:oauth_consumer_key => @secret,
|
41
|
-
:oauth_nonce =>
|
41
|
+
:oauth_nonce => SecureRandom.uuid,
|
42
42
|
:oauth_signature_method => 'HMAC-SHA1',
|
43
43
|
:oauth_timestamp => Time.now.to_i,
|
44
44
|
:oauth_version => 1.0
|
45
45
|
}.merge(params)
|
46
|
-
|
46
|
+
|
47
47
|
res = Typhoeus.get url, :params => params.merge(:oauth_signature => Signature.create('GET', url, params, @hmac_key))
|
48
|
-
|
48
|
+
|
49
49
|
json = res.body.sub(/^[^{]+/, '')
|
50
50
|
JSON.parse json
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
public
|
54
|
-
|
54
|
+
|
55
55
|
# Query a risk score information for the provided email address, IP address, or a combination.
|
56
56
|
#
|
57
57
|
# @param query [String | Array<String>] Email, IP or a tuple of (Email, IP).
|
@@ -64,7 +64,7 @@ module Emailage
|
|
64
64
|
query *= '+' if query.is_a? Array
|
65
65
|
request '', params.merge(:query => query)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
# Query a risk score information for the provided email address.
|
69
69
|
# This method differs from #query in that it ensures that the string supplied is in rfc2822 format.
|
70
70
|
#
|
@@ -76,7 +76,7 @@ module Emailage
|
|
76
76
|
Validation.validate_email! email
|
77
77
|
query email, params
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
# Query a risk score information for the provided IP address.
|
81
81
|
# This method differs from #query in that it ensures that the string supplied is in rfc791 format.
|
82
82
|
#
|
@@ -88,7 +88,7 @@ module Emailage
|
|
88
88
|
Validation.validate_ip! ip
|
89
89
|
query ip, params
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
# Query a risk score information for the provided combination of an Email and IP address.
|
93
93
|
# This method differs from #query in that it ensures that the strings supplied are in rfc2822 and rfc791 formats.
|
94
94
|
#
|
@@ -102,8 +102,8 @@ module Emailage
|
|
102
102
|
Validation.validate_ip! ip
|
103
103
|
query [email, ip], params
|
104
104
|
end
|
105
|
-
|
106
|
-
|
105
|
+
|
106
|
+
|
107
107
|
# Mark an email address as fraud, good, or neutral.
|
108
108
|
#
|
109
109
|
# @param flag [String] Either fraud, neutral, or good.
|
@@ -118,22 +118,22 @@ module Emailage
|
|
118
118
|
unless flags.include? flag.to_s
|
119
119
|
raise ArgumentError, "flag must be one of #{flags * ', '}. #{flag} is given."
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
122
|
Validation.validate_email! query
|
123
|
-
|
123
|
+
|
124
124
|
query *= '+' if query.is_a? Array
|
125
125
|
params = {:flag => flag, :query => query}
|
126
|
-
|
126
|
+
|
127
127
|
if flag == 'fraud'
|
128
128
|
unless (1..9).to_a.include? fraud_code
|
129
129
|
raise ArgumentError, "fraud_code must be an integer from 1 to 9 corresponding to #{FRAUD_CODES.values*', '}. #{fraud_code} is given."
|
130
130
|
end
|
131
131
|
params[:fraudcodeID] = fraud_code
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
request '/flag', params
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
# Mark an email address as fraud.
|
138
138
|
#
|
139
139
|
# @param query [String] Email to be flagged.
|
@@ -144,7 +144,7 @@ module Emailage
|
|
144
144
|
def flag_as_fraud(query, fraud_code)
|
145
145
|
flag 'fraud', query, fraud_code
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
# Mark an email address as good.
|
149
149
|
#
|
150
150
|
# @param query [String] Email to be flagged.
|
@@ -152,7 +152,7 @@ module Emailage
|
|
152
152
|
def flag_as_good(query)
|
153
153
|
flag 'good', query
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
156
|
# Unflag an email address that was marked as good or fraud previously.
|
157
157
|
#
|
158
158
|
# @param query [String] Email to be flagged.
|
@@ -160,6 +160,6 @@ module Emailage
|
|
160
160
|
def remove_flag(query)
|
161
161
|
flag 'neutral', query
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
end
|
165
165
|
end
|
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.1.
|
4
|
+
version: 1.1.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: 2025-
|
11
|
+
date: 2025-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '1.4'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: uuid
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '2.3'
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '2.3'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: json
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|