This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
api-trucks-for-you [2018/08/02 10:50] hari [Request] |
api-trucks-for-you [2018/08/06 10:12] 111.125.228.102 [Trucks for You API] |
||
---|---|---|---|
Line 1: | Line 1: | ||
======== Trucks for You API ======== | ======== Trucks for You API ======== | ||
- | <hidden> | + | |
====== Creation and registration ====== | ====== Creation and registration ====== | ||
Line 1060: | Line 1060: | ||
Body | Body | ||
<code> | <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> | </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 ==== | ==== Response if token is invalid ==== |