Class: Edi::Openai::ProductDataProcessor

Inherits:
BaseEdiService show all
Defined in:
app/services/edi/openai/product_data_processor.rb

Overview

Builds the OpenAI Ads product feed (a GMC-compatible CSV of our sellable
catalog) and stages it as an outbound EdiCommunicationLog for Sender.

Reuses Feed::OpenaiAds::CatalogFeedGenerator for the catalog → CSV mapping.

Constant Summary

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, #process, #tagged_logger

Constructor Details

This class inherits a constructor from Edi::BaseEdiService

Instance Method Details

#callEdiCommunicationLog

Returns the staged outbound feed (state ready).

Returns:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/edi/openai/product_data_processor.rb', line 10

def call
  logger.info "Generating OpenAI Ads product feed for partner #{orchestrator.partner}"
  # OpenAI's feed connection is single-currency (Supported currencies: USD in
  # the Ads Manager), so ship only the USD catalog. The combined US+CA scope
  # sent ~700 CAD-priced rows (the CA catalog) that the USD connection rejected,
  # loading zero products.
  result = Feed::OpenaiAds::CatalogFeedGenerator.new.call(catalogs: Catalog.for_google_feed.where(currency: 'USD'))

  EdiCommunicationLog.create_outbound_file_from_data(
    data:           result.csv,
    file_extension: 'csv',
    partner:        orchestrator.partner,
    category:       'product_data',
    data_type:      'csv',
    file_info:      { product_count: result.product_count }
  )
end