Class: ItemBuilder::Modes::CreateService
- Inherits:
-
Object
- Object
- ItemBuilder::Modes::CreateService
show all
- Includes:
- ItemBuilder::Modes
- Defined in:
- lib/item_builder/modes/create_service.rb
Constant Summary
collapse
- CREATE_CHANNEL =
{}.tap do |hash|
hash[12] = :Shopee
end.freeze
Instance Attribute Summary
#bundles, #existing_alloc_stocks, #item_bundle_variants, #lazada_quantity, #listing, #shipping_providers, #shopify_inventory_location, #stock_allocs, #variant_listings, #variants, #wh_id, #wh_spaces, #zalora_reserved_stock, #zilingo_quantity
Instance Method Summary
collapse
#base, #bundle, #bundle_variants, #existing_allocated_stock, #initialize, #stock_alloc, #variant, #warehouse
Instance Method Details
#channel_name ⇒ Object
33
34
35
|
# File 'lib/item_builder/modes/create_service.rb', line 33
def channel_name
CREATE_CHANNEL[listing.channel_id].to_s
end
|
#create_channel ⇒ Object
27
28
29
30
31
|
# File 'lib/item_builder/modes/create_service.rb', line 27
def create_channel
class_name = "ItemBuilder::Modes::Create::#{channel_name}Service"
create_channel_service = class_name.constantize
create_channel_service.new(item_listing, shipping_providers).perform
end
|
#item_listing ⇒ Object
37
38
39
|
# File 'lib/item_builder/modes/create_service.rb', line 37
def item_listing
@item_listing ||= listing.item_listing
end
|
#listings ⇒ Object
41
42
43
44
45
|
# File 'lib/item_builder/modes/create_service.rb', line 41
def listings
@listings ||= item_listing.variant_listings.where(
profile_channel_association_id: listing.profile_channel_association_id
)
end
|
14
15
16
|
# File 'lib/item_builder/modes/create_service.rb', line 14
def perform
to_h.merge(create_channel)
end
|
#to_h ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/item_builder/modes/create_service.rb', line 18
def to_h
{
item: {
id: item_listing.id,
variations: ::ItemBuilder.build(listings.map(&:id), :map_create)
}
}
end
|