This service provides a REST API for calculating an approved loan amount and period for a customer. The loan amount is calculated based on the customer's credit modifier, which is determined by the last four digits of their ID code.
- Java 17
- Spring Boot
- estonian-personal-code-validator:1.6
- Java 17
- Gradle
To install and run the service, please follow these steps:
- Clone the repository.
- Navigate to the root directory of the project.
- Run
gradle build
to build the application. - Run
java -jar build/libs/inbank-backend-1.0.jar
to start the application
The default port is 8080.
The application exposes a single endpoint:
The request body must contain the following fields:
- personalCode: The customer's personal ID code.
- loanAmount: The requested loan amount.
- loanPeriod: The requested loan period.
Request example:
{
"personalCode": "50307172740",
"loanAmount": "5000",
"loanPeriod": "24"
}
The response body contains the following fields:
- loanAmount: The approved loan amount.
- loanPeriod: The approved loan period.
- errorMessage: An error message, if any.
Response example:
{
"loanAmount": 2400,
"loanPeriod": 24,
"errorMessage": null
}
The following error responses can be returned by the service:
400 Bad Request
- in case of an invalid inputInvalid personal ID code!
- if the provided personal ID code is invalidInvalid loan amount!
- if the requested loan amount is invalidInvalid loan period!
- if the requested loan period is invalid
404 Not Found
- in case no valid loans can be foundNo valid loan found!
- if there is no valid loan found for the given ID code, loan amount, and loan period
500 Internal Server Error
- in case the server encounters an unexpected error while processing the requestAn unexpected error occurred
- if there is an unexpected error while processing the request
The service consists of two main classes:
- DecisionEngine: A service class that provides a method for calculating an approved loan amount and period for a customer.
- DecisionEngineController: A REST endpoint that handles requests for loan decisions.