Class: Edi::Walmart::CatalogItemInformationProcessor
- Inherits:
-
BaseEdiService
- Object
- BaseService
- BaseEdiService
- Edi::Walmart::CatalogItemInformationProcessor
- Defined in:
- app/services/edi/walmart/catalog_item_information_processor.rb
Defined Under Namespace
Classes: ProcessResult
Constant Summary
Constants included from AddressAbbreviator
AddressAbbreviator::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseEdiService
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 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(ecl, dry_run: false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/services/edi/walmart/catalog_item_information_processor.rb', line 33 def process(ecl, dry_run: false) data = JSON.parse(ecl.data).with_indifferent_access items = data[:ItemResponse] || [data] # Handle both batch and single item responses processed = 0 skipped = 0 errors = [] items.each do |item_data| begin result = process_item(item_data, dry_run: dry_run) if result == :processed processed += 1 else skipped += 1 end rescue StandardError => e errors << { sku: item_data[:sku], error: e. } ErrorReporting.error(e, sku: item_data[:sku], ecl_id: ecl.id) end end ecl.complete! unless dry_run ProcessResult.new(processed: processed, skipped: skipped, errors: errors) end |