Class: Edi::MiraklSeller::ConfirmMessageProcessor
- Inherits:
-
BaseEdiService
- Object
- BaseService
- BaseEdiService
- Edi::MiraklSeller::ConfirmMessageProcessor
- Defined in:
- app/services/edi/mirakl_seller/confirm_message_processor.rb
Overview
Service object: confirm message processor.
Constant Summary collapse
- BESTBUY_CA_CARRIER_CODES =
Best Buy CA's registered Mirakl carrier codes (SH21 GET /api/shipping/carriers,
verified 2026-07-31), keyed by our internal shipments.carrier name. Both the
main and outlet shops live on marketplace.bestbuy.ca, so they share a registry. { 'Canpar' => 'CPAR', 'Canadapost' => 'CPCL', 'Purolator' => 'PRLA', 'FedEx' => 'FEDX', 'UPS' => 'UPSN', 'USPS' => 'USPS', 'DhlExpress' => 'DHL' }.freeze
Constants included from RequestIdentifiable
RequestIdentifiable::REQUEST_ID_HEADERS
Constants included from AddressAbbreviator
AddressAbbreviator::MAX_LENGTH
Instance Attribute Summary
Attributes inherited from BaseEdiService
Attributes inherited from BaseService
Instance Method Summary collapse
- #acknowledge_order(order, options = {}) ⇒ void
- #build_confirm_message_from_invoice(invoice) ⇒ Object
- #cancel_order(order) ⇒ Object
- #confirm_invoice(invoice) ⇒ Object
-
#process(confirm_message, category, order = nil) ⇒ Object
Picks up the edi communication log in the queue ready to process, generate acknowledgements/shipments.
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
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
#acknowledge_order(order, options = {}) ⇒ void
This method returns an undefined value.
23 24 25 |
# File 'app/services/edi/mirakl_seller/confirm_message_processor.rb', line 23 def acknowledge_order(order, = {}) # do nothing for Mirakl. end |
#build_confirm_message_from_invoice(invoice) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/services/edi/mirakl_seller/confirm_message_processor.rb', line 36 def (invoice) delivery = invoice.delivery partner_namespace = (orchestrator.try(:namespace) || orchestrator.partner).to_sym tracking_number = delivery&.master_tracking_number || delivery&.carrier_bol carrier_code = case partner_namespace when :bestbuy_ca, :bestbuy_ca_outlet BESTBUY_CA_CARRIER_CODES[delivery&.reported_carrier] when :bricodepot_es 'courier_gls' else 'gls' # EU Mirakl partners all dropship via GLS end if carrier_code { carrier_code: carrier_code, tracking_number: tracking_number } else # OR23: unregistered carriers take carrier_name (+ tracking URL) instead # of carrier_code — an unmapped carrier degrades to this rather than 400ing. { carrier_name: delivery&.display_carrier_name, carrier_url: delivery&.tracking_link, tracking_number: tracking_number } end end |
#cancel_order(order) ⇒ Object
27 28 29 |
# File 'app/services/edi/mirakl_seller/confirm_message_processor.rb', line 27 def cancel_order(order) # do nothing for Mirakl end |
#confirm_invoice(invoice) ⇒ Object
31 32 33 34 |
# File 'app/services/edi/mirakl_seller/confirm_message_processor.rb', line 31 def confirm_invoice(invoice) m = (invoice) process(m, :order_confirm, invoice.order) end |
#process(confirm_message, category, order = nil) ⇒ Object
Picks up the edi communication log in the queue ready to process, generate acknowledgements/shipments
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/services/edi/mirakl_seller/confirm_message_processor.rb', line 65 def process(, category, order = nil) edi_log = nil EdiCommunicationLog.transaction do edi_log = EdiCommunicationLog.create! partner: orchestrator.partner, category: category, data: .to_json, data_type: 'json', transmit_datetime: Time.current end edi_log.edi_documents.create!(order: order) if order.present? edi_log end |