Class: WebhookProcessors::AmazonSpApiProcessor
- Inherits:
-
Object
- Object
- WebhookProcessors::AmazonSpApiProcessor
- Defined in:
- app/services/webhook_processors/amazon_sp_api_processor.rb
Overview
Processor for Amazon SP-API notifications, drained from SQS into
webhook_logs by AmazonSqsNotificationPollerWorker
(category = notificationType downcased).
Handlers stay thin and hand off to existing Amazon EDI machinery.
Categories without a handler complete as 'noted' — observability first;
a per-type action lands together with its subscription.
Class Method Summary collapse
-
.call(webhook_log) ⇒ Hash
Process one SP-API notification row.
Instance Method Summary collapse
-
#call ⇒ Hash
Result stored on WebhookLog#response_data.
-
#initialize(webhook_log) ⇒ AmazonSpApiProcessor
constructor
A new instance of AmazonSpApiProcessor.
Constructor Details
#initialize(webhook_log) ⇒ AmazonSpApiProcessor
Returns a new instance of AmazonSpApiProcessor.
28 29 30 31 |
# File 'app/services/webhook_processors/amazon_sp_api_processor.rb', line 28 def initialize(webhook_log) @webhook_log = webhook_log @data = webhook_log.data end |
Class Method Details
.call(webhook_log) ⇒ Hash
Process one SP-API notification row.
23 24 25 |
# File 'app/services/webhook_processors/amazon_sp_api_processor.rb', line 23 def self.call(webhook_log) new(webhook_log).call end |
Instance Method Details
#call ⇒ Hash
Returns result stored on WebhookLog#response_data.
34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/webhook_processors/amazon_sp_api_processor.rb', line 34 def call case @webhook_log.category when 'feed_processing_finished' then feed_processing_finished when 'report_processing_finished' then report_processing_finished when 'listings_item_issues_change' then listings_item_issues_change when 'any_offer_changed' then any_offer_changed else { status: 'noted', reason: "no handler for #{@webhook_log.category}" } end end |