zerobounce 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/bin/console +1 -4
- data/bin/setup +0 -2
- data/lib/zerobounce/error.rb +2 -2
- data/lib/zerobounce/request.rb +1 -1
- data/lib/zerobounce/response.rb +2 -1
- data/lib/zerobounce/response/v1_response.rb +7 -7
- data/lib/zerobounce/response/v2_response.rb +4 -4
- data/lib/zerobounce/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 242ec4a8fca45a86c1cae5aae48abe79fa4dec94e46a0ac914ee2739123fcfe8
|
4
|
+
data.tar.gz: 3c455fdb4024f924a31476e51bce40ddb0b8fd2c1178a856a9ba7fa6914b16f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3823fb127a0b58fc88c3af7d1a62cfdb808695534943658b7ed7a6ab5c3acc811e15c4628c7a54477e6984d0f11e4323b75e1c82652c48d706fb230318ee1504
|
7
|
+
data.tar.gz: 61e3a220183ddd22ae6f8163aa229eefb62634100171c68b328fd2f89684fc7b94c63264eba12b613d446aae7897e83b1940e35782c3528acd5bb8c913e37afa
|
data/.gitignore
CHANGED
data/bin/console
CHANGED
data/bin/setup
CHANGED
data/lib/zerobounce/error.rb
CHANGED
@@ -37,7 +37,7 @@ module Zerobounce
|
|
37
37
|
# @param [Hash] env
|
38
38
|
# @return [Error]
|
39
39
|
def parse_500(env)
|
40
|
-
if env[:body]
|
40
|
+
if env[:body].to_s.start_with?('Missing parameter')
|
41
41
|
MissingParameter.new(env)
|
42
42
|
else
|
43
43
|
InternalServerError.new(env)
|
@@ -49,7 +49,7 @@ module Zerobounce
|
|
49
49
|
def parse_200(env)
|
50
50
|
# The body hasn't been parsed yet and to avoid potentially parsing the body twice
|
51
51
|
# we just use String#start_with?
|
52
|
-
ApiError.new(env) if env[:body]
|
52
|
+
ApiError.new(env) if env[:body].to_s.start_with?('{"error":"')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
data/lib/zerobounce/request.rb
CHANGED
@@ -50,7 +50,7 @@ module Zerobounce
|
|
50
50
|
# @option params [String] :apikey
|
51
51
|
# @return [Integer] A value of -1 can mean the API is invalid.
|
52
52
|
def credits(params={})
|
53
|
-
get('getcredits', params).body[:Credits]
|
53
|
+
get('getcredits', params).body[:Credits].to_i
|
54
54
|
end
|
55
55
|
|
56
56
|
private
|
data/lib/zerobounce/response.rb
CHANGED
@@ -19,7 +19,7 @@ module Zerobounce
|
|
19
19
|
attr_reader :request
|
20
20
|
|
21
21
|
# @param [Faraday::Response] response
|
22
|
-
# @param [Zerobounce::Request] request
|
22
|
+
# @param [Zerobounce::Request::V2Response, Zerobounce::Request::V1Response] request
|
23
23
|
def initialize(response, request)
|
24
24
|
@response = response
|
25
25
|
@request = request
|
@@ -134,6 +134,7 @@ module Zerobounce
|
|
134
134
|
def to_h
|
135
135
|
public_methods(false).each_with_object({}) do |meth, memo|
|
136
136
|
next if %i[request response inspect to_h].include?(meth)
|
137
|
+
|
137
138
|
memo[meth] = send(meth)
|
138
139
|
end
|
139
140
|
end
|
@@ -17,7 +17,7 @@ module Zerobounce
|
|
17
17
|
#
|
18
18
|
# @return [Symbol] The status as a +Symbol+.
|
19
19
|
def status
|
20
|
-
@status ||= underscore(@body[:status])
|
20
|
+
@status ||= @body[:status].to_s.empty? ? nil : underscore(@body[:status]).to_sym
|
21
21
|
end
|
22
22
|
|
23
23
|
# A more detailed status
|
@@ -43,10 +43,11 @@ module Zerobounce
|
|
43
43
|
# :leading_period_removed
|
44
44
|
# :does_not_accept_mail
|
45
45
|
# :alias_address
|
46
|
+
# :unknown
|
46
47
|
#
|
47
48
|
# @return [Symbol] The sub_status as a +Symbol+.
|
48
49
|
def sub_status
|
49
|
-
@sub_status ||= underscore(@body[:sub_status])
|
50
|
+
@sub_status ||= @body[:sub_status].to_s.empty? ? nil : underscore(@body[:sub_status]).to_sym
|
50
51
|
end
|
51
52
|
|
52
53
|
# If the email domain is disposable, which are usually temporary email addresses.
|
@@ -81,22 +82,21 @@ module Zerobounce
|
|
81
82
|
#
|
82
83
|
# @return [Time, nil]
|
83
84
|
def processed_at
|
84
|
-
@processed_at ||= @body[:processedat] && Time.parse(@body[:processedat])
|
85
|
+
@processed_at ||= @body[:processedat] && Time.parse("#{@body[:processedat]} UTC")
|
85
86
|
end
|
86
87
|
|
87
88
|
# The creation date of the email when available.
|
88
89
|
#
|
89
90
|
# @return [Time, nil]
|
90
91
|
def creation_date
|
91
|
-
@creation_date ||= @body[:creationdate] && Time.parse(@body[:creationdate])
|
92
|
+
@creation_date ||= @body[:creationdate] && Time.parse("#{@body[:creationdate]} UTC")
|
92
93
|
end
|
93
94
|
|
94
95
|
private
|
95
96
|
|
96
|
-
# @param [String
|
97
|
-
# @return [String
|
97
|
+
# @param [String] word
|
98
|
+
# @return [String]
|
98
99
|
def underscore(word)
|
99
|
-
return if word.nil? || word.empty?
|
100
100
|
word.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase.tr('-', '_')
|
101
101
|
end
|
102
102
|
end
|
@@ -6,7 +6,7 @@ module Zerobounce
|
|
6
6
|
module V2Response
|
7
7
|
# Deliverability status
|
8
8
|
#
|
9
|
-
# @see https://
|
9
|
+
# @see https://www.zerobounce.net/docs/email-validation-api-quickstart/#status_codes__v2__
|
10
10
|
#
|
11
11
|
# Possible values:
|
12
12
|
# :valid
|
@@ -19,12 +19,12 @@ module Zerobounce
|
|
19
19
|
#
|
20
20
|
# @return [Symbol] The status as a +Symbol+.
|
21
21
|
def status
|
22
|
-
@status ||= @body[:status]
|
22
|
+
@status ||= @body[:status].to_s.empty? ? nil : @body[:status].tr('-', '_').to_sym
|
23
23
|
end
|
24
24
|
|
25
25
|
# @return [Symbol, nil]
|
26
26
|
def sub_status
|
27
|
-
@sub_status ||= @body[:sub_status]
|
27
|
+
@sub_status ||= @body[:sub_status].to_s.empty? ? nil : @body[:sub_status].to_sym
|
28
28
|
end
|
29
29
|
|
30
30
|
# @return [Integer]
|
@@ -55,7 +55,7 @@ module Zerobounce
|
|
55
55
|
#
|
56
56
|
# @return [Time, nil]
|
57
57
|
def processed_at
|
58
|
-
@processed_at ||= @body[:processed_at] && Time.parse(@body[:processed_at])
|
58
|
+
@processed_at ||= @body[:processed_at] && Time.parse("#{@body[:processed_at]} UTC")
|
59
59
|
end
|
60
60
|
|
61
61
|
# If the email comes from a free provider.
|
data/lib/zerobounce/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zerobounce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Frase
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -224,8 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
- !ruby/object:Gem::Version
|
225
225
|
version: '0'
|
226
226
|
requirements: []
|
227
|
-
|
228
|
-
rubygems_version: 2.6.14
|
227
|
+
rubygems_version: 3.0.6
|
229
228
|
signing_key:
|
230
229
|
specification_version: 4
|
231
230
|
summary: A Ruby client for Zerobounce.net.
|