Class: Edi::AmazonVc::ListingItemValidationErrorsRetriever
- Inherits:
-
BaseEdiService
- Object
- BaseService
- BaseEdiService
- Edi::AmazonVc::ListingItemValidationErrorsRetriever
- Defined in:
- app/services/edi/amazon_vc/listing_item_validation_errors_retriever.rb
Constant Summary
Constants included from Edi::AddressAbbreviator
Edi::AddressAbbreviator::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseEdiService
Instance Method Summary collapse
-
#process(sku:, product_type:, locale: nil, file_info: {}) ⇒ Object
Retrieve listing item validation errors by sending a PATCH with mode=VALIDATION_PREVIEW and data to update the sku to itself.
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:, product_type:, locale: nil, file_info: {}) ⇒ Object
Retrieve listing item validation errors by sending a PATCH with mode=VALIDATION_PREVIEW and data to update the sku to itself. This is the only reliable way we have to reveal a listing item's VALIDATION errors which prevent further changes (this is distinct from issues which do not prevent changes).
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 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/services/edi/amazon_vc/listing_item_validation_errors_retriever.rb', line 6 def process(sku:, product_type:, locale: nil, file_info: {}) # https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-use-case-guide # https://developer-docs.amazon.com/sp-api/docs/catalog-items-api-v2022-04-01-use-case-guide uri = Addressable::URI.parse("#{orchestrator.catalog_item_information_remote_path}/#{orchestrator.vendor_code}/#{sku}") marketplace_id = orchestrator.marketplace query_values = { 'mode' => 'VALIDATION_PREVIEW', 'marketplaceIds' => marketplace_id } query_values['locale'] = locale.to_s.dup.tr('-', '_') if locale uri.query_values = query_values data_to_send = %( { "productType": "#{product_type}", "patches":[ { "op":"replace", "path":"/attributes/part_number", "value": [ { "value": "#{sku}", "marketplace_id": "#{marketplace_id}" } ] } ] } ) remote_path = uri.to_s puts "Requesting from #{remote_path}" ecls = Edi::AmazonVc::Retriever.new().process(transporter: orchestrator.transporter, transporter_profile: orchestrator.transporter_profile, data_type: 'json', remote_path:, partner: orchestrator.partner, category: :catalog_item_information, store_to_upload: false, http_method: 'PATCH', data_to_send:, file_info:) ecls.first # we only deal with one ecl end |