Class: ItemBuilderMwh::Modes::CreateService
- Inherits:
-
Object
- Object
- ItemBuilderMwh::Modes::CreateService
show all
- Includes:
- ItemBuilderMwh::Modes
- Defined in:
- lib/item_builder_mwh/modes/create_service.rb
Constant Summary
collapse
- CREATE_CHANNEL =
{}.tap do |hash|
hash[12] = :Shopee
hash[15] = :Tokopedia
end.freeze
Instance Attribute Summary
#bundles, #existing_alloc_stocks, #item_bundle_variants, #lazada_quantity, #listing, #reserved_stocks, #shipping_providers, #shopify_inventory_location, #stock_allocs, #variant_listings, #variants, #wh_spaces, #zalora_reserved_stock, #zilingo_quantity
Instance Method Summary
collapse
#base, #bundle, #bundle_variants, #credential, #existing_allocated_stock, #initialize, #multiwarehouse, #pca, #stock_alloc, #variant, #variant_id, #warehouse, #warehouse_list, #warehouse_mapping, #warehouse_spaces, #warehouses, #wh_mapping, #wh_routing
Instance Method Details
#channel_name ⇒ Object
35
36
37
|
# File 'lib/item_builder_mwh/modes/create_service.rb', line 35
def channel_name
CREATE_CHANNEL[listing.channel_id].to_s
end
|
#create ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/item_builder_mwh/modes/create_service.rb', line 20
def create
{
item: {
id: item_listing.id,
variations: ::ItemBuilderMwh.build(listings.map(&:id), :map_create)
}
}
end
|
#create_channel ⇒ Object
29
30
31
32
33
|
# File 'lib/item_builder_mwh/modes/create_service.rb', line 29
def create_channel
class_name = "ItemBuilderMwh::Modes::Create::#{channel_name}Service"
create_channel_service = class_name.constantize
create_channel_service.new(item_listing, shipping_providers).perform
end
|
#item_listing ⇒ Object
39
40
41
|
# File 'lib/item_builder_mwh/modes/create_service.rb', line 39
def item_listing
@item_listing ||= listing.item_listing
end
|
#listings ⇒ Object
43
44
45
46
47
|
# File 'lib/item_builder_mwh/modes/create_service.rb', line 43
def listings
@listings ||= item_listing.variant_listings.where(
profile_channel_association_id: listing.profile_channel_association_id
)
end
|
16
17
18
|
# File 'lib/item_builder_mwh/modes/create_service.rb', line 16
def perform
create.merge(create_channel)
end
|