The following must be installed on the host machine:
- docker
- docker-compose
- make
make build
- builds the necessary images defined in the docker-compose.yaml file
make test_unit
- runs all tests in the
tests/unit
folder
make run
- if not already running, starts up the postgres container
- applies migrations in the
/migrations/versions
folder to the postgres instance using alembic - starts the api (api will be running on
localhost:5001
)
(while API is running in separate terminal)
make test_functional
- runs all tests in the
tests/functional
folder
While running, the API can be hit on the host machine using localhost:5001
Full swagger API specification can be retrieved from localhost:5001/swagger.json
All numeric values (credit, payment amount, withdrawal, etc...) must be represented in microdollars. 1c = 1000000 microdollars. The values are stored and calculated in microdollars. This helps to prevent rounding errors when calculating in currencies.
To test the endpoints manually, you can do the following:
- Create a new customer and save its uuid
- Create a new account with that customer uuid
- Apply payments/withdrawals to that account using the account uuid. Specify different dates to simulate real user activity.
- Check the account responses to ensure their accuracy
- Creates a new customer and returns it back for confirmation.
{
"fname": <Customer first name>,
"lname": <Customer last name>,
"email": <Customer email>
}
{
"uuid": <Customer uuid>,
"fname": <Customer first name>,
"lname": <Customer last name>,
"email": <Customer email>
}
<uuid>
must be an existing customer id.- Attempting to access a non-existing customer will return a 404.
{
"uuid": <Customer uuid>,
"fname": <Customer first name>,
"lname": <Customer last name>,
"email": <Customer email>
}
- Creates a new account and returns it back for confirmation.
- All numeric values should be sent/received in microdollars
{
"customerUUID": <The customer's UUID>,
"maxCredit": <Maximum Credit for this account>,
"timeOpened": <The time the account was opened>,
"apr": <The apr for this credit line>
}
{
"uuid": <The account uuid>,
"apr": <The account apr>,
"maxCredit": <The maximum credit for this account>,
"timeOpened": <The time the account was opened>,
"availableCredit": <The amount of credit left on the account>,
"principalOwed": <The amount of principal owed on the account>,
"interestOwed": <The amount of interest owed on the account>
}
<uuid>
is the account uuid<time>
gets the account information as of a certain time. Defaults to now()- Attempting to access a non-existing account will return a 404.
{
"uuid": <The account uuid>,
"apr": <The account apr>,
"maxCredit": <The maximum credit for this account>,
"timeOpened": <The time the account was opened>,
"availableCredit": <The amount of credit left on the account>,
"principalOwed": <The amount of principal owed on the account>,
"interestOwed": <The amount of interest owed on the account>
}
- Applies the payment then returns the updated balance information.
- Invalid payments will return a 422 error code.
{
"accountUUID": <The account uuid>,
"time": <The time the payment took place (default now())>,
"amount": <The amount of the payment in microdollars>
}
{
"uuid": <The account uuid>,
"apr": <The account apr>,
"maxCredit": <The maximum credit for this account>,
"timeOpened": <The time the account was opened>,
"availableCredit": <The amount of credit left on the account>,
"principalOwed": <The amount of principal owed on the account>,
"interestOwed": <The amount of interest owed on the account>
}
- Applies the withdrawal then returns the updated balance information.
- Invalid withdrawals will return a 422 error code.
{
"accountUUID": <The account uuid>,
"time": <The time the withdrawal took place (default now())>,
"amount": <The amount of the withdrawal in microdollars>
}
{
"uuid": <The account uuid>,
"apr": <The account apr>,
"maxCredit": <The maximum credit for this account>,
"timeOpened": <The time the account was opened>,
"availableCredit": <The amount of credit left on the account>,
"principalOwed": <The amount of principal owed on the account>,
"interestOwed": <The amount of interest owed on the account>
}