class Cryptopay::Invoice
Constants
- ENCODER
Public Class Methods
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
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
Invoice
cryptocurrency address
# File lib/cryptopay/models/invoice.rb, line 105 def address @attributes[:address] end
Invoice
creation date and time
# File lib/cryptopay/models/invoice.rb, line 187 def created_at @attributes[:created_at] end
Invoice
reference ID in your system
# File lib/cryptopay/models/invoice.rb, line 87 def custom_id @attributes[:custom_id] end
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
Invoice
description
# File lib/cryptopay/models/invoice.rb, line 163 def description @attributes[:description] end
# File lib/cryptopay/models/invoice.rb, line 149 def exchange @attributes[:exchange] end
Invoice
expiration date and time
# File lib/cryptopay/models/invoice.rb, line 192 def expires_at @attributes[:expires_at] end
Processing fee
# File lib/cryptopay/models/invoice.rb, line 125 def fee @attributes[:fee] end
Processing fee currency
# File lib/cryptopay/models/invoice.rb, line 130 def fee_currency @attributes[:fee_currency] end
Invoice
hosted page that renders invoice details
# File lib/cryptopay/models/invoice.rb, line 182 def hosted_page_url @attributes[:hosted_page_url] end
Invoice
ID
# File lib/cryptopay/models/invoice.rb, line 82 def id @attributes[:id] end
# 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
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
Key-value data
# File lib/cryptopay/models/invoice.rb, line 168 def metadata @attributes[:metadata] end
Invoice
name
# File lib/cryptopay/models/invoice.rb, line 158 def name @attributes[:name] end
which amount already paid
# File lib/cryptopay/models/invoice.rb, line 145 def paid_amount @attributes[:paid_amount] end
Cryptocurrency amount to pay
# File lib/cryptopay/models/invoice.rb, line 135 def pay_amount @attributes[:pay_amount] end
Cryptocurrency type
# File lib/cryptopay/models/invoice.rb, line 140 def pay_currency @attributes[:pay_currency] end
Invoice
amount
# File lib/cryptopay/models/invoice.rb, line 115 def price_amount @attributes[:price_amount] end
Invoice
amount currency
# File lib/cryptopay/models/invoice.rb, line 120 def price_currency @attributes[:price_currency] end
# File lib/cryptopay/models/invoice.rb, line 96 def status @attributes[:status] end
# File lib/cryptopay/models/invoice.rb, line 100 def status_context @attributes[:status_context] end
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
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
# File lib/cryptopay/models/invoice.rb, line 153 def transactions @attributes[:transactions] end
# File lib/cryptopay/models/invoice.rb, line 177 def unsuccess_redirect_url @attributes[:unsuccess_redirect_url] end
Invoice
URI. May be used for generating a QR code
# File lib/cryptopay/models/invoice.rb, line 110 def uri @attributes[:uri] end
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