Class: Bitstamper::Models::UserTransaction
- Defined in:
- lib/bitstamper/models/user_transaction.rb
Constant Summary collapse
- TYPES =
{ 0 => :deposit, 1 => :withdrawal, 2 => :market_trade, 14 => :sub_account_transfer }
- MAPPING =
{ "id" => :string, "order_id" => :string, "type" => :integer, "datetime" => :datetime, "fee" => :float, "usd" => :float, "eur" => :float, "btc" => :float, "btc_usd" => :float, "btc_eur" => :float, "eth" => :float, "eth_btc" => :float, "eth_usd" => :float, "eth_eur" => :float, "ltc" => :float, "xrp" => :float, "bch" => :float, }
Instance Attribute Summary collapse
-
#bch ⇒ Object
Returns the value of attribute bch.
-
#btc ⇒ Object
Returns the value of attribute btc.
-
#btc_eur ⇒ Object
Returns the value of attribute btc_eur.
-
#btc_usd ⇒ Object
Returns the value of attribute btc_usd.
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#eth ⇒ Object
Returns the value of attribute eth.
-
#eth_btc ⇒ Object
Returns the value of attribute eth_btc.
-
#eth_eur ⇒ Object
Returns the value of attribute eth_eur.
-
#eth_usd ⇒ Object
Returns the value of attribute eth_usd.
-
#eur ⇒ Object
Returns the value of attribute eur.
-
#fee ⇒ Object
Returns the value of attribute fee.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ltc ⇒ Object
Returns the value of attribute ltc.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#transaction_type ⇒ Object
Returns the value of attribute transaction_type.
-
#type ⇒ Object
Returns the value of attribute type.
-
#usd ⇒ Object
Returns the value of attribute usd.
-
#xrp ⇒ Object
Returns the value of attribute xrp.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ UserTransaction
constructor
A new instance of UserTransaction.
Methods inherited from Base
Constructor Details
#initialize(hash) ⇒ UserTransaction
Returns a new instance of UserTransaction.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bitstamper/models/user_transaction.rb', line 37 def initialize(hash) hash.each do |key, value| type = ::Bitstamper::Models::UserTransaction::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.id = hash.fetch("id", hash.fetch("tid", nil))&.to_s self.transaction_type = TYPES[self.type] end |
Instance Attribute Details
#bch ⇒ Object
Returns the value of attribute bch.
8 9 10 |
# File 'lib/bitstamper/models/user_transaction.rb', line 8 def bch @bch end |
#btc ⇒ Object
Returns the value of attribute btc.
6 7 8 |
# File 'lib/bitstamper/models/user_transaction.rb', line 6 def btc @btc end |
#btc_eur ⇒ Object
Returns the value of attribute btc_eur.
6 7 8 |
# File 'lib/bitstamper/models/user_transaction.rb', line 6 def btc_eur @btc_eur end |
#btc_usd ⇒ Object
Returns the value of attribute btc_usd.
6 7 8 |
# File 'lib/bitstamper/models/user_transaction.rb', line 6 def btc_usd @btc_usd end |
#datetime ⇒ Object
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/bitstamper/models/user_transaction.rb', line 4 def datetime @datetime end |
#eth ⇒ Object
Returns the value of attribute eth.
7 8 9 |
# File 'lib/bitstamper/models/user_transaction.rb', line 7 def eth @eth end |
#eth_btc ⇒ Object
Returns the value of attribute eth_btc.
7 8 9 |
# File 'lib/bitstamper/models/user_transaction.rb', line 7 def eth_btc @eth_btc end |
#eth_eur ⇒ Object
Returns the value of attribute eth_eur.
7 8 9 |
# File 'lib/bitstamper/models/user_transaction.rb', line 7 def eth_eur @eth_eur end |
#eth_usd ⇒ Object
Returns the value of attribute eth_usd.
7 8 9 |
# File 'lib/bitstamper/models/user_transaction.rb', line 7 def eth_usd @eth_usd end |
#eur ⇒ Object
Returns the value of attribute eur.
5 6 7 |
# File 'lib/bitstamper/models/user_transaction.rb', line 5 def eur @eur end |
#fee ⇒ Object
Returns the value of attribute fee.
4 5 6 |
# File 'lib/bitstamper/models/user_transaction.rb', line 4 def fee @fee end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/bitstamper/models/user_transaction.rb', line 4 def id @id end |
#ltc ⇒ Object
Returns the value of attribute ltc.
8 9 10 |
# File 'lib/bitstamper/models/user_transaction.rb', line 8 def ltc @ltc end |
#order_id ⇒ Object
Returns the value of attribute order_id.
4 5 6 |
# File 'lib/bitstamper/models/user_transaction.rb', line 4 def order_id @order_id end |
#transaction_type ⇒ Object
Returns the value of attribute transaction_type.
4 5 6 |
# File 'lib/bitstamper/models/user_transaction.rb', line 4 def transaction_type @transaction_type end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/bitstamper/models/user_transaction.rb', line 4 def type @type end |
#usd ⇒ Object
Returns the value of attribute usd.
5 6 7 |
# File 'lib/bitstamper/models/user_transaction.rb', line 5 def usd @usd end |
#xrp ⇒ Object
Returns the value of attribute xrp.
8 9 10 |
# File 'lib/bitstamper/models/user_transaction.rb', line 8 def xrp @xrp end |
Class Method Details
.parse(data) ⇒ Object
49 50 51 |
# File 'lib/bitstamper/models/user_transaction.rb', line 49 def self.parse(data) data&.collect { |item| ::Bitstamper::Models::UserTransaction.new(item) } end |