This challenge helps you practice your OO design skills.
You'll work alone, and you'll also review your own code, so you can practice reflecting on and improving your own work.
- You should be able to interact with your code via a JavaScript REPL - Node REPL or browser console (You don't need to implement a command line interface that takes input from STDIN.)
- Deposits, withdrawal.
- Account statement (date, credit or debit amount, balance) printing.
- Data can be kept in memory (it doesn't need to be stored to a database or anything).
Given a client makes a deposit of 1000 on 10-01-2012
And a deposit of 2000 on 13-01-2012
And a withdrawal of 500 on 14-01-2012
When she prints her bank statement
Then she would see
date || credit || debit || balance
14/01/2012 || || 500.00 || 2500.00
13/01/2012 || 2000.00 || || 3000.00
10/01/2012 || 1000.00 || || 1000.00
- Meets the spec
- Developed test-first (commit your tests before your source code to provide evidence of this)
- Passes tests
- Encapsulates adding and storing Transactions in a class
- Encapsulates Statement formatting in a class
- Encapsulates Transaction data in a class
- Generate ordered bank statements between 2 dates
- Disable withdraws if the withdrawal amount exceeds the available funds. Available funds must be calculated based on a complete transaction history, not a variable that gets updated
- Allow adding a 500 overdraft to the account
- Different account types (Savings, Investment, Checking). Savings & Investment accounts cant have overdrafts, Checking accounts can. Investment accounts accumulate 2% interest every month.
- Deposit limits of 20,000 per year on Savings accounts
- A front-end online banking app
- Generate PDFs of bank statements
I have implemented a rest api using express.js framework. The api allows accessing all the features implemented in core and extension exercises.
Build the project using:
npm run build
(Don't forget to npm i
first)
And then run using
npm start
The server will start on port 3000, though you can change it with the port
variable inside index.ts
Besides the responses listed in each endpoint, of course also 500
can always be returned if something unexpected
happens.
POST /user/register
Request body:
{
name: string
}
Returns:
201 CREATED
with resource url inLocation
header.
GET /user
Returns:
200 OK
with list of all existing users in response body (list can be empty)
GET /user/{userUUID}
Returns:
200 OK
with specified user in response body upon success404 NOT FOUND
for invaliduserUUID
in url
PUT /user/{userUUID}
Request body:
{
name: string
}
Returns:
204 NO CONTENT
upon success400 BAD REQUEST
for invalid request body404 NOT FOUND
for invaliduserUUID
in url
DELETE /user/{userUUID}
Returns:
204 NO CONTENT
upon success404 NOT FOUND
for invaliduserUUID
in url
POST /user/{userUUID}/account/open
Request body:
{
accountType: 'checking' | 'savings' | 'investment'
}
Returns:
201 CREATED
with resource url inLocation
header upon success400 BAD REQUEST
for invalid request body404 NOT FOUND
for invaliduserUUID
in url
GET /user/{userUUID}/account?accountFilter=...
accountFilter
query parameter is optional - when specified, only accounts of the given type will be fetched.
Otherwise,
all accounts will be fetched, regardless of type.
Allowed values are: checking
, savings
, 'investment'
Returns:
200 OK
with list of accounts in response body (list can be empty)400 BAD REQUEST
for invalidaccountFiler
query param value
GET /user/{userUUID}/account/{accountUUID}
Returns:
200 OK
with specified account in response body upon success404 NOT FOUND
for invaliduserUUID
oraccountUUID
in url
GET /user/{userUUID}/account/{accountUUID}/balance
Returns:
200 OK
with balance in response body upon success404 NOT FOUND
for invaliduserUUID
oraccountUUID
in url
POST /user/{userUUID}/account/{accountUUID}/deposit
Request body:
{
amount: number
}
Returns:
204 NO CONTENT
upon success400 BAD REQUEST
for invalid request body (including trying to deposit amount <= 0)404 NOT FOUND
for invaliduserUUID
oraccountUUID
in url
POST /user/{userUUID}/account/{accountUUID}/withdraw
Request body:
{
amount: number
}
Returns:
204 NO CONTENT
upon success400 BAD REQUEST
for invalid request body (including trying to withdraw amount <= 0)404 NOT FOUND
for invaliduserUUID
oraccountUUID
in url
Note that according to the domain model from earlier stage, rejected transactions will not return error http responses, they will be added to history, marked as rejected.
POST /user/{userUUID}/account/{accountUUID}/requestOverdraft
Request body: None
Returns:
204 NO CONTENT
upon success404 NOT FOUND
for invaliduserUUID
oraccountUUID
in url405 METHOD NOT ALLOWED
when trying to request overdraft on other account types than Checking Account
POST /user/{userUUID}/account/{accountUUID}/reviewOverdraftRequest
Request body:
{
decision: boolean
}
Returns:
204 NO CONTENT
upon success404 NOT FOUND
for invaliduserUUID
oraccountUUID
in url405 METHOD NOT ALLOWED
when trying to review and overdraft request on other account types than Checking Account
DELETE /user/{userUUID}/account/{accountUUID}
Returns:
204 NO CONTENT
upon success404 NOT FOUND
for invaliduserUUID
oraccountUUID
in url