Skip to content

Commit 522b923

Browse files
authored
Merge pull request #28 from afrase/fix/out-of-credits-error
Fix error check string to fix #25
2 parents 692cf11 + 1091bc0 commit 522b923

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 0.1.2
2+
3+
* Removed the double quote from the body check since it appears a space is added after the colon.
4+
* Added changelog file.
5+
6+
# 0.1.1
7+
8+
* Removed safe accessor usage to work with older versions of Ruby.
9+
10+
# 0.1.0
11+
12+
* Added support for V2 of Zerobounce API.

lib/zerobounce/error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def parse_500(env)
4949
def parse_200(env)
5050
# The body hasn't been parsed yet and to avoid potentially parsing the body twice
5151
# we just use String#start_with?
52-
ApiError.new(env) if env[:body].to_s.start_with?('{"error":"')
52+
ApiError.new(env) if env[:body].to_s.start_with?('{"error":')
5353
end
5454
end
5555
end

lib/zerobounce/middleware/raise_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class RaiseError < Faraday::Response::Middleware
1414
# @param [Hash] env
1515
# @raise [Error]
1616
def on_complete(env)
17-
if (error = Zerobounce::Error.from_response(env)) # rubocop:disable GuardClause
17+
if (error = Zerobounce::Error.from_response(env)) # rubocop:disable Style/GuardClause
1818
raise error
1919
end
2020
end

lib/zerobounce/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
module Zerobounce
44
# The version of the gem.
5-
VERSION = '0.1.1'
5+
VERSION = '0.1.2'
66
end

spec/zerobounce/error_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
end
2727

2828
context 'when body looks like an error' do
29-
before { env[:body] = '{"error":"Invalid API Key or your account ran out of credits"}' }
29+
# The Zerobounce body contains a space after the `:`
30+
before { env[:body] = '{"error": "Invalid API Key or your account ran out of credits"}' }
3031

3132
it 'returns ApiError' do
3233
expect(described_class.from_response(env)).to be_a(Zerobounce::ApiError)

zerobounce.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ lib = File.expand_path('lib', __dir__)
44
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
55
require 'zerobounce/version'
66

7-
Gem::Specification.new do |spec| # rubocop:disable BlockLength
7+
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
88
spec.name = 'zerobounce'
99
spec.version = Zerobounce::VERSION
1010
spec.authors = ['Aaron Frase']

0 commit comments

Comments
 (0)