Class: ItemBuilderMwh::Modes::QuantityService
- Inherits:
-
Object
- Object
- ItemBuilderMwh::Modes::QuantityService
show all
- Includes:
- ItemBuilderMwh::Modes
- Defined in:
- lib/item_builder_mwh/modes/quantity_service.rb
Constant Summary
collapse
- QUANTITY_CHANNEL =
{}.tap do |hash|
hash[3] = :Lazada
hash[9] = :Blibli
hash[13] = :Zalora
end.freeze
Instance Attribute Summary
#listing
Instance Method Summary
collapse
#base, #initialize, #pca, #warehouse, #warehouse_mapping, #warehouse_spaces, #warehouses, #wh_mapping
Instance Method Details
#channel_name ⇒ Object
49
50
51
|
# File 'lib/item_builder_mwh/modes/quantity_service.rb', line 49
def channel_name
QUANTITY_CHANNEL[listing.channel_id].to_s
end
|
20
21
22
23
24
|
# File 'lib/item_builder_mwh/modes/quantity_service.rb', line 20
def perform
base.merge!(
warehouse: warehouses
)
end
|
#qty(available_qty) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/item_builder_mwh/modes/quantity_service.rb', line 35
def qty(available_qty)
if channel_name.empty?
available_qty
else
qty_channel(available_qty)
end
end
|
#qty_channel(available_qty) ⇒ Object
43
44
45
46
47
|
# File 'lib/item_builder_mwh/modes/quantity_service.rb', line 43
def qty_channel(available_qty)
class_name = "ItemBuilderMwh::Modes::Quantity::#{channel_name}Service"
qty_channel_service = class_name.constantize
qty_channel_service.new(listing, available_qty).perform
end
|
#to_h(warehouse_space) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/item_builder_mwh/modes/quantity_service.rb', line 26
def to_h(warehouse_space)
{
quantity: qty(warehouse_space.quantity),
warehouse_id: wh_mapping(
warehouse_space.warehouse_id
)
}
end
|