Class: CheckoutLink
- Inherits:
-
Object
- Object
- CheckoutLink
- Defined in:
- lib/speed_lightning/checkout_link.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_billing_address_enabled ⇒ Object
Returns the value of attribute is_billing_address_enabled.
-
#is_email_enabled ⇒ Object
Returns the value of attribute is_email_enabled.
-
#is_phone_enabled ⇒ Object
Returns the value of attribute is_phone_enabled.
-
#is_shipping_address_enabled ⇒ Object
Returns the value of attribute is_shipping_address_enabled.
-
#livemode ⇒ Object
Returns the value of attribute livemode.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
-
#status ⇒ Object
Returns the value of attribute status.
-
#success_url ⇒ Object
Returns the value of attribute success_url.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ CheckoutLink
constructor
A new instance of CheckoutLink.
- #paid? ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ CheckoutLink
Returns a new instance of CheckoutLink.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/speed_lightning/checkout_link.rb', line 4 def initialize(attributes = {}) @id = attributes['id'] @amount = attributes['amount'] @currency = attributes['currency'] @url = attributes['url'] @success_url = attributes['success_url'] @status = attributes['status'] @metadata = attributes['metadata'] @is_email_enabled = attributes.dig('customer_collections_status', 'is_email_enabled') @is_phone_enabled = attributes.dig('customer_collections_status', 'is_phone_enabled') @is_billing_address_enabled = attributes.dig('customer_collections_status', 'is_billing_address_enabled') @is_shipping_address_enabled = attributes.dig('customer_collections_status', 'is_shipping_address_enabled') @livemode = attributes['livemode'] # Convert the Unix timestamp in milliseconds to Ruby's Time object @created_at = Time.at(attributes['created'] / 1000.0) @updated_at = Time.at(attributes['modified'] / 1000.0) @raw_attributes = attributes end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def amount @amount end |
#created_at ⇒ Object
Returns the value of attribute created_at.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def created_at @created_at end |
#currency ⇒ Object
Returns the value of attribute currency.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def currency @currency end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def id @id end |
#is_billing_address_enabled ⇒ Object
Returns the value of attribute is_billing_address_enabled.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def is_billing_address_enabled @is_billing_address_enabled end |
#is_email_enabled ⇒ Object
Returns the value of attribute is_email_enabled.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def is_email_enabled @is_email_enabled end |
#is_phone_enabled ⇒ Object
Returns the value of attribute is_phone_enabled.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def is_phone_enabled @is_phone_enabled end |
#is_shipping_address_enabled ⇒ Object
Returns the value of attribute is_shipping_address_enabled.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def is_shipping_address_enabled @is_shipping_address_enabled end |
#livemode ⇒ Object
Returns the value of attribute livemode.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def livemode @livemode end |
#metadata ⇒ Object
Returns the value of attribute metadata.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def @metadata end |
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def raw_attributes @raw_attributes end |
#status ⇒ Object
Returns the value of attribute status.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def status @status end |
#success_url ⇒ Object
Returns the value of attribute success_url.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def success_url @success_url end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def updated_at @updated_at end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/speed_lightning/checkout_link.rb', line 2 def url @url end |
Instance Method Details
#paid? ⇒ Boolean
40 41 42 |
# File 'lib/speed_lightning/checkout_link.rb', line 40 def paid? @status == "paid" end |
#to_hash ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/speed_lightning/checkout_link.rb', line 23 def to_hash { id: @id, amount: @amount, currency: @currency, success_url: @success_url, metadata: @metadata, customer_collections_status: { is_email_enabled: @is_email_enabled, is_phone_enabled: @is_phone_enabled, is_billing_address_enabled: @is_billing_address_enabled, is_shipping_address_enabled: @is_shipping_address_enabled }, livemode: @livemode } end |