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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59b57b0948d78b837e5a3f82a0a0e5c5446742f57e50ebbd2c5b0817f0aabfc5
4
- data.tar.gz: 58ce6a2ac2a9846e5daa63157014cbe0b557f4c94f30c71d9252db8e169cc12f
3
+ metadata.gz: 02e893db37f9960d70d4a0ed17f712ef1e02f13f707d57e7428c3f2b07e36b6d
4
+ data.tar.gz: 7ab4fc1440cc5cd172059f4d2bb53cc51f169f5f21cb7a9bb919d97f04b2b543
5
5
  SHA512:
6
- metadata.gz: 033fe8af379957fdee488fca886d3e3ac4818a7f8587b80554424c7ec824bd9dd1ed949268bc246da1460d0afc449df640cdca8e7bf4fcfbef6790c6c5b1fb1a
7
- data.tar.gz: 9d9ff16f6db49bc2c8791ae46be20dfdc7e5d8e58cc9b603e9e04492b85d97bc0bf48b7933ca46a1362469cba4ca923b35a4444c056699716a15417518454897
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 (3.1.1)
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.2)
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.9.2)
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.12.2)
32
- coderay (~> 1.1.0)
33
- method_source (~> 0.9.0)
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 available in your [Emailable Dashboard](https://app.emailable.com/api). Set `Emailable.api_key` to its value:
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 as well once complete. You can also `results` to get just 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 `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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 release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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 https://github.com/emailable/emailable-ruby.
155
+ Bug reports and pull requests are welcome on GitHub at
156
+ https://github.com/emailable/emailable-ruby.
@@ -2,15 +2,13 @@ module Emailable
2
2
  class Batch
3
3
  attr_accessor :id
4
4
 
5
- def initialize(id_or_emails, callback: nil)
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(simulate: nil)
20
+ def verify(parameters = {})
23
21
  return @id unless @id.nil?
24
22
 
25
- opts = { emails: @emails.join(','), url: @callback, simulate: simulate }
26
- response = @client.request(:post, 'batch', opts)
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(simulate: nil, partial: nil)
29
+ def status(parameters = {})
32
30
  return nil unless @id
33
31
  return @status if @status
34
32
 
35
- body = { id: @id, simulate: simulate, partial: partial }
36
- response = @client.request(:get, 'batch', body)
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, **api_options)
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,3 +1,3 @@
1
1
  module Emailable
2
- VERSION = '3.2.0'
2
+ VERSION = '4.0.0'
3
3
  end
data/lib/emailable.rb CHANGED
@@ -28,13 +28,11 @@ module Emailable
28
28
 
29
29
  module_function
30
30
 
31
- def verify(email, smtp: nil, accept_all: nil, timeout: nil)
32
- opts = {
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', opts)
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: 3.2.0
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-01-17 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler