class Bitstamper::Models::Transaction

Constants

MAPPING
TYPES

Attributes

amount[RW]
date[RW]
id[RW]
price[RW]
transaction_type[RW]
type[RW]

Public Class Methods

new(hash) click to toggle source
# File lib/bitstamper/models/transaction.rb, line 19
def initialize(hash)
  hash.each do |key, value|
    type            =     ::Bitstamper::Models::Transaction::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
parse(data) click to toggle source
# File lib/bitstamper/models/transaction.rb, line 31
def self.parse(data)
  data&.collect { |item| ::Bitstamper::Models::Transaction.new(item) }
end