Class: Bitstamper::Models::UserTransaction

Inherits:
Base
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes

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

#bchObject

Returns the value of attribute bch.



8
9
10
# File 'lib/bitstamper/models/user_transaction.rb', line 8

def bch
  @bch
end

#btcObject

Returns the value of attribute btc.



6
7
8
# File 'lib/bitstamper/models/user_transaction.rb', line 6

def btc
  @btc
end

#btc_eurObject

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_usdObject

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

#datetimeObject

Returns the value of attribute datetime.



4
5
6
# File 'lib/bitstamper/models/user_transaction.rb', line 4

def datetime
  @datetime
end

#ethObject

Returns the value of attribute eth.



7
8
9
# File 'lib/bitstamper/models/user_transaction.rb', line 7

def eth
  @eth
end

#eth_btcObject

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_eurObject

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_usdObject

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

#eurObject

Returns the value of attribute eur.



5
6
7
# File 'lib/bitstamper/models/user_transaction.rb', line 5

def eur
  @eur
end

#feeObject

Returns the value of attribute fee.



4
5
6
# File 'lib/bitstamper/models/user_transaction.rb', line 4

def fee
  @fee
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/bitstamper/models/user_transaction.rb', line 4

def id
  @id
end

#ltcObject

Returns the value of attribute ltc.



8
9
10
# File 'lib/bitstamper/models/user_transaction.rb', line 8

def ltc
  @ltc
end

#order_idObject

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_typeObject

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

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/bitstamper/models/user_transaction.rb', line 4

def type
  @type
end

#usdObject

Returns the value of attribute usd.



5
6
7
# File 'lib/bitstamper/models/user_transaction.rb', line 5

def usd
  @usd
end

#xrpObject

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