======== Trucks for You API ========
====== Creation and registration ======
===== Hirer / Driver: Request TOTP =====
==== Request ====
API call
POST https://tfy.tech101.in/api/v1/totp
Headers:
Content-Type: application/json
Body
{ "phone": "phone-number" }
==== Response for a successful request ====
Headers
HTTP/1.1 202 ACCEPTED
Body: none
==== Response if phone parameter is missing ====
Headers
HTTP/1.1 400 INVALID-PHONE
Body: none
==== Response if the user doesn't exist ====
Headers
HTTP/1.1 404 USER-NOT-FOUND
Body: none
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
This is a sample error message.
===== Hirer / Driver: Login =====
==== Request ====
API call
POST https://tfy.tech101.in/api/v1/oauth/token
Headers
Content-Type: application/json
Body
{
"grant_type": "password"
, "username": "the-username"
, "password": "the-totp"
, "scope": "hirer:all" or "driver:all"
}
==== Response if successful ====
Headers
HTTP/1.1 200 OK
Content-Type: application/json
Body
{
"access_token": "the-access-token"
, "token_type": "bearer"
, "scope": "hirer:all" or "driver:all"
}
==== Response if user doesn't exist ====
Headers
HTTP/1.1 404 HIRER-NOT-FOUND or DRIVER-NOT-FOUND
Body: none
==== Response if TOTP is wrong ====
Headers
HTTP/1.1 401 INVALID-TOTP
Body: none
==== Response for other errors ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
This is a sample error message.
===== Admin: Login =====
==== Request ====
API call
POST https://tfy.tech101.in/api/v1/oauth/token
Headers
Content-Type: application/json
Body
{
"grant_type": "password"
, "username": "admin-username"
, "password": "admin-password"
, "scope": "all:all"
}
==== Response if successful ====
Headers
HTTP/1.1 200 OK
Content-Type: application/json
Body
{
"access_token": "the-access-token"
, "token_type": "bearer"
, "scope": "hirer:all" or "driver:all"
}
==== Response if admin user doesn't exist ====
Headers
HTTP/1.1 404 ADMIN-NOT-FOUND
Body: none
==== Response if password is wrong ====
Headers
HTTP/1.1 401 INVALID-PASSWORD
Body: none
==== Response for other errors ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
This is a sample error message.
===== List of cities / truck types / trucks / drivers =====
==== Request ====
API call
GET https://tfy.tech101.in/api/v1/
where is one of cities, truck-types, trucks or drivers
Headers
Authorization: Bearer
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Content-Type: application/json
Body for cities
[
{
"id": "uuid-of-city",
"name": "name-of-city"
},
{ ... more cities ... }
]
Body for truck types
[
{
"id": "uuid-of-truck-type",
"name": "name-of-truck-type",
"img": "https://path/to/icon/of/truck/type"
},
{ ... more truck types ... }
]
Body for trucks
[
{
"id": "uuid-of-truck",
"status": ,
"city": "current-city"
},
{ ... more trucks ... }
]
where is a status code indicating the role that the truck is playing right now. It can be one of the following numbers
* 0: Truck is free for hire
* 1: Truck is provisionally allotted to a trip
* 2: Truck is confirmed for a trip
* 3: Truck is at loading point
* 4: Truck is weighed and loaded
* 5: Truck is in transit
* 6: Truck is at unloading point
* 7: Truck is unloaded and weighed
Body for drivers
[
{
"id": "uuid-of-driver",
"name": "name-of-driver",
"license": "license-number-of-driver"
},
{ ... more drivers ... }
]
==== Response if admin token is invalid ====
Headers
==== Response if admin is not allowed to list objects ====
Headers
==== Response for some other error ====
Headers
Body
===== Admin: Add a city / truck type / truck / driver =====
==== Request ====
API call
POST https://tfy.tech101.in/api/v1/cities
POST https://tfy.tech101.in/api/v1/truck-types
POST https://tfy.tech101.in/api/v1/trucks
POST https://tfy.tech101.in/api/v1/drivers
Headers
Authorization: Bearer
Content-Type: application/json
Body for city
{ "name": "city-name" }
Body for truck type
{
"name": "name-of-truck-type"
}
Body for truck
{
"registration": {
"id": "truck's-registration-number"
, "expiry": "expiry-date-of-registration"
}
, "type": "uuid-of-truck-type"
, "capacity": "capacity-in-tonnes"
, "city": "uuid-of-city-where-the-truck-is"
}
Body for driver
{
"name": "driver-name"
, "license: {
"id": "driver's-license-number"
, "expiry": "expiry-date-of-license"
}
, "phone": "phone-number-of-driver"
}
==== Response if successful ====
Headers
HTTP/1.1 200 OK
Content-Type: application/json
Body for city
{
"id": "uuid-of-city"
, "name": "name-of-city"
}
Body for truck type
{
"id": "uuid-of-truck-type"
, "name": "name-of-truck-type"
, "img": "https://path/to/truck/type/icon"
}
Body for truck
{
"id": "uuid-of-truck"
, "registration": {
"id": "registration-number-of-truck"
, "expiry": "expiry-date-for-registration"
}
, "type": "uuid-of-truck-type"
, "capacity": capacity-in-tonnes
, "img": {
"self": "https://path/to/image/of/truck"
, "rc": "https://path/to/image/of/rc/book"
}
, "driver": "uuid-of-driver-assigned"
}
}
Body for driver
{
"id": "uuid-of-driver"
, "name": "driver's name"
, "license": {
"id": "license-number-of-driver"
, "expiry": "expiry-date-of-license"
}
, "phone": "phone-number-of-driver"
, "img": {
"self": "https://path/to/image/of/driver"
, "license": "https://path/to/image/of/license"
}
, "truck": "uuid-of-truck-assigned"
}
==== Response if admin token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
Body: none
==== Response if token doesn't have sufficient permissions ====
Headers
HTTP/1.1 403 FORBIDDEN
Body: none
==== Response if fields are missing or invalid ====
Headers
HTTP/1.1 400 INVALID- e.g. INVALID-CITY-NAME
Content-Type: text/plain
Body
Validation message specific to invalid field
==== Response for some other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
===== Admin: Hide / unhide city / truck type / truck / driver =====
==== Request ====
API call
PATCH https://tfy.tech101.in/api/v1/cities/uuid-of-city
PATCH https://tfy.tech101.in/api/v1/truck-types/uuid-of-truck-type
PATCH https://tfy.tech101.in/api/v1/trucks/uuid-of-truck
PATCH https://tfy.tech101.in/api/v1/drivers/uuid-of-truck
Headers
Authorization: Bearer admin-token
Content-Type: application/json
Body
{ "isHidden": true for hide / false for unhide }
==== Response if request is successful ====
Headers
HTTP/1.1 204 DONE
Body: none
==== Response if admin token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
Body: none
==== Response if operation is forbidden for this user ====
Headers
HTTP/1.1 403 FORBIDDEN
Body: none
==== Response if underlying object is not found ====
Headers
HTTP/1.1 404
Body: none
==== Response for some other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message.
===== Admin: Upload media =====
==== Request ====
API call
POST https://tfy.tech101.in/api/v1/media
Headers
Authorization: Bearer admin-token
Content-Type: image/jpeg or image/png
Body: byte array of image
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Content-Type: text/plain
Body
https://path/of/uploaded/image
==== Response if admin token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if uploading is forbidden ====
Headers
HTTP/1.1 403 FORBIDDEN
==== Response if fields are missing or invalid ====
Headers
HTTP/1.1 400 INVALID-, e.g. INVALID-MIME, INVALID-JPEG
Content-Type: text/plain
Body
Validation error specific to the error in the field
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
===== Admin: Assign photo to truck / driver =====
==== Request ====
API call
PATCH https://tfy.tech101.in/api/v1/trucks/uuid-of-truck
PATCH https://tfy.tech101.in/api/v1/drivers/uuid-of-driver
PATCH https://tfy.tech101.in/api/v1/truck-types/uuid-of-truck-type
Headers
Authorization: Bearer admin-token
Content-Type: application/json
Body for truck
{
"img": {
"self": "https://path/to/truck/photo"
AND / OR
, "rc": "https://path/to/truck/rc/book/photo"
}
}
Body for driver
{
"img": {
"self": "https://path/to/driver/photo"
AND / OR
, "license": "https://path/to/license/photo"
}
}
Body for truck type
{ "img": "https://path/to/icon/of/truck/type" }
==== Response if request is successful ====
Headers
HTTP/1.1 204 DONE
==== Response if admin token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if assigning photos is forbidden ====
Headers
HTTP/1.1 403 FORBIDDEN
==== Response if fields are missing or invalid ====
Headers
HTTP/1.1 400 INVALID-, e.g. INVALID-PATH
Content-Type: text/plain
Body
Validation error specific to the error in the field
==== Response if underlying objects (truck, driver or photo) doesn't exist ====
Headers
HTTP/1.1 404 -NOT-FOUND, e.g. TRUCK-NOT-FOUND
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
====== Administration ======
===== Admin: List of trip requests =====
==== Request ====
API call
GET https://tfy.tech101.in/api/v1/hire-requests
Headers
Authorization: Bearer admin-token
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Body
[
{
"id": "hire-request-id",
"dates": {
"load": "desired-loading-date",
"delivery": "desired-delivery-date"
},
"cities": {
"load": {
"id": "uuid-of-city",
"name": "name-of-city"
},
"delivery": {
"id": "uuid-of-city",
"name": "name-of-city"
}
}
},
{ ... more requests ... }
]
==== Response if admin token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if listing trip requests is forbidden ====
Headers
HTTP/1.1 403 FORBIDDEN
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
===== Admin: View one trip request =====
==== Request ====
API call
https://tfy.tech101.in/api/v1/hire-requests/uuid-of-request
Headers
Authorization: Bearer admin-token
Content-Type: application/json
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Body
{
"id": "hire-request-id",
"hirer": {
"id": "uuid-of-hirer",
"name": "name-of-hirer",
"phone": "phone-number-of-hirer"
},
"dates": {
"load": "desired-loading-date",
"delivery": "desired-delivery-date"
},
"cities": {
"load": {
"id": "uuid-of-city",
"name": "name-of-city"
},
"delivery": {
"id": "uuid-of-city",
"name": "name-of-city"
}
},
"truckType": {
"id": "uuid-of-truck-type",
"name": "name-of-truck-type"
},
"capacity": capacity-in-tonnes,
"addresses": {
"load": "complete-loading-address",
"delivery": "complete-delivery-address"
},
"tariff": quoted-tariff
}
==== Response if token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if view a trip request is forbidden ====
Headers
HTTP/1.1 403 FORBIDDEN
==== Response if request UUID is not valid ====
Headers
HTTP/1.1 400 INVALID-REQUEST-ID
Content-Type: text/plain
==== Response if hire request doesn't exist ====
Headers
HTTP/1.1 404 HIRE-REQUEST-NOT-FOUND
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
===== Admin: View trucks that fit a suggestion =====
==== Request ====
API call
GET https://tfy.tech101.in/api/v1/hire-requests/uuid-of-request/trucks
Headers
Authorization: Bearer admin-token
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Content-Type: application/json
Body
[
"truck": {
"id": "uuid-of-truck",
"registration": "registration-number-of-truck"
},
"driver": {
"id": "uuid-of-driver",
"name": "name-of-driver",
"phone": ""
}
]
==== Response if token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if forbidden ====
Headers
HTTP/1.1 403 FORBIDDEN
==== Response if hire request is invalid ====
Headers
HTTP/1.1 400 INVALID-HIRE-REQUEST
Content-Type: text/plain
Body
Hire request must be a UUID.
==== Response if hire request doesn't exist ====
Headers
HTTP/1.1 404 HIRE-REQUEST-NOT-FOUND
where can be HIRE-REQUEST or SUGGESTION
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
===== Admin: Assign a truck to a request =====
==== Request ====
API call
POST https://tfy.tech101.in/api/v1/bookings
Headers
Authorization: Bearer user-token
Content-Type: application/json
Body
{
"requestId": "uuid-of-hire-request",
"truckId": "uuid-of-assigned-truck"
}
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Content-Type: application/json
Body
{
"id": "uuid-of-booking",
"hirer": {
"id": "uuid-of-hirer",
"name": "name-of-hirer",
"phone": "phone-number-of-hirer"
},
"truck": {
"id": "uuid-of-truck",
"registration": "registration-number-of-truck",
"type": {
"id": "uuid-of-truck-type",
"name": "name-of-truck-type"
}
, "capacity": capacity-in-tonnes
},
"driver": {
"id": "uuid-of-driver",
"name": "name-of-driver",
"phone": "phone-number-of-driver"
},
"plan": {
"load": {
"date": "YYYY-MM-DD, date of loading",
"city": {
"id": "uuid-of-city",
"name": "name-of-city"
},
"address": "full-address-of-loading-point"
},
"delivery": {
"date": "YYYY-MM-DD, date of delivery",
"city": {
"id": "uuid-of-city",
"name": "name-of-city"
},
"address": "full-address-of-delivery-point"
}
},
"tariff": tariff-in-rupees
}
==== Response if token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if forbidden ====
Headers
HTTP/1.1 403 FORBIDDEN
==== Response if fields are missing or invalid ====
Headers
HTTP/1.1 400 INVALID-
Content-Type: text/plain
where is one of
* HIRE-REQUEST
* TRUCK
Body
Validation error specific to the error in the field
==== Response if underlying objects don't exist ====
Headers
HTTP/1.1 404 -NOT-FOUND
where can be one of
* HIRE-REQUEST
* TRUCK
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
===== Admin: List all determined trips =====
==== Request ====
API call
GET https://tfy.tech101.in/api/v1/trips
Headers
Authorization: Bearer user-token
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Body
[
{
"id": "uuid-of-trip",
"truck": {
"id": "uuid-of-truck",
"registration": "registration-number"
},
"source":{
"date": "YYYY-MM-DD, date when truck leaves source",
"city": {
"id": "uuid-of-city",
"name": "name-of-city"
},
},
"destination": {
"date": "YYYY-MM-DD, date when truck reaches destination",
"city": {
"id": "uuid-of-city",
"name": "name-of-city"
}
}
},
{ ... more trips ... }
]
==== Response when request is successful, but there are no trips ====
Headers
HTTP/1.1 204 DONE
==== Response if token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if forbidden ====
Headers
HTTP/1.1 403 FORBIDDEN
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
===== Admin: Create a new trip =====
==== Request ====
API call
POST https://tfy.tech101.in/api/v1/trips
Headers
Authorization: Bearer user-token
Content-Type: application/json
Body
{
"truckId": "uuid-of-truck",
"source": {
"date": "YYYY-MM-DD, date when truck leaves source",
"cityId": "uuid-of-city-from-where-truck-leaves"
},
"destination": {
"date": "YYYY-MM-DD, date when truck reaches destination",
"cityId": "uuid-of-city-where-truck-reaches"
}
}
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Body
{
"id": "uuid-of-trip",
"truck": {
"id": "uuid-of-truck",
"registration": "registration-number-of-truck"
},
"source": {
"date": "YYYY-MM-DD, date when truck leaves source",
"city": {
"id": "uuid-of-city",
"name": "name-of-city-from-where-truck-leaves"
}
},
"destination": {
"date": "YYYY-MM-DD, date when truck reaches destination",
"city": {
"id": "uuid-of-city",
"name": "name-of-city-where-truck-reaches"
}
}
}
==== Response if token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if forbidden ====
Headers
HTTP/1.1 403 FORBIDDEN
==== Response if fields are missing or invalid ====
Headers
HTTP/1.1 400 INVALID-
Content-Type: text/plain
Body
Validation error specific to the error in the field
==== Response if underlying objects don't exist ====
Headers
HTTP/1.1 404 -NOT-FOUND
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
====== Hiring a truck ======
===== Hirer: Request for a truck =====
==== Request ====
API call
POST https://tfy.tech101.in/api/v1/hire-requests
Headers
Authorization: Bearer hirer-token
Content-Type: application/json
Body
{
"id": "uuid-for-request-generated-by-app"
, "source": "uuid-of-source-city"
, "destination": "uuid-of-destination-city"
, "dateLoad": "YYYY-MM-DD"
, "dateDelivery": "YYYY-MM-DD"
, "weight": weight-in-tonnes
, "truckType": "uuid-of-truck-type"
}
==== Response if request is successful ====
Headers
HTTP/1.1 200 OK
Content-Type: application/json
Body
{
"requestId": "uuid-of-this-request-for-truck"
"suggestions": [
{
"id": "uuid-for-suggestion"
, "capacity": "capacity-in-tonnes"
, "dateSource": "unix timestamp with time 00:00:00, date on which truck leaves source city"
, "dateDestination": "unix timestamp with time 23:59:59, date on which truck reaches destination city"
, "tariff": tariff-in-rupees
}
, { ... more suggestions ... }
]
}
==== Response if token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if fields are invalid ====
Headers
HTTP/1.1 400 INVALID-
Content-Type: text/plain
where field-name can be one of
SOURCE, DESTINATION, LOAD-DATE, DELIVERY-DATE, TRUCK-TYPE, WEIGHT
Body
Validation error specific to the error in the field
==== Response if one of the objects in the request does not exist ====
Headers
HTTP/1.1 404
where object-type can be one of CITY, TRUCK-TYPE
==== Response for any other error ====
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message
===== Hirer: Pick a suggestion =====
==== Request ====
API call
PATCH https://tfy.tech101.in/api/v1/hire-requests/request-id
The request-id is the same as the one returned in the hiring request as requestId.
Headers
Authorization: Bearer hirer-token
Content-Type: application/json
Body
{
"suggestionId": "uuid-of-picked-suggestion"
, "addressSource": "complete address of source"
, "addressDestination": "complete address of destination"
}
==== Response if request is successful ====
Headers
HTTP/1.1 204 DONE
==== Response if token is invalid ====
Headers
HTTP/1.1 401 INVALID-TOKEN
==== Response if fields are invalid ====
Headers
HTTP/1.1 400 INVALID-
Content-Type: text/plain
where field-name can be one of
SUGGESTION, SOURCE-ADDRESS, SOURCE-ADDRESS
Body
Validation error specific to the error in the field
==== Response if one of the objects does not exist ====
Headers
HTTP/1.1 404
where