zerobounce 0.1.0 → 0.1.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
- SHA1:
3
- metadata.gz: c721e810255839a88073d013c9b97065471160e1
4
- data.tar.gz: 84b8c3683741ea097daba407bc245ebd0d92b3cf
2
+ SHA256:
3
+ metadata.gz: 242ec4a8fca45a86c1cae5aae48abe79fa4dec94e46a0ac914ee2739123fcfe8
4
+ data.tar.gz: 3c455fdb4024f924a31476e51bce40ddb0b8fd2c1178a856a9ba7fa6914b16f8
5
5
  SHA512:
6
- metadata.gz: be2427a95a25fed9e115da52757cefe0c389a67e02d6b720117ae24f760c5de86603a0b9b8af2d46f9c30ede766e83d2003d64b4633cd3b3cfdcd360654f33c7
7
- data.tar.gz: 9ec05422f597f3b91fba26d07ef5d57be77a46b0936a61481a6b9290121a5e20eb7c4917cd0c0e266b3e519a67d3839b757420be8ffcd630e7441f7b53c866ae
6
+ metadata.gz: 3823fb127a0b58fc88c3af7d1a62cfdb808695534943658b7ed7a6ab5c3acc811e15c4628c7a54477e6984d0f11e4323b75e1c82652c48d706fb230318ee1504
7
+ data.tar.gz: 61e3a220183ddd22ae6f8163aa229eefb62634100171c68b328fd2f89684fc7b94c63264eba12b613d446aae7897e83b1940e35782c3528acd5bb8c913e37afa
data/.gitignore CHANGED
@@ -14,3 +14,4 @@ Gemfile.lock
14
14
 
15
15
  # rspec failure tracking
16
16
  .rspec_status
17
+ .env
@@ -2,9 +2,6 @@
2
2
 
3
3
  require 'bundler/setup'
4
4
  require 'zerobounce'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
5
  require 'pry'
6
+
10
7
  Pry.start
data/bin/setup CHANGED
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -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]&.start_with?('Missing parameter')
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]&.start_with?('{"error":"')
52
+ ApiError.new(env) if env[:body].to_s.start_with?('{"error":"')
53
53
  end
54
54
  end
55
55
  end
@@ -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]&.to_i
53
+ get('getcredits', params).body[:Credits].to_i
54
54
  end
55
55
 
56
56
  private
@@ -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])&.to_sym
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])&.to_sym
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, nil] word
97
- # @return [String, nil]
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://docs.zerobounce.net/docs/status-codes-v2
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]&.tr('-', '_')&.to_sym
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] == '' ? nil : @body[:sub_status]&.to_sym
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.
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Zerobounce
4
4
  # The version of the gem.
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
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.0
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: 2018-07-28 00:00:00.000000000 Z
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
- rubyforge_project:
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.