Class: Kojn::Tx
- Inherits:
-
Object
- Object
- Kojn::Tx
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Model, ActiveModel::Validations, Model
- Defined in:
- lib/kojn/transaction.rb
Constant Summary collapse
- UNCONFIRMED =
1
- INSUFFICIENT =
2
- SEEN =
3
- CANCELLED =
4
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#amount_in_fiat ⇒ Object
Returns the value of attribute amount_in_fiat.
-
#amount_left ⇒ Object
Returns the value of attribute amount_left.
-
#confirmed ⇒ Object
Returns the value of attribute confirmed.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#error ⇒ Object
Returns the value of attribute error.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#exchange_rate ⇒ Object
Returns the value of attribute exchange_rate.
-
#external_id ⇒ Object
Returns the value of attribute external_id.
-
#internal_id ⇒ Object
Returns the value of attribute internal_id.
-
#message ⇒ Object
Returns the value of attribute message.
-
#paid ⇒ Object
Returns the value of attribute paid.
-
#received_amount ⇒ Object
Returns the value of attribute received_amount.
-
#received_amount_in_fiat ⇒ Object
Returns the value of attribute received_amount_in_fiat.
-
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
-
#seen ⇒ Object
Returns the value of attribute seen.
-
#status ⇒ Object
Returns the value of attribute status.
-
#time_left ⇒ Object
Returns the value of attribute time_left.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Tx
constructor
A new instance of Tx.
-
#new_record? ⇒ Boolean
Returns whether this ‘record’ is new.
- #save ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Tx
Returns a new instance of Tx.
50 51 52 |
# File 'lib/kojn/transaction.rb', line 50 def initialize(attributes = {}) self.attributes = attributes end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def address @address end |
#amount ⇒ Object
Returns the value of attribute amount.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def amount @amount end |
#amount_in_fiat ⇒ Object
Returns the value of attribute amount_in_fiat.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def amount_in_fiat @amount_in_fiat end |
#amount_left ⇒ Object
Returns the value of attribute amount_left.
60 61 62 |
# File 'lib/kojn/transaction.rb', line 60 def amount_left @amount_left end |
#confirmed ⇒ Object
Returns the value of attribute confirmed.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def confirmed @confirmed end |
#currency ⇒ Object
Returns the value of attribute currency.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def description @description end |
#error ⇒ Object
Returns the value of attribute error.
61 62 63 |
# File 'lib/kojn/transaction.rb', line 61 def error @error end |
#errors ⇒ Object
Returns the value of attribute errors.
61 62 63 |
# File 'lib/kojn/transaction.rb', line 61 def errors @errors end |
#exchange_rate ⇒ Object
Returns the value of attribute exchange_rate.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def exchange_rate @exchange_rate end |
#external_id ⇒ Object
Returns the value of attribute external_id.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def external_id @external_id end |
#internal_id ⇒ Object
Returns the value of attribute internal_id.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def internal_id @internal_id end |
#message ⇒ Object
Returns the value of attribute message.
61 62 63 |
# File 'lib/kojn/transaction.rb', line 61 def @message end |
#paid ⇒ Object
Returns the value of attribute paid.
60 61 62 |
# File 'lib/kojn/transaction.rb', line 60 def paid @paid end |
#received_amount ⇒ Object
Returns the value of attribute received_amount.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def received_amount @received_amount end |
#received_amount_in_fiat ⇒ Object
Returns the value of attribute received_amount_in_fiat.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def received_amount_in_fiat @received_amount_in_fiat end |
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
60 61 62 |
# File 'lib/kojn/transaction.rb', line 60 def redirect_uri @redirect_uri end |
#seen ⇒ Object
Returns the value of attribute seen.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def seen @seen end |
#status ⇒ Object
Returns the value of attribute status.
59 60 61 |
# File 'lib/kojn/transaction.rb', line 59 def status @status end |
#time_left ⇒ Object
Returns the value of attribute time_left.
60 61 62 |
# File 'lib/kojn/transaction.rb', line 60 def time_left @time_left end |
Instance Method Details
#new_record? ⇒ Boolean
Returns whether this ‘record’ is new. Inspired by rails :) TODO Make sure if a newly initialized object’s internal_id is actually set to nil.
75 76 77 |
# File 'lib/kojn/transaction.rb', line 75 def new_record? self.internal_id == nil end |
#save ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/kojn/transaction.rb', line 63 def save # Uses the transactions helper class to create and update # Copies the returned transactions' attributes over to its own. if self.new_record? self.attributes = Kojn.transactions.create(self.attributes).attributes else self.attributes = Kojn.transactions.update(self.internal_id, self.attributes).attributes end end |