Class: Api::V1::ShipEngine::TrackingEventsController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- Api::V1::ShipEngine::TrackingEventsController
- Includes:
- ActionController::HttpAuthentication::Basic::ControllerMethods
- Defined in:
- app/controllers/api/v1/ship_engine/tracking_events_controller.rb
Overview
https://www.shipengine.com/docs/tracking/webhooks/
DEPRECATED: This controller has been replaced by Webhooks::V1::ShipengineController
which uses the WebhookLog architecture for audit trail and retry logic.
New endpoint: POST /webhooks/v1/shipengine
Old endpoint: POST /v1/ship_engine/track (this controller)
This controller now forwards requests to the new webhook system.
Instance Method Summary collapse
Instance Method Details
#track ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/api/v1/ship_engine/tracking_events_controller.rb', line 19 def track Rails.logger.warn '[DEPRECATION] ShipEngine webhook received on deprecated endpoint /v1/ship_engine/track' ErrorReporting.warning( 'ShipEngine webhook received on deprecated endpoint', old_endpoint: request.path, new_endpoint: '/webhooks/v1/shipengine', tracking_number: params.dig(:data, :tracking_number) ) # Forward to the new webhook system by ingesting directly raw_payload = request.raw_post payload = JSON.parse(raw_payload) rescue {} tracking_number = payload.dig('data', 'tracking_number') status_code = payload.dig('data', 'status_code') # Find shipment by tracking number shipment = find_shipment_by_tracking(tracking_number) webhook_log = WebhookLog.ingest!( provider: 'shipengine', category: 'tracking_update', resource_type: 'Shipment', resource_id: shipment&.id, external_id: "#{tracking_number}_#{status_code}_#{payload.dig('data', 'events', 0, 'occurred_at')}", data: payload, notes: "[DEPRECATED] ShipEngine tracking via old endpoint: #{tracking_number} -> #{status_code}" ) WebhookProcessorWorker.perform_async(webhook_log.id) render json: { message: 'Webhook received' }, status: :ok end |