Class: Zerobounce::Response
- Inherits:
-
Object
- Object
- Zerobounce::Response
- Defined in:
- lib/zerobounce/response.rb
Overview
A Zerobounce response
Instance Attribute Summary collapse
-
#request ⇒ Zerobounce::Request
readonly
The request instance.
-
#response ⇒ Faraday::Response
readonly
The original Faraday::Response.
Instance Method Summary collapse
-
#account ⇒ String
The portion of the email address before the “@” symbol.
-
#address ⇒ String
The email address you are validating.
-
#city ⇒ String?
The city of the IP passed in.
-
#country ⇒ String?
The country of the IP passed in.
-
#creation_date ⇒ Time?
The creation date of the email when available.
-
#disposable? ⇒ Boolean
If the email domain is disposable, which are usually temporary email addresses.
-
#domain ⇒ String
The portion of the email address after the “@” symbol.
-
#firstname ⇒ String?
The first name of the owner of the email when available.
-
#gender ⇒ String?
The gender of the owner of the email when available.
-
#initialize(response, request) ⇒ Response
constructor
A new instance of Response.
-
#inspect ⇒ String
Returns a string containing a human-readable representation.
-
#invalid? ⇒ Boolean
The opposite of #valid?.
-
#lastname ⇒ String?
The last name of the owner of the email when available.
-
#location ⇒ String?
The location of the owner of the email when available.
-
#process_date ⇒ Time?
The UTC time the email was validated.
-
#region ⇒ String?
The region/state of the IP passed in.
-
#status ⇒ Symbol
Deliverability status.
-
#sub_status ⇒ Symbol
A more detailed status.
-
#to_h ⇒ Hash
Convert to a hash.
-
#toxic? ⇒ Boolean
These domains are known for abuse, spam, or are bot created.
-
#valid? ⇒ Boolean
Is this email considered valid?.
-
#zipcode ⇒ String?
The zipcode of the IP passed in.
Constructor Details
#initialize(response, request) ⇒ Response
Returns a new instance of Response.
21 22 23 24 25 |
# File 'lib/zerobounce/response.rb', line 21 def initialize(response, request) @response = response @request = request @body = response.body end |
Instance Attribute Details
#request ⇒ Zerobounce::Request (readonly)
The request instance.
15 16 17 |
# File 'lib/zerobounce/response.rb', line 15 def request @request end |
#response ⇒ Faraday::Response (readonly)
The original Faraday::Response
15 16 17 |
# File 'lib/zerobounce/response.rb', line 15 def response @response end |
Instance Method Details
#account ⇒ String
The portion of the email address before the “@” symbol.
82 83 84 |
# File 'lib/zerobounce/response.rb', line 82 def account @account ||= @body[:account] end |
#address ⇒ String
The email address you are validating.
75 76 77 |
# File 'lib/zerobounce/response.rb', line 75 def address @address ||= @body[:address] end |
#city ⇒ String?
The city of the IP passed in.
138 139 140 |
# File 'lib/zerobounce/response.rb', line 138 def city @city ||= @body[:city] end |
#country ⇒ String?
The country of the IP passed in.
124 125 126 |
# File 'lib/zerobounce/response.rb', line 124 def country @country ||= @body[:country] end |
#creation_date ⇒ Time?
The creation date of the email when available.
196 197 198 |
# File 'lib/zerobounce/response.rb', line 196 def creation_date @creation_date ||= @body[:creationdate] && Time.parse(@body[:creationdate]) end |
#disposable? ⇒ Boolean
If you have valid emails with this flag set to true, you shouldn’t email them.
If the email domain is disposable, which are usually temporary email addresses.
These are temporary emails created for the sole purpose to sign up to websites without giving their real email address. These emails are short lived from 15 minutes to around 6 months.
173 174 175 |
# File 'lib/zerobounce/response.rb', line 173 def disposable? @disposable ||= @body[:disposable] || false end |
#domain ⇒ String
The portion of the email address after the “@” symbol.
89 90 91 |
# File 'lib/zerobounce/response.rb', line 89 def domain @domain ||= @body[:domain] end |
#firstname ⇒ String?
The first name of the owner of the email when available.
96 97 98 |
# File 'lib/zerobounce/response.rb', line 96 def firstname @firstname ||= @body[:firstname] end |
#gender ⇒ String?
The gender of the owner of the email when available.
110 111 112 |
# File 'lib/zerobounce/response.rb', line 110 def gender @gender ||= @body[:gender] end |
#inspect ⇒ String
205 206 207 |
# File 'lib/zerobounce/response.rb', line 205 def inspect "#<#{self.class.name}:#{object_id}>" end |
#invalid? ⇒ Boolean
The opposite of #valid?
161 162 163 |
# File 'lib/zerobounce/response.rb', line 161 def invalid? !valid? end |
#lastname ⇒ String?
The last name of the owner of the email when available.
103 104 105 |
# File 'lib/zerobounce/response.rb', line 103 def lastname @lastname ||= @body[:lastname] end |
#location ⇒ String?
The location of the owner of the email when available.
117 118 119 |
# File 'lib/zerobounce/response.rb', line 117 def location @location ||= @body[:location] end |
#process_date ⇒ Time?
The UTC time the email was validated.
189 190 191 |
# File 'lib/zerobounce/response.rb', line 189 def process_date @process_date ||= @body[:processedat] && Time.parse(@body[:processedat]) end |
#region ⇒ String?
The region/state of the IP passed in.
131 132 133 |
# File 'lib/zerobounce/response.rb', line 131 def region @region ||= @body[:region] end |
#status ⇒ Symbol
Deliverability status
Possible values:
:valid
:invalid
:catch_all
:unknown
:spamtrap
:abuse
:do_not_mail
39 40 41 |
# File 'lib/zerobounce/response.rb', line 39 def status @status ||= underscore(@body[:status])&.to_sym end |
#sub_status ⇒ Symbol
A more detailed status
Possible values:
:antispam_system
:greylisted
:mail_server_temporary_error
:forcible_disconnect
:mail_server_did_not_respond
:timeout_exceeded
:failed_smtp_connection
:mailbox_quota_exceeded
:exception_occurred
:possible_traps
:role_based
:global_suppression
:mailbox_not_found
:no_dns_entries
:failed_syntax_check
:possible_typo
:unroutable_ip_address
:leading_period_removed
:does_not_accept_mail
:alias_address
68 69 70 |
# File 'lib/zerobounce/response.rb', line 68 def sub_status @sub_status ||= underscore(@body[:sub_status])&.to_sym end |
#to_h ⇒ Hash
Convert to a hash.
212 213 214 215 216 217 |
# File 'lib/zerobounce/response.rb', line 212 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 |
#toxic? ⇒ Boolean
If you have a valid email with this flag set to true, you shouldn’t email them.
These domains are known for abuse, spam, or are bot created.
182 183 184 |
# File 'lib/zerobounce/response.rb', line 182 def toxic? @toxic ||= @body[:toxic] || false end |
#valid? ⇒ Boolean
Uses the values from Configuration#valid_statuses
Is this email considered valid?
154 155 156 |
# File 'lib/zerobounce/response.rb', line 154 def valid? @valid ||= Zerobounce.config.valid_statuses.include?(status) end |
#zipcode ⇒ String?
The zipcode of the IP passed in.
145 146 147 |
# File 'lib/zerobounce/response.rb', line 145 def zipcode @zipcode ||= @body[:zipcode] end |