Class: ItemBuilder::Modes::Quantity::BlibliService
- Defined in:
- lib/item_builder/modes/quantity/blibli_service.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#local_product ⇒ Hash
Find local product based on id.
- #local_variant ⇒ Object
- #perform ⇒ Object
- #total_quantity(item) ⇒ Object
Methods inherited from Base
#api_data, #apigateway_get, #apigateway_post, #credential, #data, #headers, #initialize, #order_host, #reserved_params, #reserved_stock
Constructor Details
This class inherits a constructor from ItemBuilder::Modes::Quantity::Base
Instance Method Details
#local_product ⇒ Hash
Find local product based on id
32 33 34 |
# File 'lib/item_builder/modes/quantity/blibli_service.rb', line 32 def local_product @local_product ||= JSON.parse(apigateway_post) end |
#local_variant ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/item_builder/modes/quantity/blibli_service.rb', line 12 def local_variant qty = 0 local_product['value']['items'].each do |item| qty = total_quantity(item) if item['itemSku'] == listing.local_id end qty end |
#perform ⇒ Object
8 9 10 |
# File 'lib/item_builder/modes/quantity/blibli_service.rb', line 8 def perform local_variant end |
#total_quantity(item) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/item_builder/modes/quantity/blibli_service.rb', line 20 def total_quantity(item) # Make stock 0 # if local reserved quantity is bigger than available quantity if item['reservedStockLevel2'] > available_quantity 0 else available_quantity end end |