This repository is the code corresponding to the nlw#5 - trilha elixir lab by Rafael Camarda.
The project simulates an inventory management API that allows to register restaurants and supplies, view supplies, generate reports of expiring supplies and send them to the restaurant's email.
Database, we recommends install PostgreSQL with Docker. After that, sets connection configuration at:
config/dev.exs
config/test.exs
cd inmana
mix deps.get
mix ecto.setup
mix test
mix test --cover
mix coveralls.html
mix phx.server
# welcomes (
# replaces curly braces:
# {name} : your name
# {age} : your age
# )
curl -X GET 'http://localhost:4000/api?name={name}&age={age}'
# creates restaurant
curl -X POST 'http://localhost:4000/api/restaurants' \
-H 'Content-Type: application/json' \
-d '{
"email": "ribs@puffup.com",
"name": "Ribs Puff Up"
}'
# creates supply (
# replaces curly braces:
# {restaurant_id} : restaurant identifier
# )
curl -X POST 'http://localhost:4000/api/supplies' \
-H 'Content-Type: application/json' \
-d '{
"description": "Tomato Sauce",
"expiration_date": "2021-05-09",
"responsible": "Raul",
"restaurant_id": "{restaurant_id}"
}'
# retrieves supply by id (
# replaces curly braces:
# {id} : supply identifier
# )
curl -X GET 'http://localhost:4000/api/supplies/{id}'
An expiring supplies report is emailed every 10 seconds through the generic server (Scheduler
).
See in development mode the emails sent at:
http://localhost:4000/send_emails
.