Class: Edi::Google::PromotionSender

Inherits:
BaseEdiService show all
Defined in:
app/services/edi/google/promotion_sender.rb

Overview

Transmits this partner's staged promotion_data ECLs to Google via the
Merchant API v1, upserting each Promotion into the promotions data source
for the partner's country (one partner = one country = one source). Mirrors
Sender: transient failures (429 / 5xx / timeouts) are retried
per promotion with exponential backoff, and any unrecovered failure flips the
ECL to exception rather than silently shipping a partial promotion set
(inserts are upserts, so retry is safe).

Constant Summary collapse

MAX_INSERT_ATTEMPTS =

Per-promotion upsert attempts before a transient failure is recorded.

4

Constants included from RequestIdentifiable

RequestIdentifiable::REQUEST_ID_HEADERS

Constants included from AddressAbbreviator

AddressAbbreviator::MAX_LENGTH

Instance Attribute Summary

Attributes inherited from BaseEdiService

#orchestrator

Attributes inherited from BaseService

#options

Instance Method Summary collapse

Methods inherited from BaseEdiService

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

Methods included from RequestIdentifiable

#partner_request_id

Methods included from AddressAbbreviator

#abbreviate_street, #collect_street_originals, #record_address_abbreviation_notes

Methods inherited from BaseService

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

Constructor Details

This class inherits a constructor from Edi::BaseEdiService

Instance Method Details

#process(edi_communication_logs = nil) ⇒ Object

Returns the processed logs.

Parameters:

  • edi_communication_logs (Enumerable<EdiCommunicationLog>, nil) (defaults to: nil)

    defaults to this partner's ready/retry promotion_data logs.

Returns:

  • the processed logs.



19
20
21
22
23
24
25
26
27
28
# File 'app/services/edi/google/promotion_sender.rb', line 19

def process(edi_communication_logs = nil)
  logs = Array(
    edi_communication_logs || EdiCommunicationLog.requiring_processing
                                                 .where(partner: orchestrator.partner, category: 'promotion_data')
                                                 .order(:created_at)
                                                 .to_a
  )
  logs.each { |ecl| deliver(ecl) }
  logs
end