- The purpose of the example is to handle with http get requests regarding currency exchange
- Here is the explanation of the currency exchange example
- Get rates from the database if the rate info is already inserted into database
- Get rates from apilayer.com and insert its value into database and return the rate info
- Get exchange rates by exchange request info covering base currency, target currency and lastly amount
- Get conversion by rate id
- Get all conversions between two dates named start date and end date
Method | Url | Description | Valid Request Params | Valid Path Variable |
---|---|---|---|---|
GET | /v1/rate | Get Rates | Info | |
GET | /v1/exchange | Get Exchange Rates By Exchange Request Info | Info | |
GET | getconversion | Get Conversion By Id | Info | |
GET | getconversionlist | Get Conversion List | Info |
http://localhost:8080/v1/rate?base=USD&target=EUR,TRY&date=2023-05-21
base: USD
target: EUR,TRY
date: 2023-05-21
http://localhost:8080/v1/exchange?base=USD&target=EUR,TRY&amount=100
base: USD
target: EUR
amount: 100
http://localhost:8080/v1/exchange?base=USD&target=EUR,TRY&amount=100
base: USD
target: EUR
amount: 100
http://localhost:8080/v1/conversion?startDate=2023-05-20&endDate=2023-05-22
startDate: 2023-05-20
endDate: 2023-05-22
http://localhost:8080/v1/conversion/17d98364-e435-40d7-a941-af535fc95065
- Java 17
- Spring Boot 3.0
- Open API Documentation
- Restful API
- Spring Cache
- Actuator
- Resilience4j
- Lombok
- Maven
- Junit5
- Mockito
- Integration Tests
- Docker
- Docker Compose
- Get API KEY from apilayer.com
- Maven or Docker
1 ) Open and register apilayer.com
2 ) Register Exchange Rates Data API and Get API key
EXCHANGE_API_API_KEY={YOUR_API_KEY}
The application can be built and run by the Docker
engine. The Dockerfile
has multistage build, so you do not need to build and run separately.
Please follow directions shown below in order to build and run the application with Docker Compose file;
$ cd currencyexchange
$ docker-compose up -d
To build and run the application with Maven
, please follow the directions shown below;
$ cd currencyexchange
$ mvn clean install
$ mvn spring-boot:run
You can reach the swagger-ui through the link shown below
http://localhost:8080/swagger-ui/index.html
You can reach the actuator through the link shown below
http://localhost:8080/actuator