https://github.com/raulpe7eira/banana_bank
Section 3:9 of Elixir e Phoenix do Zero Course by Rafael Camarda
https://github.com/raulpe7eira/banana_bank
api bypass ci-cd course elixir ex-machina fly-io learn mox phoenix tesla udemy
Last synced: about 1 month ago
JSON representation
Section 3:9 of Elixir e Phoenix do Zero Course by Rafael Camarda
- Host: GitHub
- URL: https://github.com/raulpe7eira/banana_bank
- Owner: raulpe7eira
- Created: 2024-01-05T04:03:00.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-18T23:23:24.000Z (about 1 year ago)
- Last Synced: 2025-02-12T07:23:59.852Z (3 months ago)
- Topics: api, bypass, ci-cd, course, elixir, ex-machina, fly-io, learn, mox, phoenix, tesla, udemy
- Language: Elixir
- Homepage: https://banana-bank-api.fly.dev/api
- Size: 83 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BananaBank
This code corresponds to the [Section 3:9 of Elixir e Phoenix do Zero Course](https://www.udemy.com/course/elixir-e-phoenix-do-zero) lab by [Rafael Camarda](https://cursos.rafaelcamarda.com/).
> The project simulates a bank, where it's possible to register a user with a real CEP, an account for an user, and do transactions between accounts.
## Compilation, tests and runs
```bash
$ cd banana_bank
$ asdf install
$ mix compile
$ mix ecto.setup
$ mix test
$ iex -S mix phx.server
```## How to use?
```bash
# retrieve welcome
curl -X GET 'http://localhost:4000/api'# -----------------------------------------------------------------------------
# create user
curl -X POST 'http://localhost:4000/api/users' \
-H 'Content-Type: application/json' \
-d '{
"cep": "12312312",
"email": "[email protected]",
"password": "111111",
"name": "Raul"
}'# login user
curl -X POST 'http://localhost:4000/api/users/login' \
-H 'Content-Type: application/json' \
-d '{
"id": "1",
"password": "111111"
}'# retrieve user by id (
# :id - user identifier
# :token - authorization token
# )
curl -X GET 'http://localhost:4000/api/users/:id' \
-H 'Authorization: :token'# update user by id (
# :id - user identifier
# :token - authorization token
# )
curl -X PUT 'http://localhost:4000/api/users/:id' \
-H 'Authorization: :token' \
-H 'Content-Type: application/json' \
-d '{
"email": "[email protected]",
"password": "aaaaaa"
}'# delete user by id (
# :id - user identifier
# :token - authorization token
# )
curl -X DELETE 'http://localhost:4000/api/users/:id' \
-H 'Authorization: :token'# -----------------------------------------------------------------------------
# create account (
# :token - authorization token
# )
curl -X POST 'http://localhost:4000/api/accounts' \
-H 'Authorization: :token' \
-H 'Content-Type: application/json' \
-d '{
"user_id": "1",
"balance": 100000
}'# -----------------------------------------------------------------------------
# create transaction between accounts (
# :token - authorization token
# )
curl -X POST 'http://localhost:4000/api/accounts/transactions' \
-H 'Authorization: :token' \
-H 'Content-Type: application/json' \
-d '{
"from_account_id": "1",
"to_account_id": "2",
"amount": 0.01
}'
```