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 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/<objects>
where <objects> is one of cities, truck-types, trucks or drivers
Headers
Authorization: Bearer <admin-token>
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": <truck-status>,
"city": "current-city"
},
{ ... more trucks ... }
]
where <truck-status> 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
Response if admin is not allowed to list objects
Response for some other error
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 <admin-token>
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-<field-name> 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 <object type>-NOT-FOUND e.g. CITY-NOT-FOUND, TRUCK-TYPE-NOT-FOUND
Body: none
Response for some other error
Headers
HTTP/1.1 500 ERROR
Content-Type: text/plain
Body
Sample error message.
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-<field-name>, 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-<field-name>, 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 <object-type>-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