Class: Sendly::Verification
- Inherits:
-
Object
- Object
- Sendly::Verification
- Defined in:
- lib/sendly/verify.rb
Constant Summary collapse
- STATUSES =
%w[pending verified expired failed].freeze
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#attempts ⇒ Object
readonly
Returns the value of attribute attempts.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#delivery_status ⇒ Object
readonly
Returns the value of attribute delivery_status.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#max_attempts ⇒ Object
readonly
Returns the value of attribute max_attempts.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#profile_id ⇒ Object
readonly
Returns the value of attribute profile_id.
-
#sandbox ⇒ Object
readonly
Returns the value of attribute sandbox.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#template_id ⇒ Object
readonly
Returns the value of attribute template_id.
-
#verified_at ⇒ Object
readonly
Returns the value of attribute verified_at.
Instance Method Summary collapse
- #expired? ⇒ Boolean
- #failed? ⇒ Boolean
-
#initialize(data) ⇒ Verification
constructor
A new instance of Verification.
- #pending? ⇒ Boolean
- #to_h ⇒ Object
- #verified? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Verification
Returns a new instance of Verification.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sendly/verify.rb', line 11 def initialize(data) @id = data["id"] @status = data["status"] @phone = data["phone"] @delivery_status = data["delivery_status"] @attempts = data["attempts"] || 0 @max_attempts = data["max_attempts"] || 3 @expires_at = parse_time(data["expires_at"]) @verified_at = parse_time(data["verified_at"]) @created_at = parse_time(data["created_at"]) @sandbox = data["sandbox"] || false @app_name = data["app_name"] @template_id = data["template_id"] @profile_id = data["profile_id"] end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def app_name @app_name end |
#attempts ⇒ Object (readonly)
Returns the value of attribute attempts.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def attempts @attempts end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def created_at @created_at end |
#delivery_status ⇒ Object (readonly)
Returns the value of attribute delivery_status.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def delivery_status @delivery_status end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def expires_at @expires_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def id @id end |
#max_attempts ⇒ Object (readonly)
Returns the value of attribute max_attempts.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def max_attempts @max_attempts end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def phone @phone end |
#profile_id ⇒ Object (readonly)
Returns the value of attribute profile_id.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def profile_id @profile_id end |
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def sandbox @sandbox end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def status @status end |
#template_id ⇒ Object (readonly)
Returns the value of attribute template_id.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def template_id @template_id end |
#verified_at ⇒ Object (readonly)
Returns the value of attribute verified_at.
5 6 7 |
# File 'lib/sendly/verify.rb', line 5 def verified_at @verified_at end |
Instance Method Details
#expired? ⇒ Boolean
35 36 37 |
# File 'lib/sendly/verify.rb', line 35 def expired? status == "expired" end |
#failed? ⇒ Boolean
39 40 41 |
# File 'lib/sendly/verify.rb', line 39 def failed? status == "failed" end |
#pending? ⇒ Boolean
27 28 29 |
# File 'lib/sendly/verify.rb', line 27 def pending? status == "pending" end |
#to_h ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/sendly/verify.rb', line 43 def to_h { id: id, status: status, phone: phone, delivery_status: delivery_status, attempts: attempts, max_attempts: max_attempts, expires_at: expires_at&.iso8601, verified_at: verified_at&.iso8601, created_at: created_at&.iso8601, sandbox: sandbox, app_name: app_name, template_id: template_id, profile_id: profile_id }.compact end |
#verified? ⇒ Boolean
31 32 33 |
# File 'lib/sendly/verify.rb', line 31 def verified? status == "verified" end |