Class: Edi::Amazon::JsonListingGenerator::Factory

Inherits:
Object
  • Object
show all
Defined in:
app/services/edi/amazon/json_listing_generator/factory.rb

Class Method Summary collapse

Class Method Details

.generator_for_catalog_item(catalog_item, product_type: nil, locale: nil, attribute_actions: nil, fba: nil, language_tag: nil, business_price_available: nil) ⇒ Edi::Amazon::ProductData::BasePresenter

Generates the appropriate Edi::Amazon::ProductData presenter class for the given catalog item.

Parameters:

  • catalog_item (Edi::Amazon::CatalogItem)

    the catalog item to generate the presenter for

  • locales (String, nil)

    the locale to generate the presenter for

Returns:

  • (Edi::Amazon::ProductData::BasePresenter)

    the presenter for the catalog item



7
8
9
10
# File 'app/services/edi/amazon/json_listing_generator/factory.rb', line 7

def self.generator_for_catalog_item(catalog_item, product_type: nil, locale: nil, attribute_actions: nil, fba: nil, language_tag: nil, business_price_available: nil)
  product_type ||= catalog_item.amazon_product_type_in_effect
  Edi::Amazon::JsonListingGenerator::BaseGenerator.new(catalog_item, product_type:, locale:, attribute_actions:, fba:, language_tag:, business_price_available:)
end

.generator_for_variation(variation, product_type: nil, catalog_item: nil, locale: nil, attribute_actions: nil, marketplace_id: nil, language_tag: nil, business_price_available: nil) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
# File 'app/services/edi/amazon/json_listing_generator/factory.rb', line 12

def self.generator_for_variation(variation, product_type: nil, catalog_item: nil, locale: nil, attribute_actions: nil, marketplace_id: nil, language_tag: nil, business_price_available: nil)
  product_type ||= variation.amazon_desired_product_type
  catalog_item ||= variation.catalog_items_for_amazon_seller_marketplace_identifier(marketplace_id).first
  raise ArgumentError, "No catalog item found for variation #{variation.id} in marketplace #{marketplace_id}" if catalog_item.nil?

  Edi::Amazon::JsonListingGenerator::BaseGenerator.new(catalog_item, product_type:, locale:, attribute_actions:, variation:, marketplace_id:, language_tag:, business_price_available:)
end