Module: ItemBuilder::Modes
- Included in:
- ActiveService, CreateService, MapCreateService, PreconditionCreateService, Price::SalePricePolicy, PriceService, QuantityService, SimpleService, UpdateService
- Defined in:
- lib/item_builder/modes.rb,
lib/item_builder/modes/price/base.rb,
lib/item_builder/modes/create/base.rb,
lib/item_builder/modes/update/base.rb,
lib/item_builder/modes/base_service.rb,
lib/item_builder/modes/price_service.rb,
lib/item_builder/modes/quantity/base.rb,
lib/item_builder/modes/active_service.rb,
lib/item_builder/modes/create_service.rb,
lib/item_builder/modes/simple_service.rb,
lib/item_builder/modes/update_service.rb,
lib/item_builder/modes/map_create/base.rb,
lib/item_builder/modes/price/jd_service.rb,
lib/item_builder/modes/quantity_service.rb,
lib/item_builder/modes/update/jd_service.rb,
lib/item_builder/modes/map_create_service.rb,
lib/item_builder/modes/price/blibli_service.rb,
lib/item_builder/modes/price/zalora_service.rb,
lib/item_builder/modes/create/shopee_service.rb,
lib/item_builder/modes/price/shopify_service.rb,
lib/item_builder/modes/update/blibli_service.rb,
lib/item_builder/modes/update/lazada_service.rb,
lib/item_builder/modes/update/zalora_service.rb,
lib/item_builder/modes/update/shopify_service.rb,
lib/item_builder/modes/price/bukalapak_service.rb,
lib/item_builder/modes/price/sale_price_policy.rb,
lib/item_builder/modes/quantity/lazada_service.rb,
lib/item_builder/modes/quantity/zalora_service.rb,
lib/item_builder/modes/create/tokopedia_service.rb,
lib/item_builder/modes/precondition_create/base.rb,
lib/item_builder/modes/quantity/zilingo_service.rb,
lib/item_builder/modes/update/bukalapak_service.rb,
lib/item_builder/modes/update/tokopedia_service.rb,
lib/item_builder/modes/map_create/shopee_service.rb,
lib/item_builder/modes/precondition_create_service.rb,
lib/item_builder/modes/map_create/tokopedia_service.rb,
lib/item_builder/modes/precondition_create/shopee_service.rb
Defined Under Namespace
Modules: Create, MapCreate, PreconditionCreate, Price, Quantity, Update Classes: ActiveService, BaseService, CreateService, MapCreateService, PreconditionCreateService, PriceService, QuantityService, SimpleService, UpdateService
Instance Attribute Summary collapse
-
#bundles ⇒ Object
readonly
Returns the value of attribute bundles.
-
#existing_alloc_stocks ⇒ Object
readonly
Returns the value of attribute existing_alloc_stocks.
-
#item_bundle_variants ⇒ Object
readonly
Returns the value of attribute item_bundle_variants.
-
#lazada_quantity ⇒ Object
readonly
Returns the value of attribute lazada_quantity.
-
#listing ⇒ Object
readonly
Returns the value of attribute listing.
-
#shipping_providers ⇒ Object
readonly
Returns the value of attribute shipping_providers.
-
#shopify_inventory_location ⇒ Object
readonly
Returns the value of attribute shopify_inventory_location.
-
#stock_allocs ⇒ Object
readonly
Returns the value of attribute stock_allocs.
-
#variant_listings ⇒ Object
readonly
Returns the value of attribute variant_listings.
-
#variants ⇒ Object
readonly
Returns the value of attribute variants.
-
#wh_id ⇒ Object
readonly
Returns the value of attribute wh_id.
-
#wh_spaces ⇒ Object
readonly
Returns the value of attribute wh_spaces.
-
#zalora_reserved_stock ⇒ Object
readonly
Returns the value of attribute zalora_reserved_stock.
-
#zilingo_quantity ⇒ Object
readonly
Returns the value of attribute zilingo_quantity.
Instance Method Summary collapse
- #base ⇒ Object
- #bundle ⇒ Object
- #bundle_variants ⇒ Object
- #existing_allocated_stock ⇒ Object
- #initialize(args) ⇒ Object
- #listings ⇒ Object
- #stock_alloc ⇒ Object
- #variant ⇒ Object
- #warehouse ⇒ Object
Instance Attribute Details
#bundles ⇒ Object (readonly)
Returns the value of attribute bundles.
15 16 17 |
# File 'lib/item_builder/modes.rb', line 15 def bundles @bundles end |
#existing_alloc_stocks ⇒ Object (readonly)
Returns the value of attribute existing_alloc_stocks.
17 18 19 |
# File 'lib/item_builder/modes.rb', line 17 def existing_alloc_stocks @existing_alloc_stocks end |
#item_bundle_variants ⇒ Object (readonly)
Returns the value of attribute item_bundle_variants.
16 17 18 |
# File 'lib/item_builder/modes.rb', line 16 def item_bundle_variants @item_bundle_variants end |
#lazada_quantity ⇒ Object (readonly)
Returns the value of attribute lazada_quantity.
20 21 22 |
# File 'lib/item_builder/modes.rb', line 20 def lazada_quantity @lazada_quantity end |
#listing ⇒ Object (readonly)
Returns the value of attribute listing.
11 12 13 |
# File 'lib/item_builder/modes.rb', line 11 def listing @listing end |
#shipping_providers ⇒ Object (readonly)
Returns the value of attribute shipping_providers.
24 25 26 |
# File 'lib/item_builder/modes.rb', line 24 def shipping_providers @shipping_providers end |
#shopify_inventory_location ⇒ Object (readonly)
Returns the value of attribute shopify_inventory_location.
22 23 24 |
# File 'lib/item_builder/modes.rb', line 22 def shopify_inventory_location @shopify_inventory_location end |
#stock_allocs ⇒ Object (readonly)
Returns the value of attribute stock_allocs.
14 15 16 |
# File 'lib/item_builder/modes.rb', line 14 def stock_allocs @stock_allocs end |
#variant_listings ⇒ Object (readonly)
Returns the value of attribute variant_listings.
18 19 20 |
# File 'lib/item_builder/modes.rb', line 18 def variant_listings @variant_listings end |
#variants ⇒ Object (readonly)
Returns the value of attribute variants.
13 14 15 |
# File 'lib/item_builder/modes.rb', line 13 def variants @variants end |
#wh_id ⇒ Object (readonly)
Returns the value of attribute wh_id.
23 24 25 |
# File 'lib/item_builder/modes.rb', line 23 def wh_id @wh_id end |
#wh_spaces ⇒ Object (readonly)
Returns the value of attribute wh_spaces.
12 13 14 |
# File 'lib/item_builder/modes.rb', line 12 def wh_spaces @wh_spaces end |
#zalora_reserved_stock ⇒ Object (readonly)
Returns the value of attribute zalora_reserved_stock.
21 22 23 |
# File 'lib/item_builder/modes.rb', line 21 def zalora_reserved_stock @zalora_reserved_stock end |
#zilingo_quantity ⇒ Object (readonly)
Returns the value of attribute zilingo_quantity.
19 20 21 |
# File 'lib/item_builder/modes.rb', line 19 def zilingo_quantity @zilingo_quantity end |
Instance Method Details
#base ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/item_builder/modes.rb', line 42 def base { id: listing.id, local_id: listing.local_id, local_item_id: listing.local_item_id, sku: listing.sku, variant_id: listing.variant_id } end |
#bundle ⇒ Object
70 71 72 |
# File 'lib/item_builder/modes.rb', line 70 def bundle bundles.select { |b| b.variant_id == listing.variant_id }.first end |
#bundle_variants ⇒ Object
64 65 66 67 68 |
# File 'lib/item_builder/modes.rb', line 64 def bundle_variants if bundle.present? item_bundle_variants.select { |ibv| ibv.bundle_id == bundle.id } end end |
#existing_allocated_stock ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/item_builder/modes.rb', line 52 def existing_allocated_stock existing_alloc_stocks.map do |els| if listings.pluck(:id).include?(els.variant_association_id) els end end.compact end |
#initialize(args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/item_builder/modes.rb', line 25 def initialize(args) @listing = args.fetch(:listing) @wh_spaces = args.fetch(:wh_spaces, []) @variants = args.fetch(:variants, []) @stock_allocs = args.fetch(:stock_allocs, []) @bundles = args.fetch(:bundles, []) @item_bundle_variants = args.fetch(:item_bundle_variants, []) @existing_alloc_stocks = args.fetch(:existing_alloc_stocks, []) @variant_listings = args.fetch(:variant_listings, []) @zilingo_quantity = args.fetch(:zilingo_quantity, []) @lazada_quantity = args.fetch(:lazada_quantity, []) @zalora_reserved_stock = args.fetch(:zalora_reserved_stock, []) @shopify_inventory_location = args.fetch(:shopify_inventory_location, []) @wh_id = args.fetch(:wh_id, []) @shipping_providers = args.fetch(:shipping_providers, []) end |
#listings ⇒ Object
60 61 62 |
# File 'lib/item_builder/modes.rb', line 60 def listings variant_listings.select { |vl| vl.variant_id == listing.variant_id} end |
#stock_alloc ⇒ Object
74 75 76 |
# File 'lib/item_builder/modes.rb', line 74 def stock_alloc stock_allocs.select { |sa| sa.variant_association_id == listing.id }.first end |
#variant ⇒ Object
86 87 88 |
# File 'lib/item_builder/modes.rb', line 86 def variant variants.select { |v| v.id == listing.variant_id }.first end |
#warehouse ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/item_builder/modes.rb', line 78 def warehouse if wh_id.present? wh_spaces.where(warehouse_id: wh_id).where(item_variant_id: listing.variant_id).first else wh_spaces.select { |ws| ws.item_variant_id == listing.variant_id }.first end end |