class Cryptopay::Invoice

Constants

ENCODER

Public Class Methods

build_from_hash(data) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Cryptopay::Invoice] Returns the model itself

# File lib/cryptopay/models/invoice.rb, line 261
def self.build_from_hash(data)
  attributes = ENCODER.build_from_hash(data)
  new(attributes)
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# File lib/cryptopay/models/invoice.rb, line 77
def initialize(attributes = {})
  @attributes = ENCODER.sanitize(attributes)
end

Public Instance Methods

address() click to toggle source

Invoice cryptocurrency address

# File lib/cryptopay/models/invoice.rb, line 105
def address
  @attributes[:address]
end
created_at() click to toggle source

Invoice creation date and time

# File lib/cryptopay/models/invoice.rb, line 187
def created_at
  @attributes[:created_at]
end
custom_id() click to toggle source

Invoice reference ID in your system

# File lib/cryptopay/models/invoice.rb, line 87
def custom_id
  @attributes[:custom_id]
end
customer_id() click to toggle source

The internal ID of your customer that the invoice relates to

# File lib/cryptopay/models/invoice.rb, line 92
def customer_id
  @attributes[:customer_id]
end
description() click to toggle source

Invoice description

# File lib/cryptopay/models/invoice.rb, line 163
def description
  @attributes[:description]
end
exchange() click to toggle source
# File lib/cryptopay/models/invoice.rb, line 149
def exchange
  @attributes[:exchange]
end
expires_at() click to toggle source

Invoice expiration date and time

# File lib/cryptopay/models/invoice.rb, line 192
def expires_at
  @attributes[:expires_at]
end
fee() click to toggle source

Processing fee

# File lib/cryptopay/models/invoice.rb, line 125
def fee
  @attributes[:fee]
end
fee_currency() click to toggle source

Processing fee currency

# File lib/cryptopay/models/invoice.rb, line 130
def fee_currency
  @attributes[:fee_currency]
end
hosted_page_url() click to toggle source

Invoice hosted page that renders invoice details

# File lib/cryptopay/models/invoice.rb, line 182
def hosted_page_url
  @attributes[:hosted_page_url]
end
id() click to toggle source

Invoice ID

# File lib/cryptopay/models/invoice.rb, line 82
def id
  @attributes[:id]
end
inspect() click to toggle source
# File lib/cryptopay/models/invoice.rb, line 272
def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
end
invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# File lib/cryptopay/models/invoice.rb, line 198
def invalid_properties
  properties = []

  properties.push('invalid value for "id", id cannot be nil.') if id.nil?

  properties.push('invalid value for "status", status cannot be nil.') if status.nil?

  if !status.nil? && !%w[new completed unresolved refunded cancelled].include?(status)
    properties.push('invalid value for status, must be one of "new", "completed", "unresolved", "refunded", "cancelled"')
  end

  if !status_context.nil? && !%w[overpaid underpaid paid_late illicit_resource].include?(status_context)
    properties.push('invalid value for status_context, must be one of "overpaid", "underpaid", "paid_late", "illicit_resource"')
  end

  properties.push('invalid value for "address", address cannot be nil.') if address.nil?

  properties.push('invalid value for "uri", uri cannot be nil.') if uri.nil?

  properties.push('invalid value for "price_amount", price_amount cannot be nil.') if price_amount.nil?

  properties.push('invalid value for "price_currency", price_currency cannot be nil.') if price_currency.nil?

  properties.push('invalid value for "fee", fee cannot be nil.') if fee.nil?

  properties.push('invalid value for "fee_currency", fee_currency cannot be nil.') if fee_currency.nil?

  properties.push('invalid value for "pay_amount", pay_amount cannot be nil.') if pay_amount.nil?

  properties.push('invalid value for "pay_currency", pay_currency cannot be nil.') if pay_currency.nil?

  properties.push('invalid value for "paid_amount", paid_amount cannot be nil.') if paid_amount.nil?

  exchange&.invalid_properties&.each do |prop|
    properties.push("invalid value for \"exchange\": #{prop}")
  end

  properties.push('invalid value for "transactions", transactions cannot be nil.') if transactions.nil?

  transactions&.each_with_index do |item, index|
    item.invalid_properties.each do |prop|
      properties.push("invalid value for \"transactions.#{index}\": #{prop}")
    end
  end

  properties.push('invalid value for "hosted_page_url", hosted_page_url cannot be nil.') if hosted_page_url.nil?

  properties.push('invalid value for "created_at", created_at cannot be nil.') if created_at.nil?

  properties.push('invalid value for "expires_at", expires_at cannot be nil.') if expires_at.nil?

  properties
end
metadata() click to toggle source

Key-value data

# File lib/cryptopay/models/invoice.rb, line 168
def metadata
  @attributes[:metadata]
end
name() click to toggle source

Invoice name

# File lib/cryptopay/models/invoice.rb, line 158
def name
  @attributes[:name]
end
paid_amount() click to toggle source

which amount already paid

pay_amount() click to toggle source

Cryptocurrency amount to pay

# File lib/cryptopay/models/invoice.rb, line 135
def pay_amount
  @attributes[:pay_amount]
end
pay_currency() click to toggle source

Cryptocurrency type

# File lib/cryptopay/models/invoice.rb, line 140
def pay_currency
  @attributes[:pay_currency]
end
price_amount() click to toggle source

Invoice amount

# File lib/cryptopay/models/invoice.rb, line 115
def price_amount
  @attributes[:price_amount]
end
price_currency() click to toggle source

Invoice amount currency

# File lib/cryptopay/models/invoice.rb, line 120
def price_currency
  @attributes[:price_currency]
end
status() click to toggle source
# File lib/cryptopay/models/invoice.rb, line 96
def status
  @attributes[:status]
end
status_context() click to toggle source
# File lib/cryptopay/models/invoice.rb, line 100
def status_context
  @attributes[:status_context]
end
success_redirect_url() click to toggle source

URL that a customer will be redirected to upon transaction confirmation

# File lib/cryptopay/models/invoice.rb, line 173
def success_redirect_url
  @attributes[:success_redirect_url]
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/cryptopay/models/invoice.rb, line 268
def to_hash
  ENCODER.to_hash(@attributes)
end
transactions() click to toggle source
# File lib/cryptopay/models/invoice.rb, line 153
def transactions
  @attributes[:transactions]
end
unsuccess_redirect_url() click to toggle source
# File lib/cryptopay/models/invoice.rb, line 177
def unsuccess_redirect_url
  @attributes[:unsuccess_redirect_url]
end
uri() click to toggle source

Invoice URI. May be used for generating a QR code

# File lib/cryptopay/models/invoice.rb, line 110
def uri
  @attributes[:uri]
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/cryptopay/models/invoice.rb, line 254
def valid?
  invalid_properties.empty?
end