Class: Edi::AmazonVc::ListingMessageSender
- Inherits:
-
Sender
- Object
- BaseService
- BaseEdiService
- Sender
- Edi::AmazonVc::ListingMessageSender
- Defined in:
- app/services/edi/amazon_vc/listing_message_sender.rb
Constant Summary
Constants included from Edi::AddressAbbreviator
Edi::AddressAbbreviator::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseEdiService
Instance Method Summary collapse
-
#process(edi_communication_logs = nil, catalog_item_or_variation: [edi_communication_logs].flatten.first&.catalog_items&.last, http_method: 'PATCH', locale: orchestrator.locales.first, use_fba_sku: false) ⇒ Object
Sends patchListingItem or pusListingItem message according to the partner config and http_method.
Methods inherited from Sender
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(edi_communication_logs = nil, catalog_item_or_variation: [edi_communication_logs].flatten.first&.catalog_items&.last, http_method: 'PATCH', locale: orchestrator.locales.first, use_fba_sku: false) ⇒ Object
Sends patchListingItem or pusListingItem message according to the partner config and http_method
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/edi/amazon_vc/listing_message_sender.rb', line 6 def process(edi_communication_logs = nil, catalog_item_or_variation: [edi_communication_logs].flatten.first&.catalog_items&.last, http_method: 'PATCH', locale: orchestrator.locales.first, use_fba_sku: false) sku_to_use = catalog_item_or_variation.reported_vendor_sku(orchestrator.partner) sku_to_use = catalog_item_or_variation.amazon_fba_sku if use_fba_sku # see: https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-reference#patchlistingsitem uri = Addressable::URI.parse("#{orchestrator.}#{orchestrator.merchant_id}/#{sku_to_use}") marketplace_id = orchestrator.marketplace query_values = { # 'mode' => 'VALIDATION_PREVIEW', # force this for now 'marketplaceIds' => marketplace_id } # query_values['mode'] = 'VALIDATION_PREVIEW' if http_method == 'PUT' # force this for now for CREATE LISTING which uses a PUT # Is this necessary? # query_values['locale'] = locale.to_s.dup.tr('-', '_') if locale uri.query_values = query_values remote_path = uri.to_s logger.info "Sending to #{remote_path}" Edi::AmazonVc::Sender.new().process(transporter: orchestrator.transporter, transporter_profile: orchestrator.transporter_profile, data_type: 'json', remote_path: remote_path, partner: orchestrator.partner, http_method: http_method, category: :listing_data, edi_communication_logs: edi_communication_logs) # Which category to send, e.g order_confirm end |