neverbounce-api 1.0.1 → 1.2.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
- SHA1:
3
- metadata.gz: cf9fa5763f319e8fc240af66e7be1809b427ac5e
4
- data.tar.gz: d960426232862d34bdd040d444627059fa63217a
2
+ SHA256:
3
+ metadata.gz: 2f9d774a33fd7d97b58da965a0aaa4479ecd2051121d94b103eb9b79dea2b840
4
+ data.tar.gz: 9a25032152f3cd29bf9f1a35e59a41f6a7c3f52e56829f2c5449953e925683e2
5
5
  SHA512:
6
- metadata.gz: 7536bf00e5a1fd3fe82e139be0e361eb2adcc2e9729ec810b4fad6174fc40dac12ed56faa5e7b2a9ba2ebe52578a6269e1b134e83b8c81b497150293441cc019
7
- data.tar.gz: 2a30f1057d9e26ea5785f992cc37edd17d560367998085a158ad204d79f4ac9a113f2c1eea17b763ccc0ae718b8e50eb0c30cb406e64933d09988e204f96c70f
6
+ metadata.gz: a6675271c6f4aec84f635a0b6c0f20207f217e4be96cfc64957feae519f1ad0c6fb5d6d15cd80f63d73a8de842917399bb0230afae444ff0ea4203dcf5396ce0
7
+ data.tar.gz: 73b51b37c0a7ed257c3b7548cd2b3b771483261a2a9cb61a818e91b3442a378f096c0b229d83f703b064b911e8b8f6a913c3fa4a3bcc436333a3e0e0be136bbc
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /tmp/*
9
9
  /vendor/bundle/
10
10
  /.yardoc/
11
+ *.gem
11
12
 
12
13
  # Project-specific.
13
14
  /lib/lib_local.rb
@@ -18,4 +19,4 @@
18
19
  *.old*
19
20
  *.orig
20
21
  /*.patch
21
- *.ref*
22
+ *.ref*
@@ -5,7 +5,11 @@ env:
5
5
  global:
6
6
  - CC_TEST_REPORTER_ID=9300cb7898e254e78099399acbb2796471fde0e5c1873899273a583d56c9d740
7
7
 
8
+ before_install:
9
+ - gem install bundler
10
+
8
11
  install:
12
+ - bundle update --bundler
9
13
  - bundle install --path ~/bundle
10
14
 
11
15
  before_script:
@@ -20,8 +24,7 @@ after_script:
20
24
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
21
25
 
22
26
  rvm:
23
- - 2.0
24
- - 2.1
25
- - 2.2
26
- - 2.3
27
27
  - 2.4
28
+ - 2.5
29
+ - 2.6
30
+ - 2.7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neverbounce-api (1.0.1)
4
+ neverbounce-api (1.1.0)
5
5
  httparty (~> 0.15)
6
6
 
7
7
  GEM
@@ -9,30 +9,30 @@ GEM
9
9
  specs:
10
10
  diff-lcs (1.3)
11
11
  docile (1.1.5)
12
- httparty (0.15.6)
12
+ httparty (0.16.2)
13
13
  multi_xml (>= 0.5.2)
14
14
  json (2.1.0)
15
15
  multi_xml (0.6.0)
16
16
  redcarpet (3.4.0)
17
- rspec (3.6.0)
18
- rspec-core (~> 3.6.0)
19
- rspec-expectations (~> 3.6.0)
20
- rspec-mocks (~> 3.6.0)
21
- rspec-core (3.6.0)
22
- rspec-support (~> 3.6.0)
23
- rspec-expectations (3.6.0)
17
+ rspec (3.7.0)
18
+ rspec-core (~> 3.7.0)
19
+ rspec-expectations (~> 3.7.0)
20
+ rspec-mocks (~> 3.7.0)
21
+ rspec-core (3.7.0)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-expectations (3.7.0)
24
24
  diff-lcs (>= 1.2.0, < 2.0)
25
- rspec-support (~> 3.6.0)
26
- rspec-mocks (3.6.0)
25
+ rspec-support (~> 3.7.0)
26
+ rspec-mocks (3.7.0)
27
27
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.6.0)
29
- rspec-support (3.6.0)
30
- simplecov (0.15.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-support (3.7.0)
30
+ simplecov (0.15.1)
31
31
  docile (~> 1.1.0)
32
32
  json (>= 1.8, < 3)
33
33
  simplecov-html (~> 0.10.0)
34
34
  simplecov-html (0.10.2)
35
- yard (0.9.9)
35
+ yard (0.9.12)
36
36
 
37
37
  PLATFORMS
38
38
  ruby
data/README.md CHANGED
@@ -48,7 +48,7 @@ To talk to the API, create a `Client` object and call one of its request methods
48
48
  For example, let's get account info:
49
49
 
50
50
  ```ruby
51
- client = NeverBounce::API::Client.new(api_key: "key123abc") # Insert YOUR key here.
51
+ client = NeverBounce::API::Client.new(api_key: "secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") # Insert YOUR key here.
52
52
  resp = client.account_info
53
53
 
54
54
  if resp.ok?
@@ -60,6 +60,8 @@ else
60
60
  end
61
61
  ```
62
62
 
63
+ >**The API username and secret key used to authenticate V3 API requests will not work to authenticate V4 API requests.** If you are attempting to authenticate your request with the 8 character username or 12-16 character secret key the request will return an `auth_failure` error. The API key used for the V4 API will look like the following: `secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`. To create new V4 API credentials please go [here](https://app.neverbounce.com/apps/custom-integration/new).
64
+
63
65
  Now, let's check a single e-mail:
64
66
 
65
67
  ```ruby
@@ -37,7 +37,7 @@ module NeverBounce; module API
37
37
  Feature::BasicInitialize.load(self)
38
38
  Feature::RequireAttr.load(self)
39
39
 
40
- attr_writer :api_key
40
+ attr_writer :api_key, :api_version
41
41
 
42
42
  # API key.
43
43
  # @return [String]
@@ -45,6 +45,12 @@ module NeverBounce; module API
45
45
  @api_key or raise AttributeError, "Attribute must be set: api_key"
46
46
  end
47
47
 
48
+ # API version.
49
+ # @return [String]
50
+ def api_version
51
+ @api_version
52
+ end
53
+
48
54
  #--------------------------------------- Misc
49
55
 
50
56
  # Wrap request in a session, return response.
@@ -67,6 +73,7 @@ module NeverBounce; module API
67
73
  def account_info
68
74
  response_to(Request::AccountInfo.new({
69
75
  api_key: api_key,
76
+ api_version: api_version,
70
77
  }))
71
78
  end
72
79
 
@@ -83,7 +90,7 @@ module NeverBounce; module API
83
90
  # @raise [StandardError]
84
91
  # @see Request::JobsCreate
85
92
  # @see https://developers.neverbounce.com/v4.0/reference#jobs-create
86
- def jobs_create(auto_parse: nil, auto_start: nil, filename: nil, remote_input: nil, run_sample: nil, supplied_input: nil)
93
+ def jobs_create(auto_parse: false, auto_start: false, filename: nil, remote_input: nil, run_sample: false, supplied_input: nil, historical: nil)
87
94
  raise ArgumentError, "`remote_input` and `supplied_input` can't both be given" if remote_input && supplied_input
88
95
 
89
96
  input_location = if (v = remote_input)
@@ -102,12 +109,14 @@ module NeverBounce; module API
102
109
 
103
110
  response_to(API::Request::JobsCreate.new({
104
111
  api_key: api_key,
112
+ api_version: api_version,
105
113
  auto_parse: auto_parse,
106
114
  auto_start: auto_start,
107
115
  filename: filename,
108
116
  input: input,
109
117
  input_location: input_location,
110
118
  run_sample: run_sample,
119
+ historical: historical,
111
120
  }))
112
121
  end
113
122
 
@@ -122,6 +131,7 @@ module NeverBounce; module API
122
131
  def jobs_delete(job_id: nil)
123
132
  response_to(Request::JobsDelete.new({
124
133
  api_key: api_key,
134
+ api_version: api_version,
125
135
  job_id: job_id,
126
136
  }))
127
137
  end
@@ -137,6 +147,7 @@ module NeverBounce; module API
137
147
  def jobs_download(job_id: nil)
138
148
  response_to(Request::JobsDownload.new({
139
149
  api_key: api_key,
150
+ api_version: api_version,
140
151
  job_id: job_id,
141
152
  }))
142
153
  end
@@ -153,6 +164,7 @@ module NeverBounce; module API
153
164
  def jobs_parse(auto_start: nil, job_id: nil)
154
165
  response_to(Request::JobsParse.new({
155
166
  api_key: api_key,
167
+ api_version: api_version,
156
168
  auto_start: auto_start,
157
169
  job_id: job_id,
158
170
  }))
@@ -171,6 +183,7 @@ module NeverBounce; module API
171
183
  def jobs_results(job_id: nil, page: 1, per_page: nil)
172
184
  response_to(Request::JobsResults.new({
173
185
  api_key: api_key,
186
+ api_version: api_version,
174
187
  job_id: job_id,
175
188
  page: page,
176
189
  per_page: per_page,
@@ -190,6 +203,7 @@ module NeverBounce; module API
190
203
  def jobs_search(job_id: nil, page: 1, per_page: nil)
191
204
  response_to(Request::JobsSearch.new({
192
205
  api_key: api_key,
206
+ api_version: api_version,
193
207
  job_id: job_id,
194
208
  page: page,
195
209
  per_page: per_page,
@@ -208,6 +222,7 @@ module NeverBounce; module API
208
222
  def jobs_start(job_id: nil, run_sample: nil)
209
223
  response_to(Request::JobsStart.new({
210
224
  api_key: api_key,
225
+ api_version: api_version,
211
226
  job_id: job_id,
212
227
  run_sample: run_sample,
213
228
  }))
@@ -224,6 +239,7 @@ module NeverBounce; module API
224
239
  def jobs_status(job_id: nil)
225
240
  response_to(Request::JobsStatus.new({
226
241
  api_key: api_key,
242
+ api_version: api_version,
227
243
  job_id: job_id,
228
244
  }))
229
245
  end
@@ -239,13 +255,15 @@ module NeverBounce; module API
239
255
  # @raise [StandardError]
240
256
  # @see Request::SingleCheck
241
257
  # @see https://developers.neverbounce.com/v4.0/reference#single-check
242
- def single_check(address_info: nil, credits_info: nil, email: nil, timeout: nil)
258
+ def single_check(address_info: nil, credits_info: nil, email: nil, timeout: nil, historical: nil)
243
259
  response_to(Request::SingleCheck.new({
244
260
  address_info: address_info,
245
261
  api_key: api_key,
262
+ api_version: api_version,
246
263
  credits_info: credits_info,
247
264
  email: email,
248
265
  timeout: timeout,
266
+ historical: historical,
249
267
  }))
250
268
  end
251
269
 
@@ -263,6 +281,7 @@ module NeverBounce; module API
263
281
  def poe_confirm(email: nil, transaction_id: nil, confirmation_token: nil, result: nil)
264
282
  response_to(Request::POEConfirm.new({
265
283
  api_key: api_key,
284
+ api_version: api_version,
266
285
  email: email,
267
286
  transaction_id: transaction_id,
268
287
  confirmation_token: confirmation_token,
@@ -12,12 +12,18 @@ module NeverBounce; module API; module Request
12
12
  # User's API key.
13
13
  # @return [String]
14
14
  attr_accessor :api_key
15
- attr_writer :api_url, :headers, :user_agent
15
+ attr_writer :api_url, :headers, :user_agent, :api_version
16
16
 
17
- # Custom API URL. Default is <tt>https://api.neverbounce.com/v4</tt>.
17
+ # Custom API URL. Default is <tt>https://api.neverbounce.com</tt>.
18
18
  # @return [String]
19
19
  def api_url
20
- @api_url ||= "https://api.neverbounce.com/v4"
20
+ @api_url ||= "https://api.neverbounce.com"
21
+ end
22
+
23
+ # Custom API URL. Default is <tt>https://api.neverbounce.com</tt>.
24
+ # @return [String]
25
+ def api_version
26
+ @api_version ||= "v4.2"
21
27
  end
22
28
 
23
29
  # @!attribute headers
@@ -57,7 +63,7 @@ module NeverBounce; module API; module Request
57
63
  @curl ||= begin
58
64
  ar = [
59
65
  "--request", self.class.http_method.to_s.upcase,
60
- "--url", "#{api_url}/#{self.class.path}",
66
+ "--url", "#{api_url}/#{api_version}/#{self.class.path}",
61
67
  ]
62
68
 
63
69
  ar += headers.reject { |k,| k == "User-Agent" }.flat_map do |k, v|
@@ -82,7 +88,7 @@ module NeverBounce; module API; module Request
82
88
  def to_httparty
83
89
  [
84
90
  self.class.http_method, # E.g. `:get`.
85
- "#{api_url}/#{self.class.path}",
91
+ "#{api_url}/#{api_version}/#{self.class.path}",
86
92
  {
87
93
  body: to_h.to_json,
88
94
  headers: headers,
@@ -23,6 +23,22 @@ module NeverBounce; module API; module Request
23
23
  # @return [Boolean]
24
24
  attr_accessor :run_sample
25
25
 
26
+ # @return [Boolean]
27
+ attr_accessor :historical
28
+
29
+ # @return [Boolean]
30
+ attr_accessor :allow_manual_review
31
+
32
+ # @return [String]
33
+ attr_accessor :callback_url
34
+
35
+ # @return [Hash]
36
+ attr_accessor :callback_headers
37
+
38
+ def leverage_historical
39
+ defined?(@historical) ? @historical : true
40
+ end
41
+
26
42
  # @return [Symbol]
27
43
  def self.http_method
28
44
  :post
@@ -53,6 +69,22 @@ module NeverBounce; module API; module Request
53
69
  unless (v = run_sample).nil?
54
70
  _[:run_sample] = v
55
71
  end
72
+
73
+ unless (v = allow_manual_review).nil?
74
+ _[:allow_manual_review] = v
75
+ end
76
+
77
+ unless (v = callback_url).nil?
78
+ _[:callback_url] = v
79
+ end
80
+
81
+ unless (v = callback_headers).nil?
82
+ _[:callback_headers] = v
83
+ end
84
+
85
+ unless historical.nil?
86
+ _[:request_meta_data] = {leverage_historical_data: leverage_historical}
87
+ end
56
88
  end
57
89
  end
58
90
 
@@ -11,6 +11,9 @@ module NeverBounce; module API; module Request
11
11
  # @return [Boolean]
12
12
  attr_accessor :run_sample
13
13
 
14
+ # @return [Boolean]
15
+ attr_accessor :allow_manual_review
16
+
14
17
  # @return [Symbol]
15
18
  def self.http_method
16
19
  :post
@@ -33,6 +36,10 @@ module NeverBounce; module API; module Request
33
36
  unless (v = run_sample).nil?
34
37
  _[:run_sample] = v
35
38
  end
39
+
40
+ unless (v = allow_manual_review).nil?
41
+ _[:allow_manual_review] = v
42
+ end
36
43
  end
37
44
  end
38
45
 
@@ -17,6 +17,13 @@ module NeverBounce; module API; module Request
17
17
  # @return [Integer]
18
18
  attr_accessor :timeout
19
19
 
20
+ # @return [Boolean]
21
+ attr_accessor :historical
22
+
23
+ def leverage_historical
24
+ defined?(@historical) ? @historical : true
25
+ end
26
+
20
27
  # @return [Symbol]
21
28
  def self.http_method
22
29
  :get
@@ -47,6 +54,10 @@ module NeverBounce; module API; module Request
47
54
  unless (v = timeout).nil?
48
55
  _[:timeout] = v
49
56
  end
57
+
58
+ unless historical.nil?
59
+ _[:request_meta_data] = {leverage_historical_data: leverage_historical}
60
+ end
50
61
  end
51
62
  end
52
63
 
@@ -23,13 +23,14 @@ module NeverBounce; module API; module Response; module Feature
23
23
 
24
24
  oattr :bounce_estimate, :scalar, type: :float
25
25
  oattr :filename, :scalar
26
- oattr :percent_complete, :scalar, type: :integer
26
+ oattr :percent_complete, :scalar, type: :float
27
27
 
28
28
  oattr :total, :writer
29
29
 
30
30
  oattr :created_at, :scalar
31
31
  oattr :finished_at, :scalar
32
32
  oattr :started_at, :scalar
33
+ oattr :failure_reason, :scalar
33
34
  end
34
35
  end
35
36
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module NeverBounce; module API
3
- VERSION = "1.0.1"
3
+ VERSION = "1.2.0"
4
4
  end; end
@@ -14,6 +14,16 @@ module NeverBounce; module API
14
14
  expect(r.api_key).to eq "api_key"
15
15
  end
16
16
  end
17
+
18
+ describe "#api_version" do
19
+ it "generally works" do
20
+ r = newo
21
+ r.api_key = "api_key"
22
+ expect(r.api_version).to eq nil
23
+ r.api_version = "api_version"
24
+ expect(r.api_version).to eq "api_version"
25
+ end
26
+ end
17
27
  end # describe "attributes"
18
28
 
19
29
  describe "requests" do
@@ -19,7 +19,7 @@ module NeverBounce; module API; module Request
19
19
  expect(res).to be_a Array
20
20
  method, url, data = res
21
21
  expect(method).to eq :get
22
- expect(url).to eq "https://api.neverbounce.com/v4/account/info"
22
+ expect(url).to eq "https://api.neverbounce.com/v4.2/account/info"
23
23
  expect(data).to include(:body, :headers)
24
24
  expect(data.fetch(:body)).to eq "{\"key\":\"api_key\"}"
25
25
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
@@ -9,12 +9,20 @@ module NeverBounce; module API; module Request
9
9
  it "generally works" do
10
10
  r = newo()
11
11
  expect(r.mode_h).to eq({})
12
- r = newo(auto_start: nil, auto_parse: nil, run_sample: nil)
12
+ r = newo(auto_start: nil, auto_parse: nil, run_sample: nil, allow_manual_review: nil)
13
13
  expect(r.mode_h).to eq({})
14
14
  r = newo(auto_start: false, auto_parse: false, run_sample: false)
15
15
  expect(r.mode_h).to eq({auto_start: false, auto_parse: false, run_sample: false})
16
16
  r = newo(auto_start: true, auto_parse: true, run_sample: true)
17
17
  expect(r.mode_h).to eq({auto_start: true, auto_parse: true, run_sample: true})
18
+ r = newo(historical: true)
19
+ expect(r.mode_h).to eq({request_meta_data: {leverage_historical_data: true}})
20
+ r = newo(historical: false)
21
+ expect(r.mode_h).to eq({request_meta_data: {leverage_historical_data: false}})
22
+ r = newo(allow_manual_review: true, callback_url: "http://test.com", callback_headers: {:Authorization => "Basic test"})
23
+ expect(r.mode_h).to eq({allow_manual_review: true, callback_url: "http://test.com", callback_headers: {:Authorization => "Basic test"}})
24
+ r = newo(allow_manual_review: false, callback_url: nil, callback_headers: nil)
25
+ expect(r.mode_h).to eq({allow_manual_review: false})
18
26
  end
19
27
  end
20
28
 
@@ -79,11 +87,82 @@ module NeverBounce; module API; module Request
79
87
  expect(res).to be_a Array
80
88
  method, url, data = res
81
89
  expect(method).to eq :post
82
- expect(url).to eq "https://api.neverbounce.com/v4/jobs/create"
90
+ expect(url).to eq "https://api.neverbounce.com/v4.2/jobs/create"
83
91
  expect(data).to include(:body, :headers)
84
92
  expect(data.fetch(:body)).to eq "{\"input\":\"input\",\"input_location\":\"remote_url\",\"filename\":\"filename\",\"key\":\"api_key\"}"
85
93
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
86
94
  end
95
+
96
+ it "allows historical to be disabled" do
97
+ r = newo
98
+ r.input = "input"
99
+ r.input_location = "remote_url"
100
+ r.filename = "filename"
101
+ r.api_key = "api_key"
102
+ r.historical = false
103
+
104
+ res = r.to_httparty
105
+ expect(res).to be_a Array
106
+ method, url, data = res
107
+ expect(data.fetch(:body)).to eq "{\"input\":\"input\",\"input_location\":\"remote_url\",\"filename\":\"filename\",\"key\":\"api_key\",\"request_meta_data\":{\"leverage_historical_data\":false}}"
108
+ end
109
+
110
+ it "allows historical to be explicitly enabled" do
111
+ r = newo
112
+ r.input = "input"
113
+ r.input_location = "remote_url"
114
+ r.filename = "filename"
115
+ r.api_key = "api_key"
116
+ r.historical = true
117
+
118
+ res = r.to_httparty
119
+ expect(res).to be_a Array
120
+ method, url, data = res
121
+ expect(data.fetch(:body)).to eq "{\"input\":\"input\",\"input_location\":\"remote_url\",\"filename\":\"filename\",\"key\":\"api_key\",\"request_meta_data\":{\"leverage_historical_data\":true}}"
122
+ end
123
+
124
+ it "allows allow manual review parameter to be enabled" do
125
+ r = newo
126
+ r.input = "input"
127
+ r.input_location = "remote_url"
128
+ r.filename = "filename"
129
+ r.api_key = "api_key"
130
+ r.allow_manual_review = true
131
+
132
+ res = r.to_httparty
133
+ expect(res).to be_a Array
134
+ method, url, data = res
135
+ expect(data.fetch(:body)).to eq "{\"input\":\"input\",\"input_location\":\"remote_url\",\"filename\":\"filename\",\"key\":\"api_key\",\"allow_manual_review\":true}"
136
+ end
137
+
138
+ it "allows allow manual review parameter to be disabled" do
139
+ r = newo
140
+ r.input = "input"
141
+ r.input_location = "remote_url"
142
+ r.filename = "filename"
143
+ r.api_key = "api_key"
144
+ r.allow_manual_review = false
145
+
146
+ res = r.to_httparty
147
+ expect(res).to be_a Array
148
+ method, url, data = res
149
+ expect(data.fetch(:body)).to eq "{\"input\":\"input\",\"input_location\":\"remote_url\",\"filename\":\"filename\",\"key\":\"api_key\",\"allow_manual_review\":false}"
150
+ end
151
+
152
+ it "allows callback url and headers" do
153
+ r = newo
154
+ r.input = "input"
155
+ r.input_location = "remote_url"
156
+ r.filename = "filename"
157
+ r.api_key = "api_key"
158
+ r.callback_url = "http://test.com"
159
+ r.callback_headers = {:Authorization => "Basic test"}
160
+
161
+ res = r.to_httparty
162
+ expect(res).to be_a Array
163
+ method, url, data = res
164
+ expect(data.fetch(:body)).to eq "{\"input\":\"input\",\"input_location\":\"remote_url\",\"filename\":\"filename\",\"key\":\"api_key\",\"callback_url\":\"http://test.com\",\"callback_headers\":{\"Authorization\":\"Basic test\"}}"
165
+ end
87
166
  end
88
167
  end
89
168
  end; end; end
@@ -21,7 +21,7 @@ module NeverBounce; module API; module Request
21
21
  expect(res).to be_a Array
22
22
  method, url, data = res
23
23
  expect(method).to eq :post
24
- expect(url).to eq "https://api.neverbounce.com/v4/jobs/delete"
24
+ expect(url).to eq "https://api.neverbounce.com/v4.2/jobs/delete"
25
25
  expect(data).to include(:body, :headers)
26
26
  expect(data.fetch(:body)).to eq("{\"job_id\":\"123\",\"key\":\"api_key\"}")
27
27
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
@@ -21,7 +21,7 @@ module NeverBounce; module API; module Request
21
21
  expect(res).to be_a Array
22
22
  method, url, data = res
23
23
  expect(method).to eq :get
24
- expect(url).to eq "https://api.neverbounce.com/v4/jobs/download"
24
+ expect(url).to eq "https://api.neverbounce.com/v4.2/jobs/download"
25
25
  expect(data).to include(:body, :headers)
26
26
  expect(data.fetch(:body)).to eq("{\"job_id\":\"123\",\"key\":\"api_key\"}")
27
27
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
@@ -34,7 +34,7 @@ module NeverBounce; module API; module Request
34
34
  expect(res).to be_a Array
35
35
  method, url, data = res
36
36
  expect(method).to eq :post
37
- expect(url).to eq "https://api.neverbounce.com/v4/jobs/parse"
37
+ expect(url).to eq "https://api.neverbounce.com/v4.2/jobs/parse"
38
38
  expect(data).to include(:body, :headers)
39
39
  expect(data.fetch(:body)).to eq("{\"job_id\":\"123\",\"key\":\"api_key\"}")
40
40
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
@@ -32,7 +32,7 @@ module NeverBounce; module API; module Request
32
32
  expect(res).to be_a Array
33
33
  method, url, data = res
34
34
  expect(method).to eq :get
35
- expect(url).to eq "https://api.neverbounce.com/v4/jobs/results"
35
+ expect(url).to eq "https://api.neverbounce.com/v4.2/jobs/results"
36
36
  expect(data).to include(:body, :headers)
37
37
  expect(data.fetch(:body)).to eq "{\"job_id\":\"123\",\"key\":\"api_key\"}"
38
38
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
@@ -30,7 +30,7 @@ module NeverBounce; module API; module Request
30
30
  expect(res).to be_a Array
31
31
  method, url, data = res
32
32
  expect(method).to eq :get
33
- expect(url).to eq "https://api.neverbounce.com/v4/jobs/search"
33
+ expect(url).to eq "https://api.neverbounce.com/v4.2/jobs/search"
34
34
  expect(data).to include(:body, :headers)
35
35
  expect(data.fetch(:body)).to eq "{\"key\":\"api_key\",\"job_id\":\"abc\",\"page\":12,\"items_per_page\":34}"
36
36
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
@@ -9,12 +9,12 @@ module NeverBounce; module API; module Request
9
9
  it "generally works" do
10
10
  r = newo()
11
11
  expect(r.mode_h).to eq({})
12
- r = newo(run_sample: nil)
12
+ r = newo(run_sample: nil, allow_manual_review: nil)
13
13
  expect(r.mode_h).to eq({})
14
- r = newo(run_sample: false)
15
- expect(r.mode_h).to eq({run_sample: false})
16
- r = newo(run_sample: true)
17
- expect(r.mode_h).to eq({run_sample: true})
14
+ r = newo(run_sample: false, allow_manual_review: false)
15
+ expect(r.mode_h).to eq({run_sample: false, allow_manual_review: false})
16
+ r = newo(run_sample: true, allow_manual_review: true)
17
+ expect(r.mode_h).to eq({run_sample: true, allow_manual_review: true})
18
18
  end
19
19
  end
20
20
 
@@ -34,11 +34,35 @@ module NeverBounce; module API; module Request
34
34
  expect(res).to be_a Array
35
35
  method, url, data = res
36
36
  expect(method).to eq :post
37
- expect(url).to eq "https://api.neverbounce.com/v4/jobs/start"
37
+ expect(url).to eq "https://api.neverbounce.com/v4.2/jobs/start"
38
38
  expect(data).to include(:body, :headers)
39
39
  expect(data.fetch(:body)).to eq("{\"job_id\":\"123\",\"key\":\"api_key\"}")
40
40
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
41
41
  end
42
+
43
+ it "allows allow manual review parameter to be enabled" do
44
+ r = newo
45
+ r.job_id = "123"
46
+ r.api_key = "api_key"
47
+ r.allow_manual_review = true
48
+
49
+ res = r.to_httparty
50
+ expect(res).to be_a Array
51
+ method, url, data = res
52
+ expect(data.fetch(:body)).to eq "{\"job_id\":\"123\",\"key\":\"api_key\",\"allow_manual_review\":true}"
53
+ end
54
+
55
+ it "allows allow manual review parameter to be disabled" do
56
+ r = newo
57
+ r.job_id = "123"
58
+ r.api_key = "api_key"
59
+ r.allow_manual_review = false
60
+
61
+ res = r.to_httparty
62
+ expect(res).to be_a Array
63
+ method, url, data = res
64
+ expect(data.fetch(:body)).to eq "{\"job_id\":\"123\",\"key\":\"api_key\",\"allow_manual_review\":false}"
65
+ end
42
66
  end
43
67
  end
44
68
  end; end; end
@@ -21,7 +21,7 @@ module NeverBounce; module API; module Request
21
21
  expect(res).to be_a Array
22
22
  method, url, data = res
23
23
  expect(method).to eq :get
24
- expect(url).to eq "https://api.neverbounce.com/v4/jobs/status"
24
+ expect(url).to eq "https://api.neverbounce.com/v4.2/jobs/status"
25
25
  expect(data).to include(:body, :headers)
26
26
  expect(data.fetch(:body)).to eq "{\"job_id\":\"123\",\"key\":\"api_key\"}"
27
27
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
@@ -27,7 +27,7 @@ module NeverBounce; module API; module Request
27
27
  expect(res).to be_a Array
28
28
  method, url, data = res
29
29
  expect(method).to eq :get
30
- expect(url).to eq "https://api.neverbounce.com/v4/poe/confirm"
30
+ expect(url).to eq "https://api.neverbounce.com/v4.2/poe/confirm"
31
31
  expect(data).to include(:body, :headers)
32
32
  expect(data.fetch(:body)).to eq "{\"email\":\"email\",\"transaction_id\":\"NBTRNS-abcdefg\",\"confirmation_token\":\"abcdefg123456\",\"result\":\"valid\",\"key\":\"api_key\"}"
33
33
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
@@ -15,6 +15,10 @@ module NeverBounce; module API; module Request
15
15
  expect(r.mode_h).to eq({address_info: false, credits_info: false})
16
16
  r = newo(address_info: true, credits_info: true, timeout: 12)
17
17
  expect(r.mode_h).to eq({address_info: true, credits_info: true, timeout: 12})
18
+ r = newo(historical: true)
19
+ expect(r.mode_h).to eq({request_meta_data: {leverage_historical_data: true}})
20
+ r = newo(historical: false)
21
+ expect(r.mode_h).to eq({request_meta_data: {leverage_historical_data: false}})
18
22
  end
19
23
  end
20
24
 
@@ -34,11 +38,33 @@ module NeverBounce; module API; module Request
34
38
  expect(res).to be_a Array
35
39
  method, url, data = res
36
40
  expect(method).to eq :get
37
- expect(url).to eq "https://api.neverbounce.com/v4/single/check"
41
+ expect(url).to eq "https://api.neverbounce.com/v4.2/single/check"
38
42
  expect(data).to include(:body, :headers)
39
43
  expect(data.fetch(:body)).to eq "{\"email\":\"email\",\"key\":\"api_key\",\"address_info\":true,\"credits_info\":true,\"timeout\":12}"
40
44
  expect(data.fetch(:headers)).to include("Content-Type", "User-Agent")
41
45
  end
46
+
47
+ it "allows historical to be disabled" do
48
+ r = newo(address_info: true, credits_info: true, timeout: 12, historical: false)
49
+ r.email = "email"
50
+ r.api_key = "api_key"
51
+
52
+ res = r.to_httparty
53
+ expect(res).to be_a Array
54
+ method, url, data = res
55
+ expect(data.fetch(:body)).to eq "{\"email\":\"email\",\"key\":\"api_key\",\"address_info\":true,\"credits_info\":true,\"timeout\":12,\"request_meta_data\":{\"leverage_historical_data\":false}}"
56
+ end
57
+
58
+ it "allows historical to be explicitly enabled" do
59
+ r = newo(address_info: true, credits_info: true, timeout: 12, historical: true)
60
+ r.email = "email"
61
+ r.api_key = "api_key"
62
+
63
+ res = r.to_httparty
64
+ expect(res).to be_a Array
65
+ method, url, data = res
66
+ expect(data.fetch(:body)).to eq "{\"email\":\"email\",\"key\":\"api_key\",\"address_info\":true,\"credits_info\":true,\"timeout\":12,\"request_meta_data\":{\"leverage_historical_data\":true}}"
67
+ end
42
68
  end
43
69
  end
44
70
  end; end; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neverbounce-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NeverBounce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-11 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -137,7 +137,6 @@ files:
137
137
  - spec/lib/never_bounce/api/response/single_check_spec.rb
138
138
  - spec/lib/never_bounce/api/response/spec_helper.rb
139
139
  - spec/lib/never_bounce/api/session_spec.rb
140
- - spec/lib/never_bounce/api_spec.rb
141
140
  - spec/spec_helper.rb
142
141
  - spec/spec_support/include_dir_context.rb
143
142
  - spec/spec_support/simplecov.rb
@@ -160,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
159
  - !ruby/object:Gem::Version
161
160
  version: '0'
162
161
  requirements: []
163
- rubyforge_project:
164
- rubygems_version: 2.6.10
162
+ rubygems_version: 3.0.3
165
163
  signing_key:
166
164
  specification_version: 4
167
165
  summary: The official NeverBounce API library for Ruby
@@ -210,7 +208,6 @@ test_files:
210
208
  - spec/lib/never_bounce/api/response/single_check_spec.rb
211
209
  - spec/lib/never_bounce/api/response/spec_helper.rb
212
210
  - spec/lib/never_bounce/api/session_spec.rb
213
- - spec/lib/never_bounce/api_spec.rb
214
211
  - spec/spec_helper.rb
215
212
  - spec/spec_support/include_dir_context.rb
216
213
  - spec/spec_support/simplecov.rb
@@ -1,8 +0,0 @@
1
-
2
- require "never_bounce/api/version"
3
-
4
- describe NeverBounce::API do
5
- describe "VERSION" do
6
- it { expect(described_class::VERSION).to eq "1.0.1" }
7
- end
8
- end