Class: VerifyAnyEmail::VerificationResult
- Inherits:
-
Object
- Object
- VerifyAnyEmail::VerificationResult
- Defined in:
- lib/verifyanyemail/verification_result.rb
Overview
Immutable wrapper around a single verification result object returned by
POST /v1/verify.
Access the raw hash with #to_h, or use the reader methods below. Boolean helpers such as #deliverable? classify the #status field.
Instance Attribute Summary collapse
-
#raw ⇒ Hash
readonly
The raw parsed result hash (string keys).
Instance Method Summary collapse
-
#account ⇒ String?
Local part (before the @).
- #catch_all? ⇒ Boolean?
-
#checked_at ⇒ String?
ISO-8601 timestamp of when the check ran.
-
#checks ⇒ Hash
The
checkssub-object (string keys), or {} when absent. -
#deliverable? ⇒ Boolean
Status == "deliverable".
- #disposable? ⇒ Boolean?
-
#domain ⇒ String?
Domain part (after the @).
-
#duration_ms ⇒ Integer?
Wall-clock verification time in milliseconds.
-
#email ⇒ String?
The address exactly as submitted.
- #free_provider? ⇒ Boolean?
- #gibberish? ⇒ Boolean?
- #has_mx_records? ⇒ Boolean?
-
#initialize(data) ⇒ VerificationResult
constructor
A new instance of VerificationResult.
- #mailbox_exists? ⇒ Boolean?
-
#normalized ⇒ String?
Normalized (lowercased/trimmed) address.
- #null_mx? ⇒ Boolean?
- #possible_typo? ⇒ Boolean?
-
#risky? ⇒ Boolean
Status == "risky".
- #role_based? ⇒ Boolean?
-
#safe_to_send ⇒ Boolean?
Whether the API recommends sending to this address.
-
#safe_to_send? ⇒ Boolean
Convenience alias for the
safeToSendflag. -
#score ⇒ Integer?
Confidence score, 0-100.
- #smtp_connectable? ⇒ Boolean?
-
#status ⇒ String?
One of: deliverable, undeliverable, risky, unknown.
-
#sub_status ⇒ String?
Finer-grained reason (e.g. valid_mailbox, catch_all).
-
#suggestion ⇒ String?
"Did you mean" domain correction, when available.
- #syntax? ⇒ Boolean?
-
#to_h ⇒ Hash
The raw underlying hash.
- #to_s ⇒ String (also: #inspect)
-
#undeliverable? ⇒ Boolean
Status == "undeliverable".
-
#unknown? ⇒ Boolean
Status == "unknown".
Constructor Details
#initialize(data) ⇒ VerificationResult
Returns a new instance of VerificationResult.
14 15 16 |
# File 'lib/verifyanyemail/verification_result.rb', line 14 def initialize(data) @raw = data.is_a?(Hash) ? data : {} end |
Instance Attribute Details
#raw ⇒ Hash (readonly)
Returns The raw parsed result hash (string keys).
11 12 13 |
# File 'lib/verifyanyemail/verification_result.rb', line 11 def raw @raw end |
Instance Method Details
#account ⇒ String?
Returns Local part (before the @).
29 30 31 |
# File 'lib/verifyanyemail/verification_result.rb', line 29 def account @raw["account"] end |
#catch_all? ⇒ Boolean?
131 132 133 |
# File 'lib/verifyanyemail/verification_result.rb', line 131 def catch_all? checks["catchAll"] end |
#checked_at ⇒ String?
Returns ISO-8601 timestamp of when the check ran.
74 75 76 |
# File 'lib/verifyanyemail/verification_result.rb', line 74 def checked_at @raw["checkedAt"] end |
#checks ⇒ Hash
Returns The checks sub-object (string keys), or {} when absent.
54 55 56 |
# File 'lib/verifyanyemail/verification_result.rb', line 54 def checks @raw["checks"] || {} end |
#deliverable? ⇒ Boolean
Returns status == "deliverable".
79 80 81 |
# File 'lib/verifyanyemail/verification_result.rb', line 79 def deliverable? status == "deliverable" end |
#disposable? ⇒ Boolean?
141 142 143 |
# File 'lib/verifyanyemail/verification_result.rb', line 141 def disposable? checks["disposable"] end |
#domain ⇒ String?
Returns Domain part (after the @).
34 35 36 |
# File 'lib/verifyanyemail/verification_result.rb', line 34 def domain @raw["domain"] end |
#duration_ms ⇒ Integer?
Returns Wall-clock verification time in milliseconds.
69 70 71 |
# File 'lib/verifyanyemail/verification_result.rb', line 69 def duration_ms @raw["durationMs"] end |
#email ⇒ String?
Returns The address exactly as submitted.
19 20 21 |
# File 'lib/verifyanyemail/verification_result.rb', line 19 def email @raw["email"] end |
#free_provider? ⇒ Boolean?
146 147 148 |
# File 'lib/verifyanyemail/verification_result.rb', line 146 def free_provider? checks["freeProvider"] end |
#gibberish? ⇒ Boolean?
156 157 158 |
# File 'lib/verifyanyemail/verification_result.rb', line 156 def gibberish? checks["gibberish"] end |
#has_mx_records? ⇒ Boolean?
111 112 113 |
# File 'lib/verifyanyemail/verification_result.rb', line 111 def has_mx_records? checks["hasMxRecords"] end |
#mailbox_exists? ⇒ Boolean?
126 127 128 |
# File 'lib/verifyanyemail/verification_result.rb', line 126 def mailbox_exists? checks["mailboxExists"] end |
#normalized ⇒ String?
Returns Normalized (lowercased/trimmed) address.
24 25 26 |
# File 'lib/verifyanyemail/verification_result.rb', line 24 def normalized @raw["normalized"] end |
#null_mx? ⇒ Boolean?
116 117 118 |
# File 'lib/verifyanyemail/verification_result.rb', line 116 def null_mx? checks["nullMx"] end |
#possible_typo? ⇒ Boolean?
151 152 153 |
# File 'lib/verifyanyemail/verification_result.rb', line 151 def possible_typo? checks["possibleTypo"] end |
#risky? ⇒ Boolean
Returns status == "risky".
89 90 91 |
# File 'lib/verifyanyemail/verification_result.rb', line 89 def risky? status == "risky" end |
#role_based? ⇒ Boolean?
136 137 138 |
# File 'lib/verifyanyemail/verification_result.rb', line 136 def role_based? checks["roleBased"] end |
#safe_to_send ⇒ Boolean?
Returns Whether the API recommends sending to this address.
64 65 66 |
# File 'lib/verifyanyemail/verification_result.rb', line 64 def safe_to_send @raw["safeToSend"] end |
#safe_to_send? ⇒ Boolean
Returns Convenience alias for the safeToSend flag.
99 100 101 |
# File 'lib/verifyanyemail/verification_result.rb', line 99 def safe_to_send? safe_to_send == true end |
#score ⇒ Integer?
Returns Confidence score, 0-100.
49 50 51 |
# File 'lib/verifyanyemail/verification_result.rb', line 49 def score @raw["score"] end |
#smtp_connectable? ⇒ Boolean?
121 122 123 |
# File 'lib/verifyanyemail/verification_result.rb', line 121 def smtp_connectable? checks["smtpConnectable"] end |
#status ⇒ String?
Returns One of: deliverable, undeliverable, risky, unknown.
39 40 41 |
# File 'lib/verifyanyemail/verification_result.rb', line 39 def status @raw["status"] end |
#sub_status ⇒ String?
Returns Finer-grained reason (e.g. valid_mailbox, catch_all).
44 45 46 |
# File 'lib/verifyanyemail/verification_result.rb', line 44 def sub_status @raw["subStatus"] end |
#suggestion ⇒ String?
Returns "Did you mean" domain correction, when available.
59 60 61 |
# File 'lib/verifyanyemail/verification_result.rb', line 59 def suggestion @raw["suggestion"] end |
#syntax? ⇒ Boolean?
106 107 108 |
# File 'lib/verifyanyemail/verification_result.rb', line 106 def syntax? checks["syntax"] end |
#to_h ⇒ Hash
Returns The raw underlying hash.
161 162 163 |
# File 'lib/verifyanyemail/verification_result.rb', line 161 def to_h @raw end |
#to_s ⇒ String Also known as: inspect
166 167 168 169 |
# File 'lib/verifyanyemail/verification_result.rb', line 166 def to_s "#<VerifyAnyEmail::VerificationResult #{normalized || email.inspect} " \ "status=#{status.inspect} score=#{score.inspect}>" end |
#undeliverable? ⇒ Boolean
Returns status == "undeliverable".
84 85 86 |
# File 'lib/verifyanyemail/verification_result.rb', line 84 def undeliverable? status == "undeliverable" end |
#unknown? ⇒ Boolean
Returns status == "unknown".
94 95 96 |
# File 'lib/verifyanyemail/verification_result.rb', line 94 def unknown? status == "unknown" end |