Class: Bitstamper::Models::Withdrawal
- Defined in:
- lib/bitstamper/models/withdrawal.rb
Constant Summary collapse
- TYPES =
{ 0 => :sepa, 1 => :bitcoin, 2 => :wire, 14 => :xrp, 15 => :ltc, 16 => :eth }
- STATUS =
{ 0 => :open, 1 => :in_process, 2 => :finished, 3 => :cancelled, 4 => :failed }
- MAPPING =
{ "id" => :string, "currency" => :string, "amount" => :float, "datetime" => :datetime, "type" => :integer, "status" => :integer, "address" => :string, "transaction_id" => :string }
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#id ⇒ Object
Returns the value of attribute id.
-
#status ⇒ Object
Returns the value of attribute status.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ Withdrawal
constructor
A new instance of Withdrawal.
Methods inherited from Base
Constructor Details
#initialize(hash) ⇒ Withdrawal
Returns a new instance of Withdrawal.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bitstamper/models/withdrawal.rb', line 36 def initialize(hash) hash.each do |key, value| type = ::Bitstamper::Models::Withdrawal::MAPPING.fetch(key, nil) value = value && type ? ::Bitstamper::Utilities::convert_value(value, type) : value self.send("#{key}=", value) if self.respond_to?(key) end self.type = TYPES[self.type] self.status = STATUS[self.status] end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
6 7 8 |
# File 'lib/bitstamper/models/withdrawal.rb', line 6 def address @address end |
#amount ⇒ Object
Returns the value of attribute amount.
4 5 6 |
# File 'lib/bitstamper/models/withdrawal.rb', line 4 def amount @amount end |
#currency ⇒ Object
Returns the value of attribute currency.
4 5 6 |
# File 'lib/bitstamper/models/withdrawal.rb', line 4 def currency @currency end |
#datetime ⇒ Object
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/bitstamper/models/withdrawal.rb', line 4 def datetime @datetime end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/bitstamper/models/withdrawal.rb', line 4 def id @id end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/bitstamper/models/withdrawal.rb', line 5 def status @status end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
6 7 8 |
# File 'lib/bitstamper/models/withdrawal.rb', line 6 def transaction_id @transaction_id end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/bitstamper/models/withdrawal.rb', line 5 def type @type end |
Class Method Details
.parse(data) ⇒ Object
47 48 49 |
# File 'lib/bitstamper/models/withdrawal.rb', line 47 def self.parse(data) data&.collect { |item| ::Bitstamper::Models::Withdrawal.new(item) } end |