Class: Cryptopay::Transaction
- Inherits:
-
Object
- Object
- Cryptopay::Transaction
- Defined in:
- lib/cryptopay/models/transaction.rb
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Transaction
Builds the object from hash.
Instance Method Summary collapse
-
#amount ⇒ Object
Transaction amount.
-
#balance ⇒ Object
Account subtotal.
-
#created_at ⇒ Object
Transaction creation date and time.
-
#currency ⇒ Object
Transaction currency.
-
#custom_id ⇒ Object
Transaction description.
-
#customer_id ⇒ Object
The reference ID of your customer.
-
#description ⇒ Object
Transaction description.
-
#fee ⇒ Object
Transaction fee details.
-
#fee_currency ⇒ Object
Transaction fee currency.
-
#id ⇒ Object
Account transaction ID.
-
#initialize(attributes = {}) ⇒ Transaction
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#reference_id ⇒ Object
Transaction reference ID in Cryptopay.
- #reference_type ⇒ Object
- #risk ⇒ Object
-
#status ⇒ Object
Transaction status.
-
#status_context ⇒ Object
Transaction status context.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Transaction
Initializes the object
64 65 66 |
# File 'lib/cryptopay/models/transaction.rb', line 64 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Transaction
Builds the object from hash
57 58 59 60 |
# File 'lib/cryptopay/models/transaction.rb', line 57 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#amount ⇒ Object
Transaction amount
84 85 86 |
# File 'lib/cryptopay/models/transaction.rb', line 84 def amount @attributes[:amount] end |
#balance ⇒ Object
Account subtotal
94 95 96 |
# File 'lib/cryptopay/models/transaction.rb', line 94 def balance @attributes[:balance] end |
#created_at ⇒ Object
Transaction creation date and time
137 138 139 |
# File 'lib/cryptopay/models/transaction.rb', line 137 def created_at @attributes[:created_at] end |
#currency ⇒ Object
Transaction currency
89 90 91 |
# File 'lib/cryptopay/models/transaction.rb', line 89 def currency @attributes[:currency] end |
#custom_id ⇒ Object
Transaction description
74 75 76 |
# File 'lib/cryptopay/models/transaction.rb', line 74 def custom_id @attributes[:custom_id] end |
#customer_id ⇒ Object
The reference ID of your customer
79 80 81 |
# File 'lib/cryptopay/models/transaction.rb', line 79 def customer_id @attributes[:customer_id] end |
#description ⇒ Object
Transaction description
118 119 120 |
# File 'lib/cryptopay/models/transaction.rb', line 118 def description @attributes[:description] end |
#fee ⇒ Object
Transaction fee details
99 100 101 |
# File 'lib/cryptopay/models/transaction.rb', line 99 def fee @attributes[:fee] end |
#fee_currency ⇒ Object
Transaction fee currency
104 105 106 |
# File 'lib/cryptopay/models/transaction.rb', line 104 def fee_currency @attributes[:fee_currency] end |
#id ⇒ Object
Account transaction ID
69 70 71 |
# File 'lib/cryptopay/models/transaction.rb', line 69 def id @attributes[:id] end |
#inspect ⇒ Object
183 184 185 |
# File 'lib/cryptopay/models/transaction.rb', line 183 def inspect "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash) end |
#invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/cryptopay/models/transaction.rb', line 143 def invalid_properties properties = [] properties.push('invalid value for "id", id cannot be nil.') if id.nil? properties.push('invalid value for "amount", amount cannot be nil.') if amount.nil? properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil? properties.push('invalid value for "balance", balance cannot be nil.') if balance.nil? properties.push('invalid value for "reference_id", reference_id cannot be nil.') if reference_id.nil? properties.push('invalid value for "reference_type", reference_type cannot be nil.') if reference_type.nil? if !reference_type.nil? && !%w[BankDeposit BankWithdrawal ChannelPayment CoinDeposit CoinWithdrawal ExchangeTransfer Invoice InvoiceRefund ManualBalanceTransaction].include?(reference_type) properties.push('invalid value for reference_type, must be one of "BankDeposit", "BankWithdrawal", "ChannelPayment", "CoinDeposit", "CoinWithdrawal", "ExchangeTransfer", "Invoice", "InvoiceRefund", "ManualBalanceTransaction"') end risk&.invalid_properties&.each do |prop| properties.push("invalid value for \"risk\": #{prop}") end properties.push('invalid value for "created_at", created_at cannot be nil.') if created_at.nil? properties end |
#reference_id ⇒ Object
Transaction reference ID in Cryptopay
109 110 111 |
# File 'lib/cryptopay/models/transaction.rb', line 109 def reference_id @attributes[:reference_id] end |
#reference_type ⇒ Object
113 114 115 |
# File 'lib/cryptopay/models/transaction.rb', line 113 def reference_type @attributes[:reference_type] end |
#risk ⇒ Object
132 133 134 |
# File 'lib/cryptopay/models/transaction.rb', line 132 def risk @attributes[:risk] end |
#status ⇒ Object
Transaction status
123 124 125 |
# File 'lib/cryptopay/models/transaction.rb', line 123 def status @attributes[:status] end |
#status_context ⇒ Object
Transaction status context
128 129 130 |
# File 'lib/cryptopay/models/transaction.rb', line 128 def status_context @attributes[:status_context] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
179 180 181 |
# File 'lib/cryptopay/models/transaction.rb', line 179 def to_hash ENCODER.to_hash(@attributes) end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
173 174 175 |
# File 'lib/cryptopay/models/transaction.rb', line 173 def valid? invalid_properties.empty? end |