diff --git a/README.md b/README.md index 51976f3..a44a178 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,9 @@ An H2 database is populated on startup. The initial data is described below. ### What has not been implemented -* Pagination -* Registering fraud tentatives +* Pagination for payments +* Registering of fraud tentatives +* Final execution of payments (mark payment as executed and update end-of-day balances) ### How to run the application @@ -55,4 +56,79 @@ Run it using the following command: docker run -p 8080:8080 bankingservice ``` +### Application summary + +Using a tool like Postman (see `resources` folder for a sample collection), a user can send requests to the REST API. + +First the user has to log in using the `POST /login` endpoint providing username and password as basic authentication. + +Then the now authenticated user can execute payments, view his/her payments, delete a payment or list his/her bank accounts. +The user can also update the user details (address, password) using the dedicated endpoint. + +To create a payment, the following constraints apply: +* The giver bank account has to be owned by the user +* Payments to the same account as the giver are not valid +* Payments only be executed if the account balance is sufficient +* Payments to the following list of accounts are forbidden: + * LU280019400644750000 + * LU120010001234567891 +* The IBAN of the beneficiary is validated with [https://openiban.com/validate](https://openiban.com/validate) + +The account balances will be updated, if they belong to this banking service. + +The payment is processed in a single transaction, creating the payment in the database and updating the available balances. + +When the user has finished, he can log out using the `POST /logout` endpoint, which will invalidate the session. + +### Endpoints + +* `POST /login`: The user can log in using basic authentication +* `POST /logout`: The user can log out +* `PUT /update-user`: Update the user details and password +* `POST /payment`: Create a new payment +* `GET /accounts`: List the user's bank accounts +* `GET /payments`: List the created payments for the authenticated user +* `DELETE /payment`: Delete a payment using its ID. Only payments that have not yet been executed can be deleted. + +For a detailed overview of the API, visit the Swagger documentation at [http://localhost:8080/swagger-ui.html](http://localhost:8080/swagger-ui.html) + ### Populated data + +#### Users + +| ID | User | Password | Accounts | +|----|-------|---------------|------------| +| 1 | user1 | user1Password | 1,2 | +| 2 | user2 | user2Password | 2,3,4,9,19 | +| 3 | user3 | user3Password | 2,8,13,16 | +| 4 | user4 | user4Password | 8,14 | +| 5 | user5 | user5Password | 4,12,13,16 | +| 6 | user6 | user6Password | 10,15,18 | +| 7 | user7 | user7Password | 5,6,17 | +| 8 | user8 | user8Password | 7,11,13,20 | + +#### Accounts + +| ID | Account name | IBAN | Balance | Users | +|----|---------------|----------------------|-----------|-------| +| 1 | Personal | LU584022594948990503 | 578.98 | 1 | +| 2 | Work | LU907047173626189281 | 4135.14 | 1,2,3 | +| 3 | Checking | LU337685598868536287 | 21545.32 | 2 | +| 4 | Joint | LU840552586110383855 | 201.00 | 2,5 | +| 5 | Primary | LU068976849336652168 | 984512.23 | 7 | +| 6 | Secondary | LU148716017016374383 | 382690.16 | 7 | +| 7 | Joy | LU798574254737992988 | 232663.94 | 8 | +| 8 | Holidays | LU881912185721376358 | 421234.41 | 3,4 | +| 9 | Personal | LU191013601444141763 | 158052.05 | 2 | +| 10 | Savings | LU710564368935005652 | 292888.94 | 6 | +| 11 | Personal | LU222549371173567471 | 168211.44 | 8 | +| 12 | Savings | LU261309808416076323 | 223757.44 | 5 | +| 13 | Work | LU654310230678616664 | 207268.46 | 3,5,8 | +| 14 | Expenses | LU231866912041681639 | 326704.48 | 4 | +| 15 | Personal | LU429127592687822778 | 98377.59 | 6 | +| 16 | Joint account | LU786522695111559649 | 23818.53 | 3,5 | +| 17 | Savings | LU259786109895524005 | 252442.60 | 7 | +| 18 | Pension | LU744005943189772712 | 412747.20 | 6 | +| 19 | Savings | LU130189044953642517 | 359691.69 | 2 | +| 20 | Trading | LU081651725326393823 | 278739.76 | 8 | + diff --git a/resources/Banking Service.postman_collection.json b/resources/Banking Service.postman_collection.json new file mode 100644 index 0000000..35d6a5b --- /dev/null +++ b/resources/Banking Service.postman_collection.json @@ -0,0 +1,219 @@ +{ + "info": { + "_postman_id": "325fdf37-6ce8-41aa-bd68-ecf08c1a2ee3", + "name": "Banking Service", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "List accounts", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "localhost:8080/accounts", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "accounts" + ] + } + }, + "response": [] + }, + { + "name": "Login User1", + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "password", + "value": "user1Password", + "type": "string" + }, + { + "key": "username", + "value": "user1", + "type": "string" + } + ] + }, + "method": "POST", + "header": [], + "url": { + "raw": "localhost:8080/login", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "login" + ] + } + }, + "response": [] + }, + { + "name": "Login User2", + "request": { + "auth": { + "type": "basic", + "basic": [ + { + "key": "username", + "value": "user2", + "type": "string" + }, + { + "key": "password", + "value": "user2Password", + "type": "string" + } + ] + }, + "method": "POST", + "header": [], + "url": { + "raw": "localhost:8080/login", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "login" + ] + } + }, + "response": [] + }, + { + "name": "Logout", + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "localhost:8080/logout", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "logout" + ] + } + }, + "response": [] + }, + { + "name": "Create Payment", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"amount\": 1,\n \"currency\": \"EUR\",\n \"giverAccount\": 2,\n \"beneficiaryName\": \"testName\",\n \"beneficiaryAccountNumber\": \"LU560303O43349845521\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "localhost:8080/payment", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "payment" + ] + } + }, + "response": [] + }, + { + "name": "Update User", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"password\": \"user1UpdatedPassword\",\n \"street\": \"updatedStreet\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "localhost:8080/update-user", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "update-user" + ] + } + }, + "response": [] + }, + { + "name": "Delete Payment", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "localhost:8080/payment/1", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "payment", + "1" + ] + } + }, + "response": [] + }, + { + "name": "List All Payments", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "localhost:8080/payments", + "host": [ + "localhost" + ], + "port": "8080", + "path": [ + "payments" + ], + "query": [ + { + "key": "beneficiaryAccountNumber", + "value": "LU560303O43349845521", + "disabled": true + }, + { + "key": "startDate", + "value": "2023-05-15T17:39:10", + "disabled": true + }, + { + "key": "endDate", + "value": "2023-05-15T17:39", + "disabled": true + } + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/resources/Finologee - Java Development Assignment - Luxembourg.pdf b/resources/Finologee - Java Development Assignment - Luxembourg.pdf new file mode 100644 index 0000000..b20caa3 Binary files /dev/null and b/resources/Finologee - Java Development Assignment - Luxembourg.pdf differ