This is a basic REST api for charging station service. I followed laravel structure so entire app is contained in app
folder, test in test
folder and docker instructions in Dockerfile
and docker-compose.yml
files.
I decide to improve basic api for a bit and added some featured which you can find on extended
branch.
docker-compose build
You can run api with docker and manually
docker-compose up
php artisan serve
php artisan test
POST http://example/stations
{
city: `Example city`,
position:{
latitude: `Example latitude`,
longitude: `Example longitude`,
}
}
Status: 201 Created
{
station: `station object`
}
GET http://example/stations
- status
open
close
- city
cityName
Status: 200 OK
Body: {
stations: [
`stationObject`,
`stationObject`
...
]
}
GET http://example/stations/closest
-
status
open
close
-
measure (
default
=direct_distance
)direct_distance
-
position
- LatLon formated to
<latitude>.<longitude>
- LatLon formated to
Status: 200 OK
Body: {
measure: `requestMeasure`,
value: `resultValue`,
station: `stationObject`
}
PUT http://example/stations
{
status: <open|close>
city: <ExampleCity>,
position:{
latitude: <ExampleLatitude>,
longitude: <ExampleLongitude>,
}
}
Status: 204 No Content
`DELETE` http://example/stations/{id}
Status: 204 No Content