Skip to content

MichalBorecki/SimpleCurrencyAccountApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Currency Account App

Application allows to:

  • create bank accounts with sub-accounts in PLN and USD;
  • enables the exchange in pair: PLN <-> USD at the current exchange rate taken from public NBP API;
  • change in the balances on sub-accounts after the currency exchange.

Validated data: user data and his personal ID (PESEL), user age, initial amount, exchange currencies codes, exchange amounts, available funds.

The application downloads the data of current exchange rates from the public NBP API (https://api.nbp.pl/)

Tech/framework used

Application code: JAVA 17

Built with:

Application uses:

Installation instructions

Import the project as a maven application to your favorite IDE.

To run the application

Run the app in IDE as 'Java application'

To test the application

The REST API to the example app is described below:

1. Create a new account

Request:

POST /api/accounts/

curl --location --request POST 'localhost:8080/api/accounts' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Adam",
"surname": "Test",
"pesel": "02070803628",
"amountPln": 1000
}'

Response:

HTTP/1.1 201 Created
Status: 201 Created
Content-Type: application/json
Location: /api/accounts/02070803628

{
    "id": 1,
    "name": "Adam",
    "surname": "Test",
    "pesel": "02070803628",
    "subaccountList": [
        {
            "id": 2,
            "currencyCode": "PLN",
            "balance": 1000
        },
        {
            "id": 3,
            "currencyCode": "USD",
            "balance": 0
        }
    ]
}

2. Exchange PLN to USD

Request:

POST /api/exchange/

curl --location --request POST 'localhost:8080/api/exchange/' \
--header 'Content-Type: application/json' \
--data-raw '{
"pesel": "02070803628", 
"amountToExchange": 600, 
"fromCurrency": "PLN", 
"toCurrency": "USD"
}'

Response:

HTTP/1.1 200 OK
Status: 200 OK
Content-Type: application/json

{
    "success": true,
    "amountToExchange": 600,
    "fromCurrency": "PLN",
    "toCurrency": "USD",
    "rate": 0.2197,
    "result": 131.82
}

3. Exchange USD to PLN

Request:

POST /api/exchange/

curl --location --request POST 'localhost:8080/api/exchange/' \
--header 'Content-Type: application/json' \
--data-raw '{
"pesel": "02070803628", 
"amountToExchange": 100.00, 
"fromCurrency": "PLN", 
"toCurrency": "USD"
}'

Response:

HTTP/1.1 200 OK
Status: 200 OK
Content-Type: application/json

{
    "success": true,
    "amountToExchange": 100.00,
    "fromCurrency": "USD",
    "toCurrency": "PLN",
    "rate": 4.4622,
    "result": 446.22
}

4. Get account data

Request:

GET /api/accounts/{pesel}

curl --location --request GET 'localhost:8080/api/accounts/02070803628'

Response:

HTTP/1.1 200 OK
Status: 200 OK
Content-Type: application/json

{
    "id": 1,
    "name": "Adam",
    "surname": "Test",
    "pesel": "02070803628",
    "subaccountList": [
        {
            "id": 2,
            "currencyCode": "PLN",
            "balance": 846.22
        },
        {
            "id": 3,
            "currencyCode": "USD",
            "balance": 31.82
        }
    ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages