Class: ItemBuilder::Modes::PriceService
- Inherits:
-
Object
- Object
- ItemBuilder::Modes::PriceService
- Includes:
- ItemBuilder::Modes
- Defined in:
- lib/item_builder/modes/price_service.rb
Constant Summary collapse
- PRICE_CHANNEL =
{}.tap do |hash| hash[2] = :Shopify hash[9] = :Blibli hash[11] = :Bukalapak hash[13] = :Zalora hash[16] = :Jd end.freeze
Instance Attribute Summary
Attributes included from ItemBuilder::Modes
Instance Method Summary collapse
Methods included from ItemBuilder::Modes
Instance Method Details
#channel_name ⇒ Object
49 50 51 |
# File 'lib/item_builder/modes/price_service.rb', line 49 def channel_name PRICE_CHANNEL[listing.channel_id].to_s end |
#perform ⇒ Object
22 23 24 |
# File 'lib/item_builder/modes/price_service.rb', line 22 def perform to_h.merge(base) end |
#price ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/item_builder/modes/price_service.rb', line 30 def price if channel_name.empty? { price: listing.price, sale_price: listing.sale_price, sale_start_at: listing.sale_start_at, sale_end_at: listing.sale_end_at } else price_channel end end |
#price_channel ⇒ Object
43 44 45 46 47 |
# File 'lib/item_builder/modes/price_service.rb', line 43 def price_channel class_name = "ItemBuilder::Modes::Price::#{channel_name}Service" price_channel_service = class_name.constantize price_channel_service.new(listing).perform end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/item_builder/modes/price_service.rb', line 26 def to_h price end |