This is Exchange Rates API for Freska test application. Part of Test assignment for fetching exchange currencies data from fixer.io.
API has 3 endpoints:
- any date request e.g.
api/v1/2019-12-17
- current rates request
api/v1/latest
- dates period request
api/v1/timeseries
(its paid feature in Fixer, so use carefully - each day is 1 request)
It takes params:
-
String
base
(e.g.base=EUR
). Default value isEUR
. -
String
symbols
(e.g.symbols=USD,DKK
). Default value isUSD
. -
String
start_date
,end_date
(e.g.2020-12-12
) only for/timeseries
endpoint -
Units specs written with
Rspec
. -
Rates info is fetched from Fixer.io, cached with Redis and stored in MongoDB.
-
Rubocop is used for a good code style. Run example:
rubocop
- Sinatra v 2.1
- Ruby version 2.6
- Caching layer: Redis
- Persistance layer: MongoDB
Install and run Redis and MongoDB first: On Mac OS with homebrew:
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb/brew/mongodb-community
brew install redis
brew services start redis
Then you can start this app with rackup -p 4567
:
RACK_ENV=test rspec spec/
curl -H "Content-Type: application/json" http://localhost:4567/api/v1/timeseries?start_date=2020-12-20&end_date=2020-12-22&base=EUR&symbols=GBP,USD
curl -H "Content-Type: application/json" http://localhost:4567/api/v1/2019-12-17?symbols=GBP,USD
curl -H "Content-Type: application/json" http://localhost:4567/api/v1/latest\?symbols\=GBP,USD,DKK
- Add API authentication (e.g. with jwt)
- Add logging system
- Configure docker-compose to avoid manual installation of MongoDB and Redis
- Add tests for app helpers