Class: CheckoutLink

Inherits:
Object
  • Object
show all
Defined in:
lib/speed_lightning/checkout_link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#amountObject

Returns the value of attribute amount.



2
3
4
# File 'lib/speed_lightning/checkout_link.rb', line 2

def amount
  @amount
end

#created_atObject

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

#currencyObject

Returns the value of attribute currency.



2
3
4
# File 'lib/speed_lightning/checkout_link.rb', line 2

def currency
  @currency
end

#idObject

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_enabledObject

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_enabledObject

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_enabledObject

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_enabledObject

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

#livemodeObject

Returns the value of attribute livemode.



2
3
4
# File 'lib/speed_lightning/checkout_link.rb', line 2

def livemode
  @livemode
end

#metadataObject

Returns the value of attribute metadata.



2
3
4
# File 'lib/speed_lightning/checkout_link.rb', line 2

def 
  @metadata
end

#raw_attributesObject

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

#statusObject

Returns the value of attribute status.



2
3
4
# File 'lib/speed_lightning/checkout_link.rb', line 2

def status
  @status
end

#success_urlObject

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_atObject

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

#urlObject

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

Returns:

  • (Boolean)


40
41
42
# File 'lib/speed_lightning/checkout_link.rb', line 40

def paid?
  @status == "paid"
end

#to_hashObject



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