Class: Cryptopay::InvoiceTransaction
- Inherits:
-
Object
- Object
- Cryptopay::InvoiceTransaction
- Defined in:
- lib/cryptopay/models/invoice_transaction.rb
Overview
Cryptocurrency transaction hash and its risk level details
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::InvoiceTransaction
Builds the object from hash.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ InvoiceTransaction
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
- #risk ⇒ Object
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#txid ⇒ Object
Transaction hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ InvoiceTransaction
Initializes the object
33 34 35 |
# File 'lib/cryptopay/models/invoice_transaction.rb', line 33 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::InvoiceTransaction
Builds the object from hash
26 27 28 29 |
# File 'lib/cryptopay/models/invoice_transaction.rb', line 26 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#inspect ⇒ Object
72 73 74 |
# File 'lib/cryptopay/models/invoice_transaction.rb', line 72 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?
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cryptopay/models/invoice_transaction.rb', line 48 def invalid_properties properties = [] properties.push('invalid value for "txid", txid cannot be nil.') if txid.nil? risk&.invalid_properties&.each do |prop| properties.push("invalid value for \"risk\": #{prop}") end properties end |
#risk ⇒ Object
42 43 44 |
# File 'lib/cryptopay/models/invoice_transaction.rb', line 42 def risk @attributes[:risk] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
68 69 70 |
# File 'lib/cryptopay/models/invoice_transaction.rb', line 68 def to_hash ENCODER.to_hash(@attributes) end |
#txid ⇒ Object
Transaction hash
38 39 40 |
# File 'lib/cryptopay/models/invoice_transaction.rb', line 38 def txid @attributes[:txid] end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
62 63 64 |
# File 'lib/cryptopay/models/invoice_transaction.rb', line 62 def valid? invalid_properties.empty? end |