Class: SpreeSquare::InventoryWebhookJob
- Defined in:
- app/jobs/spree_square/inventory_webhook_job.rb
Overview
Handles inventory.count.updated. Unlike the catalog webhook, this
payload is fully actionable on its own — catalog_object_id, location_id,
and the new quantity all arrive inline, no follow-up API call needed.
Instance Method Summary collapse
Instance Method Details
#perform(webhook_event_id) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/jobs/spree_square/inventory_webhook_job.rb', line 11 def perform(webhook_event_id) event = SpreeSquare::WebhookEvent.find(webhook_event_id) counts = event.payload.dig('data', 'object', 'inventory_counts') || [] counts.each do |count| SpreeSquare::InventorySync.call( catalog_object_id: count['catalog_object_id'], location_id: count['location_id'], quantity: count['quantity'], state: count['state'] ) end event.mark_processed! end |