Get Draft Bookings
The getDraftBookings API endpoint is used to retrieve a list of all current unassigned, incomplete, or otherwise unconfirmed bookings stored with a status of Draft. This API natively scopes the query to return only draft bookings created by the provided userId parameter. The primary data model returned by this API is BookingDetails.java represented comprehensively as JSON.
Endpoint
GET /rest/booking/getDraftBookings/{userId}/{authKey}
Path Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
userId | String | The active username. This acts as both an authentication credential and a filter applied to the drafted list. | Yes |
authKey | String | A valid Authorization token for this user, required to ensure identity execution checks. | Yes |
Response
The response is a JSON array of BookingDetails models without any class wrapper (exclusions applied via SpecificClassExclusionStrategy).
Success Response (200 OK):
[
{
"bookingID": "TICKET100802",
"customerName": "Acme Corp",
"refNo": "BO-12293-122",
"status": "Draft",
"orderType": "SHIPMENT",
"pickupAddress": [
{
"addressId": "ADD89",
"city": "Chennai",
"country": 105
}
],
"deliveryAddress": [
{
"addressId": "ADD90",
"city": "Bengaluru",
"country": 105
}
],
"truckRequirements": [
{
"truckType": "Semi-Trailer",
"truckTonnage": "12T"
}
]
}
]
Unauthorized (401 Unauthorized):
{
"success": false,
"message": "Unauthorized"
}
Internal Server Error (500 Internal Server Error):
{
"success": false,
"message": "Internal server error"
}
Business Logic
-
Authentication Strategy: Every request must first pass
checkIfAuthKeyIsValid()to ensure the user credential matching tenant parameters is legitimate. If not, the request rejects gracefully with401 Unauthorized. -
Database Querying Flow: The service layer (
BookingService.java) queries the backend using HibernateCriteriarestricted exclusively toRestrictions.eq("status", TmsConstants.STATUS_DRAFT). Furthermore, if theuserIdparameter evaluates to valid string, the criteria builder is chained withRestrictions.eq("bookedBy", userId)guaranteeing isolation of an individual users' drafts. -
Data Serialization Restrictions: Gson builder parses the raw List of
BookingDetailsreturned by database into JSON formats. By leveragingSpecificClassExclusionStrategy(), properties deemed unsuitable (like circularly dependent tables or deeply nested mappings) are automatically detached to ensure lightweight responses.