Finance Interest Account Library provides you as the customer easy to use functions to manipulate your interest account. See the complete lis of methods below.
This library implements the PSR-4 interface that you can type-hint against in your own libraries. You can use it in your applications. PSR-12 code standards applied.
how to use with a php example
A few commands are available for ease of use
This is to install composer on your local set up
Build the docker image which will be used to run tests
Run the php unit tests inside the docker image
Run the php unit tests in your local environment
Create the phpdoc folder with documentation from docblocs
The project is not published anywhere, so it requires a manual integration as a library to your code base. The idea is to publish the library for composer integration.
The ideal way to ensure that payouts are occuring daily, is by creating a php file, which is part a daily running cron job. This file should basically look like the following:
$listOfUsers = array( ... );
foreach($listOfUsers as $user)
{
$UUIDv4Object = new \Finance\IA\Object\UUIDv4Object($uuidExample);
$FinanceApiRequest = new Finance\IA\Request\FinanceApiRequest($UUIDv4Object);
$FinanceInterestAccount = new \Finance\IA\Account($UUIDv4Object, $FinanceApiRequest);
$FinanceInterestAccount->openInterestAccount();
$result = $FinanceInterestAccount->payout();
}
Install dependencies
composer install
In your PHP script, add the following
$UUIDv4Object = new \Finance\IA\Object\UUIDv4Object($uuidExample);
$FinanceApiRequest = new Finance\IA\Request\FinanceApiRequest($UUIDv4Object);
$FinanceInterestAccount = new \Finance\IA\Account($UUIDv4Object, $FinanceApiRequest);
# we now can use the library
$FinanceInterestAccount->openInterestAccount($income_in_pennies);
This method is not fully implementation. The functionality is a potential for future related work.
You need to open the account to ensure that the information is retrieved and set.
Returns a list of transactions objects
Deposit funds in pennies to the opened account.
This method calculates all the neccessary data and processes how much money is owed to the user. Should it be at least 1 penny, it is deposited to the account. Otherwise, it is stored for accumulation towards future payouts.
From root of project
./vendor/bin/phpunit
- Finance-IA works with PHP 7.4 or above
- PHP-Decimal
Contact the author, Chris Bartolo on chris@chrisbartolo.com
Chris Bartolo - chris@chrisbartolo.com
Open Source - created for the purposes of the Finance Interview process
The task requirements has set a number of functionality that is not provided as part of the API. For this reason, it has been assumed that the following will be implemented: Future work would include:
- improve handling of exceptions and errors, both for implementation and API endpoints
- simplify tests with re-usable set up code
- simplify financeRequestApi object in Account class
URL: /users/{uuid}/transactions
METHOD: GET
PARAMS: sort=ASC|DESC
RESPONSE: an array/list with transaction objects. Each transaction object has at least date_time, type, amount_in_pennies
URL: /users/{uuid}/rate
METHOD: GET
RESPONSE: yearly_interest_rate DECIMAL
URL: /users/{uuid}/rate
METHOD: POST
PARAMS: rate DECIMAL
RESPONSE: true|false
URL: /users/{uuid}/deposit
METHOD: POST
PARAMS: amount_in_pennies INT
RESPONSE: true|false
URL: /users/{uuid}/skipped_payout
METHOD: POST
PARAMS: amount_in_decimal DECIMAL
RESPONSE: true|false
URL: /users/{uuid}/skipped_payout
METHOD: GET
RESPONSE: array of object with field amount_in_decimal
###Reset Skipped Payouts Endpoint
URL: /users/{uuid}/skipped_payout
METHOD: POST
PARAMS: reset BOOL
RESPONSE: true|false
URL: /users/{uuid}/transaction
METHOD: POST
PARAMS: date_time DATE_TIME, concluded BOOL, uuid
RESPONSE: true|false
URL: /users/{uuid}/balance
METHOD: GET
RESPONSE: balance INT