Class: BandCampBX::Entities::Order

Inherits:
Base
  • Object
show all
Defined in:
lib/bandcampbx/entities/order.rb

Defined Under Namespace

Classes: InvalidTypeError

Class Method Summary collapse

Methods inherited from Base

#initialize, #inspect, keys, map_decimal, map_int, map_time, setup_readers

Constructor Details

This class inherits a constructor from BandCampBX::Entities::Base

Class Method Details

.map_typeObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/bandcampbx/entities/order.rb', line 8

def self.map_type
  ->(val) do
    case val.to_s
    when '0'
      :buy
    when '1'
      :sell
    else
      raise InvalidTypeError
    end
  end
end

.mappingsObject



21
22
23
24
25
26
27
28
29
# File 'lib/bandcampbx/entities/order.rb', line 21

def self.mappings
  {
    id: map_int,
    datetime: map_time,
    type: map_type,
    price: map_decimal,
    amount: map_decimal
  }
end