Class: SpreeUberDirect::WebhookEvent

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree_uber_direct/webhook_event.rb

Overview

Idempotency + audit log for inbound Uber Direct webhook notifications.

Column named status on this table is Uber's own delivery status value (pending/pickup/pickup_complete/dropoff/delivered/canceled/returned/ shopping_completed) — this model's own pending/processed/failed processing state lives in the separate processing_status column, to avoid the two genuinely different meanings colliding on one name (DoorDash's own WebhookEvent didn't need this distinction since its payload field is called event_name, not status).

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.digest(raw_body) ⇒ Object



22
23
24
# File 'app/models/spree_uber_direct/webhook_event.rb', line 22

def self.digest(raw_body)
  Digest::SHA256.hexdigest(raw_body)
end

Instance Method Details

#mark_failed!(error) ⇒ Object



30
31
32
# File 'app/models/spree_uber_direct/webhook_event.rb', line 30

def mark_failed!(error)
  update!(processing_status: 'failed', processed_at: Time.current, error_message: error.to_s.truncate(1000))
end

#mark_processed!Object



26
27
28
# File 'app/models/spree_uber_direct/webhook_event.rb', line 26

def mark_processed!
  update!(processing_status: 'processed', processed_at: Time.current)
end