Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raulpe7eira/rp7pay
nlw#4 - trilha elixir from rocketseat by Rafael Camarda
https://github.com/raulpe7eira/rp7pay
bcrypt coveralls credo ecto elixir nlw nlw-4-elixir phoenix rocketseat
Last synced: 15 days ago
JSON representation
nlw#4 - trilha elixir from rocketseat by Rafael Camarda
- Host: GitHub
- URL: https://github.com/raulpe7eira/rp7pay
- Owner: raulpe7eira
- Created: 2021-02-22T21:57:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-18T23:50:22.000Z (11 months ago)
- Last Synced: 2024-07-30T17:56:11.029Z (5 months ago)
- Topics: bcrypt, coveralls, credo, ecto, elixir, nlw, nlw-4-elixir, phoenix, rocketseat
- Language: Elixir
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RP7Pay API
This repository is the code corresponding to the [nlw#4 - trilha elixir](https://nextlevelweek.com/) lab by Rafael Camarda.
> The project simulates a banking API that allows to withdraw, deposit or transfer money between two accounts and uses Basic Auth as authentication in some resources.
## Previous installations
**Database**, we recommends install [PostgreSQL](https://www.postgresql.org/) with [Docker](https://hub.docker.com/_/postgres). After that, sets connection configuration at:
- `config/dev.exs`
- `config/test.exs`## Gets dependencies, setups database, tests, coverages, reports and starts application
```bash
cd rp7pay
mix deps.get
mix ecto.setup
mix test
mix test --cover
mix coveralls.html
mix phx.server
```## How to use?
```bash
# welcomes (
# replaces curly braces:
# {filename} : path for CSV file w/ the following sintax - `1,2,3,4,8,9,10`
# )
curl -X GET 'http://localhost:4000/api/{filename}'# creates user
curl -X POST 'http://localhost:4000/api/users' \
-H 'Content-Type: application/json' \
-d '{
"name": "Raul Pereira",
"nickname": "raulpe7eira",
"email": "[email protected]",
"age": 40,
"password": "12345abcd"
}'# does deposit (
# replaces curly braces:
# {id} : account identifier
# {basic_auth} : username and password credentials
# )
curl -X POST 'http://localhost:4000/api/accounts/{id}/deposit' \
-H 'Authorization: {basic_auth}' \
-H 'Content-Type: application/json' \
-d '{
"value": 50.00
}'# does withdraw (
# replaces curly braces:
# {id} : account identifier
# {basic_auth} : username and password credentials
# )
curl -X POST 'http://localhost:4000/api/accounts/{id}/withdraw' \
-H 'Authorization: {basic_auth}' \
-H 'Content-Type: application/json' \
-d '{
"value": 1.00
}'# does transaction (
# replaces curly braces:
# {from} : from account identifier
# {to} : to account identifier
# {basic_auth} : username and password credentials
# )
curl -X POST 'http://localhost:4000/api/accounts/transaction' \
-H 'Authorization: {basic_auth}' \
-H 'Content-Type: application/json' \
-d '{
"from": "{from}",
"to": "{to}",
"value": 1.00
}'
```