This webhook is used for the purpose of both creating and updating orders on Captain.AI. Only orders that are considered delivery orders are processed (if order. orderType.orderServiceType is equal to DeliveryByCourier). Please see ‘Technical Reference - Delivery Schema’ for what fields are consumed by Captain.AI.
This webhook is used for the purpose of clocking in/out drivers. Please see ‘Technical Reference - Personal Shift’ for what fields are consumed by Captain.AI.
Caus::Syrve::BatchSyncDriversWorker
)API call used: fetch_drivers (see Technical Reference - HTTP client below) ****
This code serves as an automated synchronization tool between Captain and Syrve systems, focusing on aligning driver records. It operates in two main phases: initially, it identifies accounts integrated with Syrve and triggers individual synchronization tasks for each. Then, for every account, it authenticates validity, retrieves the latest driver data from Syrve, and updates the local records in Captain. The synchronization logic specifically accounts for drivers flagged as isDeleted
in Syrve, marking such drivers as inactive in Captain to accurately mirror their employment status. This mechanism ensures both systems maintain consistent and up-to-date information on drivers.
Active vs. Inactive Drivers: The system carefully checks each driver's status. If a driver is marked as deleted (isDeleted
) on the Syrve platform, they are marked inactive in the local system, and a specific action (ClockOutAgent
) is performed to reflect their status accurately.
API call used: clockin OR clockout (see Technical Reference - HTTP client below) ****
Payload:
{
'organizationId': account.partners_external_identifier,
'terminalGroupId': agent.partner_data['terminal_group_id'],
'employeeId': agent.partners_external_identifier
}
API call used: update_order_delivery_status (see Technical Reference - HTTP client below) ****
Payload:
DELIVERY_STATUS_MAPPING = {
assigned_and_accepted_by_driver: 'Waiting',
collected: 'OnWay',
dropped_off: 'Delivered'
}
{
'organizationId': account.partners_external_identifier,
'orderId': order.partners_unique_internal_order_id,
'deliveryStatus': DELIVERY_STATUS_MAPPING[delivery_status],
// The following field is only sent if the delivery has a 'delivered_at' timestamp.
'deliveryDate': job.delivered_at.in_time_zone(time_zone).strftime('%F %T.%L')
}