emailable 3.1.1 → 4.0.1
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 +31 -9
- data/lib/emailable/batch.rb +8 -9
- data/lib/emailable/email_validator.rb +1 -1
- data/lib/emailable/resources/batch_status.rb +2 -2
- data/lib/emailable/version.rb +1 -1
- data/lib/emailable.rb +3 -5
- data/test/emailable/batch_test.rb +1 -2
- 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: a16092a97f3a44d6367dd6f43c6d2ca0ef865b4f4d72f128fc5e0ed9af61690d
|
4
|
+
data.tar.gz: 193b812579bd58486dccc1b96b27a6be94a08ba95292393c5f76e15787cbb8a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12d8fea5456e9a845f14fa8e06beb91503a4589890b82aeb00f519d3474a2d9952efd480c0ff89d36018bed4623a9614a92b4e1617dee84fc3ae4e472c6ac9c8
|
7
|
+
data.tar.gz: d3b50438805d55f28d8c072ce578a4431a848054a38d1a2881dc7696636bce59d1b6b93bd56d175f00e95d1a7c12330bee7c9d4bafaa2f7032c75f90437bdb4c
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
emailable (
|
4
|
+
emailable (4.0.1)
|
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
@@ -1,5 +1,6 @@
|
|
1
1
|
# Emailable Ruby Library
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/emailable.svg)](https://rubygems.org/gems/emailable)
|
3
4
|
[![Build Status](https://app.travis-ci.com/emailable/emailable-ruby.svg)](https://app.travis-ci.com/emailable/emailable-ruby)
|
4
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/e7eef54e491adec95e6d/maintainability)](https://codeclimate.com/github/emailable/emailable-ruby/maintainability)
|
5
6
|
|
@@ -29,7 +30,9 @@ Or install it yourself as:
|
|
29
30
|
|
30
31
|
## Usage
|
31
32
|
|
32
|
-
The library needs to be configured with your account's API key which is
|
33
|
+
The library needs to be configured with your account's API key which is
|
34
|
+
available in your [Emailable Dashboard](https://app.emailable.com/api). Set
|
35
|
+
`Emailable.api_key` to its value:
|
33
36
|
|
34
37
|
### Setup
|
35
38
|
|
@@ -47,6 +50,9 @@ Emailable.api_key = 'live_...'
|
|
47
50
|
Emailable.verify('jarrett@emailable.com')
|
48
51
|
```
|
49
52
|
|
53
|
+
All supported parameters for the verify endpoint can be passed in as hash
|
54
|
+
arguments to the `verify` method.
|
55
|
+
|
50
56
|
#### Slow Email Server Handling
|
51
57
|
|
52
58
|
Some email servers are slow to respond. As a result, the timeout may be reached
|
@@ -60,23 +66,29 @@ email `slow@example.com`.
|
|
60
66
|
|
61
67
|
### Batch Verification
|
62
68
|
|
69
|
+
First, create an `Emailable::Batch` object. Then, call the `verify` method to
|
70
|
+
start the batch. All supported parameters for the batch verification endpoint
|
71
|
+
can be passed in as hash arguments to the `verify` method.
|
72
|
+
|
63
73
|
#### Start a batch
|
64
74
|
|
65
75
|
```ruby
|
66
76
|
emails = ['jarrett@emailable.com', 'support@emailable.com', ...]
|
67
77
|
batch = Emailable::Batch.new(emails)
|
68
78
|
|
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
79
|
# start verifying the batch
|
74
80
|
batch.verify
|
81
|
+
|
82
|
+
# you can optionally pass in a callback url that we'll POST to when the batch
|
83
|
+
# is complete.
|
84
|
+
batch.verify(url: 'https://emailable.com/')
|
75
85
|
```
|
76
86
|
|
77
87
|
#### Get the status / results of a batch
|
78
88
|
|
79
|
-
Calling `status` on a batch will return the status. It will contain the results
|
89
|
+
Calling `status` on a batch will return the status. It will contain the results
|
90
|
+
as well once complete. All supported parameters for the status endpoint can be
|
91
|
+
passed in as hash arguments to the `status` method.
|
80
92
|
|
81
93
|
```ruby
|
82
94
|
id = '5cfcbfdeede34200693c4319'
|
@@ -85,6 +97,9 @@ batch = Emailable::Batch.new(id)
|
|
85
97
|
# get status of batch
|
86
98
|
batch.status
|
87
99
|
|
100
|
+
# get the status of a batch, with partial results if the batch is incomplete
|
101
|
+
batch.status(partial: true)
|
102
|
+
|
88
103
|
# gets the results
|
89
104
|
batch.status.emails
|
90
105
|
|
@@ -126,10 +141,17 @@ attr_accessor :email_verification_result
|
|
126
141
|
|
127
142
|
## Development
|
128
143
|
|
129
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
144
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
145
|
+
`rake test` to run the tests. You can also run `bin/console` for an interactive
|
146
|
+
prompt that will allow you to experiment.
|
130
147
|
|
131
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
148
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
149
|
+
release a new version, update the version number in `version.rb`, and then run
|
150
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
151
|
+
git commits and tags, and push the `.gem` file to
|
152
|
+
[rubygems.org](https://rubygems.org).
|
132
153
|
|
133
154
|
## Contributing
|
134
155
|
|
135
|
-
Bug reports and pull requests are welcome on GitHub at
|
156
|
+
Bug reports and pull requests are welcome on GitHub at
|
157
|
+
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,20 +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
|
-
|
33
|
+
parameters[:id] = @id
|
34
|
+
response = @client.request(:get, 'batch', parameters)
|
36
35
|
bs = BatchStatus.new(response.body)
|
37
36
|
@status = bs if bs.complete?
|
38
37
|
|
@@ -40,7 +39,7 @@ module Emailable
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def complete?
|
43
|
-
|
42
|
+
status.complete?
|
44
43
|
end
|
45
44
|
|
46
45
|
def inspect
|
@@ -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)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Emailable
|
2
2
|
class BatchStatus < APIResource
|
3
3
|
attr_accessor :emails, :id, :message, :reason_counts, :total_counts,
|
4
|
-
:processed, :total
|
4
|
+
:processed, :total, :download_file
|
5
5
|
|
6
6
|
def complete?
|
7
|
-
|
7
|
+
message.include?('completed')
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emailable
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|