class Zerobounce::Response
A Zerobounce
response
@author Aaron Frase
@attr_reader [Zerobounce::Request] request
The request instance.
@attr_reader [Faraday::Response] response
The original {https://www.rubydoc.info/gems/faraday/1.4.2/Faraday/Response Faraday::Response}
Attributes
Public Class Methods
@param [Faraday::Response] response @param [Zerobounce::Request::V2Response, Zerobounce::Request::V1Response] request
# File lib/zerobounce/response.rb, line 23 def initialize(response, request) @response = response @request = request @body = response.body case request.api_version when 'v2' extend(V2Response) else extend(V1Response) end end
Public Instance Methods
The portion of the email address before the “@” symbol.
@return [String]
# File lib/zerobounce/response.rb, line 46 def account @account ||= @body[:account] end
The email address you are validating.
@return [String]
# File lib/zerobounce/response.rb, line 39 def address @address ||= @body[:address] end
The city of the IP passed in.
@return [String, nil]
# File lib/zerobounce/response.rb, line 95 def city @city ||= @body[:city] end
The country of the IP passed in.
@return [String, nil]
# File lib/zerobounce/response.rb, line 81 def country @country ||= @body[:country] end
The portion of the email address after the “@” symbol.
@return [String]
# File lib/zerobounce/response.rb, line 53 def domain @domain ||= @body[:domain] end
The first name of the owner of the email when available.
@return [String, nil]
# File lib/zerobounce/response.rb, line 60 def firstname @firstname ||= @body[:firstname] end
The gender of the owner of the email when available.
@return [String, nil]
# File lib/zerobounce/response.rb, line 74 def gender @gender ||= @body[:gender] end
Returns a string containing a human-readable representation.
@note Overriding inspect to hide the {#request}/{#response} instance variables
@return [String]
# File lib/zerobounce/response.rb, line 127 def inspect "#<#{self.class.name}:0x#{object_id.to_s(16)} @address=#{address}>" end
The opposite of {#valid?}
@return [Boolean]
# File lib/zerobounce/response.rb, line 118 def invalid? !valid? end
The last name of the owner of the email when available.
@return [String, nil]
# File lib/zerobounce/response.rb, line 67 def lastname @lastname ||= @body[:lastname] end
The region/state of the IP passed in.
@return [String, nil]
# File lib/zerobounce/response.rb, line 88 def region @region ||= @body[:region] end
Convert to a hash.
@return [Hash]
# File lib/zerobounce/response.rb, line 134 def to_h public_methods(false).each_with_object({}) do |meth, memo| next if %i[request response inspect to_h].include?(meth) memo[meth] = send(meth) end end
Is this email considered valid?
@note Uses the values from {Zerobounce::Configuration#valid_statuses}
@return [Boolean]
# File lib/zerobounce/response.rb, line 111 def valid? @valid ||= Zerobounce.config.valid_statuses.include?(status) end
The zipcode of the IP passed in.
@return [String, nil]
# File lib/zerobounce/response.rb, line 102 def zipcode @zipcode ||= @body[:zipcode] end