This is small REST-service which can convert some amount from on currency to another.
- Javalin (v4.1.1) - used the rest api building
- OkHttp (4.9.2) - used as http client
- exchangeratesapi.io - used as point of truth for currency rates
#Notes about exchangeratesapi.io free plan
If you use the free plan on exchangeratesapi.io, you coundn't change base currency. And the base currency is EUR.
gradle shadowJar - was builded an build/libsConverterApp-fat.jar
At first, you need to set some environment variables:
- EX_RATE_ACCESS_KEY - your access_key for exchangeratesapi.io (doesn't have default value)
- EX_RATE_API_URL - the url exchangeratesapi.io (http://api.exchangeratesapi.io/v1/ as default)
- CONVERTER_APP_PORT - port of the application (8090 as default)
Then just run the next command:
java -jar build/libs/ConverterApp-fat.jar
curl --request GET \
--url 'http://localhost:8090/converter/convert?source=EUR&target=RUB&monetary=100'
The result of the request will looks like
{
"source": "EUR",
"target": "RUB",
"rate": "82.668491",
"amountSource": "100",
"amountResult": "8266.85"
}