Class: ItemBuilder::Modes::Create::ShopeeService

Inherits:
Base
  • Object
show all
Defined in:
lib/item_builder/modes/create/shopee_service.rb

Instance Attribute Summary

Attributes inherited from Base

#item_listing, #shipping_providers

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from ItemBuilder::Modes::Create::Base

Instance Method Details

#brandObject



24
25
26
27
28
29
30
# File 'lib/item_builder/modes/create/shopee_service.rb', line 24

def brand
  {
    id: item_listing&.item_listing_brand&.id,
    local_id: item_listing&.item_listing_brand&.shopee&.local_id,
    name: item_listing&.item_listing_brand&.shopee&.name
  }
end

#categoryObject



16
17
18
19
20
21
22
# File 'lib/item_builder/modes/create/shopee_service.rb', line 16

def category
  {
    id: item_listing&.item_listing_category&.id,
    local_id: item_listing&.item_listing_category&.shopee&.local_id,
    name: item_listing&.item_listing_category&.shopee&.name
  }
end

#map_shipping_providersObject



32
33
34
35
36
37
38
39
40
# File 'lib/item_builder/modes/create/shopee_service.rb', line 32

def map_shipping_providers
  shipping_providers.map do |shipping_provider|
    {
      local_id: shipping_provider.local_id,
      name: shipping_provider.name,
      enabled: shipping_provider.enabled
    }
  end
end

#performObject



8
9
10
11
12
13
14
# File 'lib/item_builder/modes/create/shopee_service.rb', line 8

def perform
  {
    category: category,
    brand: brand,
    shipping_providers: map_shipping_providers
  }
end