Class: Edi::AmazonVc::ListingItemInformationRetriever

Inherits:
BaseEdiService show all
Defined in:
app/services/edi/amazon_vc/listing_item_information_retriever.rb

Constant Summary

Constants included from Edi::AddressAbbreviator

Edi::AddressAbbreviator::MAX_LENGTH

Instance Attribute Summary

Attributes inherited from BaseEdiService

#orchestrator

Instance Method Summary collapse

Methods inherited from BaseEdiService

#duplicate_po_already_notified?, #initialize, #mark_duplicate_po_as_notified, #report_order_creation_issues, #safe_process_edi_communication_log

Methods included from Edi::AddressAbbreviator

#abbreviate_street, #collect_street_originals, #record_address_abbreviation_notes

Methods inherited from BaseService

#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger

Constructor Details

This class inherits a constructor from Edi::BaseEdiService

Instance Method Details

#process(sku:, locale: nil, file_info: {}) ⇒ Object

Retrieve catalog item information for the provided ASIN



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/edi/amazon_vc/listing_item_information_retriever.rb', line 6

def process(sku:, locale: nil, file_info: {})
  # see: https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-reference#patchlistingsitem

  uri = Addressable::URI.parse("#{orchestrator.listing_message_remote_path}#{orchestrator.merchant_id}/#{sku}")
  marketplace_id = orchestrator.marketplace
  query_values = {
    'marketplaceIds' => marketplace_id,
    'includedData' => 'summaries,attributes,issues,offers,fulfillmentAvailability,relationships,productTypes'
    # 'locale' => locale.to_s.dup.tr('-', '_')
  }
  uri.query_values = query_values

  remote_path = uri.to_s
  logger.info "Requesting from #{remote_path}"
  ecls = Edi::AmazonVc::Retriever.new(options).process transporter: orchestrator.transporter,
                                                     transporter_profile: orchestrator.transporter_profile,
                                                     data_type: 'json',
                                                     remote_path: remote_path,
                                                     partner: orchestrator.partner,
                                                     category: :listing_item_information,
                                                     store_to_upload: false,
                                                     file_info: file_info
  ecls.first # we only deal with one ecl
end