StPfeffer / rusty-roads

A simple route manager application written in Rust
MIT License
0 stars 0 forks source link

Vehicle Endpoint #77

Closed StPfeffer closed 1 month ago

StPfeffer commented 1 month ago

Description

Implementation of the vehicle scope.

Endpoints

Method Endpoint Description
GET /api/v1/vehicles List all the vehicles.
GET /api/v1/vehicles/:vehicleId Returns the vehicle referring to the given ID.
POST /api/v1/vehicles Creates a vehicle.
DELETE /api/v1/vehicles/:vehicleId Deletes the vehicle referring to the entered ID.

Payloads

List all vehicles

Response
{
    "vehicles": [
        {
            "id": "b87d1704-c957-4ee2-b378-f7be43c10b85",
            "name": "Volkswagen Gol",
            "initialMileage": 85,
            "actualMileage": 93,
            "createdAt": "2024-05-27T20:12:09.472329",
            "updatedAt": "2024-05-27T20:12:09.472329"
        }
    ],
    "results": 1
}

Get a vehicle

Response
{
    "id": "b87d1704-c957-4ee2-b378-f7be43c10b85",
    "name": "Volkswagen Gol",
    "initialMileage": 85,
    "actualMileage": 93,
    "createdAt": "2024-05-27T20:12:09.472329",
    "updatedAt": "2024-05-27T20:12:09.472329"
}

Create a vehicle

Request

The actualMileage field is optional. If it is not included in the request body, the value of initialMileage will be used instead.

{
    "name": "Volkswagen Gol",
    "initialMileage": 85,
    "actualMileage": 93
}
Response
{
    "id": "b87d1704-c957-4ee2-b378-f7be43c10b85",
    "name": "Volkswagen Gol",
    "initialMileage": 85,
    "actualMileage": 93,
    "createdAt": "2024-05-27T20:12:09.472329",
    "updatedAt": "2024-05-27T20:12:09.472329"
}

Delete a vehicle

Response
{
    "id": "b87d1704-c957-4ee2-b378-f7be43c10b85",
    "name": "Volkswagen Gol",
    "initialMileage": 85,
    "actualMileage": 93,
    "createdAt": "2024-05-27T20:12:09.472329",
    "updatedAt": "2024-05-27T20:12:09.472329"
}

Type of change

Checklist