Skip to content

Banking app to create, deposit, withdraw, get balance and send money

Notifications You must be signed in to change notification settings

sharmadeepak29/ex_banking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExBanking

Banking application using Elixir/OTP with the features of creating users, deposits, withdrawals, get balances and send money.

Getting Started

To run the application locally, follow these steps:

1. Prerequisites:

elixir 1.16.0-otp-26
erlang 26.2.1
  • Elixir and Erlang versions are already added to .tool-versions and can be installed using asdf.

2. Clone the Repository:

git clone https://github.com/sharmadeepak29/ex_banking.git
cd ex_banking

3. Setup

To start your server:

  • Run mix deps.get to install and setup dependencies
  • Start inside IEx with iex -S mix.

API Reference

1. Create User

  • Creates new user in the system.
  • New user has zero balance of any currency.

Request:

ExBanking.create_user(name)

Response:

:ok | {:error, :wrong_arguments | :user_already_exists}

Example:

ExBanking.create_user("Deepak Sharma")

2. Deposit Funds

Deposit funds into a user account.

  • Increases user’s balance in then given currency by amount value.
  • Returns the updated balance of the user in the given currency.

Request:

ExBanking.deposit(name, amount, currency)

Response:

{:ok, updated_balance :: number} | {:error, :wrong_arguments | :user_does_not_exist | :too_many_requests_to_user}

Example:

{:ok, 100.5} = ExBanking.deposit("Deepak Sharma", 100.50, "USD")

3. Withdraw Funds

Withdraw funds from a user account.

  • Decreases the user’s balance in the given currency by amount value.
  • Returns the updated balance of the user in the given currency.

Request:

ExBanking.withdraw(name, amount, currency)

Response:

 {:ok, updated_balance :: number} | {:error, :wrong_arguments | :user_does_not_exist | :not_enough_money | :too_many_requests_to_user}

Example:

{:ok, 90.0} = ExBanking.withdraw("Deepak Sharma", 10.50, "USD")

4. Get balance

Retrieves the current balance of the user in the given currency.

Request:

ExBanking.get_balance(name, currency)

Response:

 {:ok, updated_balance :: number} | {:error, :wrong_arguments | :user_does_not_exist | :too_many_requests_to_user}

Example:

{:ok, 90.0} = ExBanking.get_balance("Deepak Sharma", "USD")

5. Send Money

Sends money from one account to another.

  • Decreases from_user’s balance in given currency by amount value.
  • Increases to_user’s balance in given currency by amount value.
  • Returns updated balances of from_user and to_user.

Request:

ExBanking.send(from_user, to_user, amount, currency)

Response:

 {:ok, from_user_balance :: number, to_user_balance :: number} | {:error, :wrong_arguments | :not_enough_money | :sender_does_not_exist | :receiver_does_not_exist | :too_many_requests_to_sender | :too_many_requests_to_receiver}

Example:

{:ok, 80.0, 10.0} = ExBanking.send("Deepak Sharma", "Pranav", 10, "USD")

Tests

To run the tests for this project, simply run in your terminal:

mix test

Learn more

About

Banking app to create, deposit, withdraw, get balance and send money

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages