Class: Bitstamper::Models::Withdrawal

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes

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

#addressObject

Returns the value of attribute address.



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

def address
  @address
end

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#currencyObject

Returns the value of attribute currency.



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

def currency
  @currency
end

#datetimeObject

Returns the value of attribute datetime.



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

def datetime
  @datetime
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#transaction_idObject

Returns the value of attribute transaction_id.



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

def transaction_id
  @transaction_id
end

#typeObject

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