emailable 3.1.1 → 4.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90f1d586f58f97cf11f78a6dac64fa169e9ff0d1a2902a4f5df86a32f9d16dae
4
- data.tar.gz: 20e10632676d8374b41048c9324fe879c5da2cc0841a71ae9bf920ea752abc58
3
+ metadata.gz: a16092a97f3a44d6367dd6f43c6d2ca0ef865b4f4d72f128fc5e0ed9af61690d
4
+ data.tar.gz: 193b812579bd58486dccc1b96b27a6be94a08ba95292393c5f76e15787cbb8a1
5
5
  SHA512:
6
- metadata.gz: 644ea041fc96995db1c0121be0b494f1cbea6df42dbbf691afebce236ce567a5db4ee87d34bf222dc26e244a4624777ca8a08a4df899a980050902403a31a7e0
7
- data.tar.gz: 54b5b43f725562bcae4a38385b70a9ff61e74c4fbe74200b288d1112ed7b640eea2326c618ea8f1adf815f5aad42ef69982029f70f7246bbf55746bfe752435f
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 (3.1.1)
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.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
@@ -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 available in your [Emailable Dashboard](https://app.emailable.com/api). Set `Emailable.api_key` to its value:
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 as well once complete. You can also `results` to get just 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 `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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 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).
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 https://github.com/emailable/emailable-ruby.
156
+ Bug reports and pull requests are welcome on GitHub at
157
+ 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,20 +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)
29
+ def status(parameters = {})
32
30
  return nil unless @id
33
31
  return @status if @status
34
32
 
35
- response = @client.request(:get, 'batch', { id: @id, simulate: simulate })
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
- !status.complete?
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, **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,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
- !emails.nil?
7
+ message.include?('completed')
8
8
  end
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Emailable
2
- VERSION = '3.1.1'
2
+ VERSION = '4.0.1'
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)
@@ -22,8 +22,7 @@ module Emailable
22
22
  end
23
23
 
24
24
  def test_batch_complete
25
- complete = @batch.complete?
26
- assert complete == true || complete == false
25
+ assert @batch.complete?
27
26
  end
28
27
 
29
28
  end
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.1.1
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: 2021-11-23 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler