emailable 3.2.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/README.md +30 -9
- data/lib/emailable/batch.rb +7 -9
- data/lib/emailable/email_validator.rb +1 -1
- data/lib/emailable/version.rb +1 -1
- data/lib/emailable.rb +3 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02e893db37f9960d70d4a0ed17f712ef1e02f13f707d57e7428c3f2b07e36b6d
|
4
|
+
data.tar.gz: 7ab4fc1440cc5cd172059f4d2bb53cc51f169f5f21cb7a9bb919d97f04b2b543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb96ef05631762f2e6fa53e13a621e6006f23af42dba60fa36a86adc978b8b537def118e7547c8af4da8925109a7b671e7cfba4c5eab031a4c874f2e15e64f1d
|
7
|
+
data.tar.gz: c1292e55f4ba32a80da7a30e9d9f401d51f0747d23ccac2f1e8cd336020b9cda45413e7f423eb0b00fee24bb618704e596d20203f8334f532a9d364b97df218f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
emailable (
|
4
|
+
emailable (4.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -17,20 +17,20 @@ GEM
|
|
17
17
|
ansi (1.5.0)
|
18
18
|
awesome_print (1.8.0)
|
19
19
|
builder (3.2.3)
|
20
|
-
coderay (1.1.
|
20
|
+
coderay (1.1.3)
|
21
21
|
concurrent-ruby (1.1.7)
|
22
22
|
i18n (1.8.5)
|
23
23
|
concurrent-ruby (~> 1.0)
|
24
|
-
method_source (0.
|
24
|
+
method_source (1.0.0)
|
25
25
|
minitest (5.11.3)
|
26
26
|
minitest-reporters (1.3.6)
|
27
27
|
ansi
|
28
28
|
builder
|
29
29
|
minitest (>= 5.0)
|
30
30
|
ruby-progressbar
|
31
|
-
pry (0.
|
32
|
-
coderay (~> 1.1
|
33
|
-
method_source (~>
|
31
|
+
pry (0.14.1)
|
32
|
+
coderay (~> 1.1)
|
33
|
+
method_source (~> 1.0)
|
34
34
|
rake (13.0.1)
|
35
35
|
ruby-progressbar (1.10.1)
|
36
36
|
thread_safe (0.3.6)
|
data/README.md
CHANGED
@@ -29,7 +29,9 @@ Or install it yourself as:
|
|
29
29
|
|
30
30
|
## Usage
|
31
31
|
|
32
|
-
The library needs to be configured with your account's API key which is
|
32
|
+
The library needs to be configured with your account's API key which is
|
33
|
+
available in your [Emailable Dashboard](https://app.emailable.com/api). Set
|
34
|
+
`Emailable.api_key` to its value:
|
33
35
|
|
34
36
|
### Setup
|
35
37
|
|
@@ -47,6 +49,9 @@ Emailable.api_key = 'live_...'
|
|
47
49
|
Emailable.verify('jarrett@emailable.com')
|
48
50
|
```
|
49
51
|
|
52
|
+
All supported parameters for the verify endpoint can be passed in as hash
|
53
|
+
arguments to the `verify` method.
|
54
|
+
|
50
55
|
#### Slow Email Server Handling
|
51
56
|
|
52
57
|
Some email servers are slow to respond. As a result, the timeout may be reached
|
@@ -60,23 +65,29 @@ email `slow@example.com`.
|
|
60
65
|
|
61
66
|
### Batch Verification
|
62
67
|
|
68
|
+
First, create an `Emailable::Batch` object. Then, call the `verify` method to
|
69
|
+
start the batch. All supported parameters for the batch verification endpoint
|
70
|
+
can be passed in as hash arguments to the `verify` method.
|
71
|
+
|
63
72
|
#### Start a batch
|
64
73
|
|
65
74
|
```ruby
|
66
75
|
emails = ['jarrett@emailable.com', 'support@emailable.com', ...]
|
67
76
|
batch = Emailable::Batch.new(emails)
|
68
77
|
|
69
|
-
# you can optionally pass in a callback url that we'll POST to when the
|
70
|
-
# batch is complete.
|
71
|
-
batch = Emailable::Batch.new(emails, callback: 'https://emailable.com/')
|
72
|
-
|
73
78
|
# start verifying the batch
|
74
79
|
batch.verify
|
80
|
+
|
81
|
+
# you can optionally pass in a callback url that we'll POST to when the batch
|
82
|
+
# is complete.
|
83
|
+
batch.verify(url: 'https://emailable.com/')
|
75
84
|
```
|
76
85
|
|
77
86
|
#### Get the status / results of a batch
|
78
87
|
|
79
|
-
Calling `status` on a batch will return the status. It will contain the results
|
88
|
+
Calling `status` on a batch will return the status. It will contain the results
|
89
|
+
as well once complete. All supported parameters for the status endpoint can be
|
90
|
+
passed in as hash arguments to the `status` method.
|
80
91
|
|
81
92
|
```ruby
|
82
93
|
id = '5cfcbfdeede34200693c4319'
|
@@ -85,6 +96,9 @@ batch = Emailable::Batch.new(id)
|
|
85
96
|
# get status of batch
|
86
97
|
batch.status
|
87
98
|
|
99
|
+
# get the status of a batch, with partial results if the batch is incomplete
|
100
|
+
batch.status(partial: true)
|
101
|
+
|
88
102
|
# gets the results
|
89
103
|
batch.status.emails
|
90
104
|
|
@@ -126,10 +140,17 @@ attr_accessor :email_verification_result
|
|
126
140
|
|
127
141
|
## Development
|
128
142
|
|
129
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
143
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
144
|
+
`rake test` to run the tests. You can also run `bin/console` for an interactive
|
145
|
+
prompt that will allow you to experiment.
|
130
146
|
|
131
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
147
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
148
|
+
release a new version, update the version number in `version.rb`, and then run
|
149
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
150
|
+
git commits and tags, and push the `.gem` file to
|
151
|
+
[rubygems.org](https://rubygems.org).
|
132
152
|
|
133
153
|
## Contributing
|
134
154
|
|
135
|
-
Bug reports and pull requests are welcome on GitHub at
|
155
|
+
Bug reports and pull requests are welcome on GitHub at
|
156
|
+
https://github.com/emailable/emailable-ruby.
|
data/lib/emailable/batch.rb
CHANGED
@@ -2,15 +2,13 @@ module Emailable
|
|
2
2
|
class Batch
|
3
3
|
attr_accessor :id
|
4
4
|
|
5
|
-
def initialize(id_or_emails
|
5
|
+
def initialize(id_or_emails)
|
6
6
|
if id_or_emails.is_a?(Array)
|
7
7
|
@id = nil
|
8
8
|
@emails = id_or_emails
|
9
|
-
@callback = callback
|
10
9
|
elsif id_or_emails.is_a?(String)
|
11
10
|
@id = id_or_emails
|
12
11
|
@emails = nil
|
13
|
-
@callback = nil
|
14
12
|
else
|
15
13
|
raise ArgumentError, 'expected an array of emails or batch id'
|
16
14
|
end
|
@@ -19,21 +17,21 @@ module Emailable
|
|
19
17
|
@status = nil
|
20
18
|
end
|
21
19
|
|
22
|
-
def verify(
|
20
|
+
def verify(parameters = {})
|
23
21
|
return @id unless @id.nil?
|
24
22
|
|
25
|
-
|
26
|
-
response = @client.request(:post, 'batch',
|
23
|
+
parameters[:emails] = @emails.join(',')
|
24
|
+
response = @client.request(:post, 'batch', parameters)
|
27
25
|
|
28
26
|
@id = response.body['id']
|
29
27
|
end
|
30
28
|
|
31
|
-
def status(
|
29
|
+
def status(parameters = {})
|
32
30
|
return nil unless @id
|
33
31
|
return @status if @status
|
34
32
|
|
35
|
-
|
36
|
-
response = @client.request(:get, 'batch',
|
33
|
+
parameters[:id] = @id
|
34
|
+
response = @client.request(:get, 'batch', parameters)
|
37
35
|
bs = BatchStatus.new(response.body)
|
38
36
|
@status = bs if bs.complete?
|
39
37
|
|
@@ -38,7 +38,7 @@ class EmailValidator < ActiveModel::EachValidator
|
|
38
38
|
|
39
39
|
api_options = { timeout: timeout, smtp: smtp }
|
40
40
|
api_options[:accept_all] = true unless accept_all
|
41
|
-
ev = Emailable.verify(value,
|
41
|
+
ev = Emailable.verify(value, api_options)
|
42
42
|
|
43
43
|
result_accessor = "#{attribute}_verification_result"
|
44
44
|
if record.respond_to?(result_accessor)
|
data/lib/emailable/version.rb
CHANGED
data/lib/emailable.rb
CHANGED
@@ -28,13 +28,11 @@ module Emailable
|
|
28
28
|
|
29
29
|
module_function
|
30
30
|
|
31
|
-
def verify(email,
|
32
|
-
|
33
|
-
email: email, smtp: smtp, accept_all: accept_all, timeout: timeout
|
34
|
-
}
|
31
|
+
def verify(email, parameters = {})
|
32
|
+
parameters[:email] = email
|
35
33
|
|
36
34
|
client = Emailable::Client.new
|
37
|
-
response = client.request(:get, 'verify',
|
35
|
+
response = client.request(:get, 'verify', parameters)
|
38
36
|
|
39
37
|
if response.status == 249
|
40
38
|
raise Emailable::TimeoutError.new(response.body)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emailable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emailable
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|