Class: Edi::Amazon::FbaOrderMessageRetriever

Inherits:
BaseEdiService show all
Defined in:
app/services/edi/amazon/fba_order_message_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(po_numbers: []) ⇒ Object

Retrieves FBA (Fulfillment By Amazon) order messages according to the partner config
See: https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-reference



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/edi/amazon/fba_order_message_retriever.rb', line 5

def process(po_numbers: [])

  if po_numbers.any?
    remote_path = "#{orchestrator.order_message_remote_path}?MarketplaceIds=#{orchestrator.marketplace}&MaxResultsPerPage=100&AmazonOrderIds=#{po_numbers.join(',')}"
  else
    remote_path = "#{orchestrator.order_message_remote_path}?MarketplaceIds=#{orchestrator.marketplace}&MaxResultsPerPage=100&CreatedAfter=#{CGI.escape([Date.parse(Edi::Amazon::Orchestrator::GOLIVE_DATE_STR), 3.days.ago].max.to_date.iso8601)}&OrderStatuses=Shipped&FulfillmentChannels=AFN"
  end

  Edi::Amazon::OrderRetriever.new(options).process transporter: orchestrator.transporter,
                                              transporter_profile: orchestrator.transporter_profile,
                                              data_type: 'json',
                                              orchestrator:,
                                              remote_path: remote_path,
                                              partner: orchestrator.partner,
                                              category: :fba_order_batch
end