This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
api-trucks-for-you [2018/08/01 11:56] hari [Response if request is successful] |
api-trucks-for-you [2018/08/13 11:53] (current) 103.226.237.56 [Response for a successful request] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======== Trucks for You API ======== | ======== Trucks for You API ======== | ||
| - | <hidden> | + | |
| ====== Creation and registration ====== | ====== Creation and registration ====== | ||
| Line 29: | Line 29: | ||
| <code> | <code> | ||
| HTTP/1.1 202 ACCEPTED | HTTP/1.1 202 ACCEPTED | ||
| + | </code> | ||
| + | |||
| + | Body: none | ||
| + | |||
| + | ==== Response if phone parameter is missing ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 400 INVALID-PHONE | ||
| </code> | </code> | ||
| Line 651: | Line 660: | ||
| </code> | </code> | ||
| - | </hidden> | ||
| ====== Administration ====== | ====== Administration ====== | ||
| ===== Admin: List of trip requests ===== | ===== Admin: List of trip requests ===== | ||
| Line 913: | Line 921: | ||
| API call | API call | ||
| <code> | <code> | ||
| - | POST https://tfy.tech101.in/api/v1/trips | + | POST https://tfy.tech101.in/api/v1/bookings |
| </code> | </code> | ||
| Line 941: | Line 949: | ||
| <code> | <code> | ||
| { | { | ||
| - | "uuid" | + | "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 | ||
| } | } | ||
| </code> | </code> | ||
| Line 997: | Line 1043: | ||
| Sample error message | Sample error message | ||
| </code> | </code> | ||
| + | |||
| + | |||
| + | ===== Admin: List all determined trips ===== | ||
| + | |||
| + | ==== Request ==== | ||
| + | |||
| + | API call | ||
| + | <code> | ||
| + | GET https://tfy.tech101.in/api/v1/trips | ||
| + | </code> | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | Authorization: Bearer user-token | ||
| + | </code> | ||
| + | |||
| + | ==== Response if request is successful ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 200 OK | ||
| + | </code> | ||
| + | |||
| + | Body | ||
| + | <code> | ||
| + | [ | ||
| + | { | ||
| + | "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 ... } | ||
| + | ] | ||
| + | </code> | ||
| + | |||
| + | ==== Response when request is successful, but there are no trips ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 204 DONE | ||
| + | </code> | ||
| + | |||
| + | ==== Response if token is invalid ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 401 INVALID-TOKEN | ||
| + | </code> | ||
| + | |||
| + | ==== Response if forbidden ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 403 FORBIDDEN | ||
| + | </code> | ||
| + | |||
| + | |||
| + | |||
| + | ==== Response for any other error ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 500 ERROR | ||
| + | Content-Type: text/plain | ||
| + | </code> | ||
| + | |||
| + | Body | ||
| + | <code> | ||
| + | Sample error message | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ===== Admin: Create a new trip ===== | ||
| + | |||
| + | ==== Request ==== | ||
| + | |||
| + | API call | ||
| + | <code> | ||
| + | POST https://tfy.tech101.in/api/v1/trips | ||
| + | </code> | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | Authorization: Bearer user-token | ||
| + | Content-Type: application/json | ||
| + | </code> | ||
| + | |||
| + | Body | ||
| + | <code> | ||
| + | { | ||
| + | "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" | ||
| + | } | ||
| + | } | ||
| + | </code> | ||
| + | |||
| + | ==== Response if request is successful ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 200 OK | ||
| + | </code> | ||
| + | |||
| + | Body | ||
| + | <code> | ||
| + | { | ||
| + | "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" | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </code> | ||
| + | |||
| + | |||
| + | ==== Response if token is invalid ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 401 INVALID-TOKEN | ||
| + | </code> | ||
| + | |||
| + | ==== Response if forbidden ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 403 FORBIDDEN | ||
| + | </code> | ||
| + | |||
| + | ==== Response if fields are missing or invalid ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 400 INVALID-<field-name> | ||
| + | Content-Type: text/plain | ||
| + | </code> | ||
| + | |||
| + | Body | ||
| + | <code> | ||
| + | Validation error specific to the error in the field | ||
| + | </code> | ||
| + | |||
| + | ==== Response if underlying objects don't exist ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 404 <object-type>-NOT-FOUND | ||
| + | </code> | ||
| + | |||
| + | ==== Response for any other error ==== | ||
| + | |||
| + | Headers | ||
| + | <code> | ||
| + | HTTP/1.1 500 ERROR | ||
| + | Content-Type: text/plain | ||
| + | </code> | ||
| + | |||
| + | Body | ||
| + | <code> | ||
| + | Sample error message | ||
| + | </code> | ||
| + | |||