Field Name | Unique? | Validation |
---|---|---|
registration | ✔ | ^[a-zA-Z0-9]+$ |
year | ^[0-9]{4}$ | |
transmission | ('M', 'A') | |
seat_number | ^[0-9]{1,2}$ | |
fuel_type | ^[a-zA-Z0-9_ ]+$ | |
name | ||
asset_no | ||
key_no | ||
body_colour | ||
license_type | ||
kms_start | ||
kms_current | ||
availability_weekend | ||
availability_afterhours | ||
comments | ||
vehicle_cost | ||
vehicle_cost_type |
Resource | 1-to-1 | 1-to-many | many-to-1 | many-to-many |
---|---|---|---|---|
make | ✔ | |||
model | ✔ | |||
features | ✔ | |||
company | ✔ | |||
branch | ✔ | |||
cost-centre | ✔ |
Returns a list of vehicle hashes. Vehicles can be filtered be the following query string parameters:
By supplying one of the above as the query key with the ID for that resource, vehicles can be limited to those related groupings.
Operation: GET /vehicles?company=1
Itent: fetch a list of vehicles which belong to company 1
Status: 200 OK
Response body:
[{ VEHICLE HASH }, { VEHICLE HASH }, ... ]
Operation: GET /vehicle/1
Intent: retrieve vehicle 1
Status: 200 OK
Response body:
{
"id": "1",
"location": "/vehicle/1",
"name": "racy number",
"registration": "rcynum",
"year": "2014",
"transmission": "A",
"seat_number": "4",
"fuel_type": "PULP",
"body_color": "united grey",
"license_type": "car",
"kms_start": "14000",
"kms_current": "128572",
"avail_weekend": "yes",
"avail_outofhours": "no",
"comments": "",
"make": { VEHICLE MAKE HASH },
"model": { VEHICLE MODEL HASH },
"branch": { BRANCH HASH },
"features": { VEHICLE FEATURES HASH },
"cost-centre": { COST-CENTRE HASH },
"bookings.total": "17"
}
When creating a vehicle, the client may optionally supply a comma-separated list of cost-centre IDs or feature IDs (or both).
Operation: POST /vehicle
Request body:
{
"registration": "abc123",
"year": "1981",
"transmission": "M",
"seat_number": "4",
"fuel_type": "biodiesel",
"cost-centre_ids": "1,2",
"feature_ids": "8,12,39"
}
Intent: create a new vehicle
Status: 201 Created
Response body: { VEHICLE HASH }
Operation: PUT /vehicle/1
Request body:
{
"registration": "bca321"
}
Intent: update the registration datum for vehicle 1
Status: 200 OK
Response body: { VEHICLE HASH }
Operation: DELETE /vehicle/1
Intent: delete vehicle 1
Status: 200 OK
See also
Operation: POST /vehicle/1/booking/2014-01-01/20:00/2014-01-01/21:00
Intent: book vehicle 1 for one hour on the 1st of Jan, 2014 starting at 2000hrs
Status: 201 Created
Response body: { BOOKING HASH }
See also
Operation: GET /vehicle/1/booking/2014-01-01/00:00/2014-01-02/23:00
Intent: fetch bookings for vehicle 1 between midnight, 1st of Jan, 2014 and 2300hrs, 2nd of Jan, 2014
Status: 200 OK
Response body: [ { BOOKING HASH }, { BOOKING HASH }, ... ]
See also
Operation: GET /vehicle/1/assets
Intent: return all assets for vehicle 1
Status: 200 OK
Response body: { ASSETS HASH }
See also
Operation: POST /vehicle/1/assets/alloys
Request headers: Content-Type:image/gif
Request body: <binary JPEG data>
Intent: upload a GIF for vehicle 1 tagged "alloys"
Status: 201 Created
Response body: { ASSETS HASH }
Accepts CSV data and creates one vehicle per row.