This is a coding challenge to create a vehicle sales inventory API, complete with documentation based on the OpenAPI specification.
https://app.swaggerhub.com/apis/DTayloe/vehicle-api/1.0
- Clone the project using GitHub
- Ensure Docker is installed and setup
cd
to the root directory of the project in your terminal (such that this readme is listed)- Run the following command in the bash terminal:
./vendor/bin/sail up
- You should be able to view the page at
localhost
, which contains a single button to redirect to the list of vehicles. - The database may be seeded using the "Seed Database" button on the
localhost
page, which will add 50 random Vehicles.
The resulting vehicle returned from certain queries below will have these properties in the returned JSON object:
- Make
- Model
- Year
- Color
- Price
- Mileage
- Optional specs can be returned e.g. AWD, Engine type
GET /api/vehicles
POST /api/vehicles
GET /api/vehicles/{id}
PUT /api/vehicles/{id}
DELETE /api/vehicles/{id}
The following criteria can be searched using the API. Substitute your search term for the curly braces in the request.
/api/vehicles/search/make/{make}
- Example
URL:
http://localhost/api/vehicles/search/make/tesla
Result:
{
"current_page": 1,
"data": [
{
"id": 26,
"make": "tesla",
"model": "test",
"year": 2003,
"color": "red",
"price": "10000.00",
"mileage": 2000,
"options": "{\"AWD\": true}",
"created_at": "2021-04-25T20:01:26.000000Z",
"updated_at": "2021-04-25T20:01:26.000000Z"
}
],
"first_page_url": "http://localhost/api/vehicles/search/make/tesla?page=1",
...
/api/vehicles/search/model/{model}
/api/vehicles/search/year/{year}
/api/vehicles/search/color/{color}