👉 👉 🔗 https://immense-coast-01186.herokuapp.com/
-
Start your service with
docker-compose up
-
Run project test suite with
docker-compose run park_a_lot mix test
-
Start IEx session in running service # Find a container id using docker ps docker exec -it bash
# In container iex --sname debug --remsh app@$(hostname)
- Start just only the database service with
docker-compose up db
- Install dependencies with
mix deps.get
- prepare the database using
mix do ecto.create, ecto.migrate
- Start your service with
iex -S mix
HttpCode == 200 with always a payload in this manner.
{
"data": {entity} //entity is a JS Object with the data about entity or the performed action as well
}
HttpCode == 200 with always a payload in this manner. It's a similar idea to GraphQL
This kinda errors shall arise from the actions or Entities modules
{
"error": reason //reason is a string with error description
}
HttpCode in [30X, 40X, 50X]
This kinda errors shall arise from the handlers or from an un expected situation like an outage.
{
"error": reason //reason is a string with error description
}
Create a new parking ticket
This happen when a user enter with their vehicle at the parking lot, the machine at the gate
make a POST to {server_url}/api/tickets/ then if there are at least an available slot
the server will return a new ticket to open the gate
//Response
{
"data": {
"id": "00000000000000001", // the id field is the barcode in Hex
"inserted_at": "2020-02-23T03:11:50"
}
}
Get the cost of a parking ticket
The machine at the gate could calculate the cost of a especific ticket doing a
make a POST to {server_url}/api/tickets/{barcode_hexa} .
The client will always pay for a full hour
//Response
{
"data": {
"cost": 2,
"currency": "euros"
}
}
get the cost of a parking ticket
The machine at the gate could calculate the cost of a especific ticket,
The client must paid their ticket before leaving the parking slot, the payment will be informed by hitting
POST to {server_url}/api/tickets/{barcode_hexa}/payments with "payment_method" at json body
//Request
// POST to {server_url}/api/tickets/{barcode_hexa}/payments
{
"payment_method": "cash" // ["cash", "debit card", "credit car"]
}
//Response
{
"data": {
"id": "00000000000001005",
"payment_method": "cash",
"state": "paid",
"inserted_at": "2020-02-23T04:48:38"
}
}
Know if a ticket is paid or inpaid state
The machine at the gate could calculate the payment status/state of a especific ticket,
The client must paid their ticket before leaving the parking slot, the payment will be informed by hitting
GET to {server_url}/api/tickets/{barcode_hexa}/state
//Response
{
"data": {
"id": "00000000000001005",
"payment_method": "cash",
"state": "paid",
"inserted_at": "2020-02-23T04:48:38"
}
}
Calculate free space at parking lot
The machine at the gate could calculate the payment available spaces at the parking,
The client must paid their ticket before leaving the parking slot, the payment will be informed by hitting
GET to {server_url}/api/free-spaces
//Response
{
"data": {
"available_free_space": 36
}
}
Create and endpoint to return the ticket at the gate
The must return their parking ticket at the gate for leaving the place with their car,
The client must paid their ticket before leaving the parking slot, the payment will be informed by hitting
GET to {server_url}/api/tickets/{barcode_hexa}/retrun
//Response
{
"data": {
"id": 1,
"payment_method": "cash",
"state": "returned",
"inserted_at": "2020-02-23T03:11:50"
}
}