For this task you are given a list of employees. The output of the task is an endpoint which returns the same list of employees but with the relevant country specific information added to each employee.
docker-compose build web
docker-compose up webcurl -X GET "http://localhost:3000/api/v1/employees" -H "accept: application/json"
http://localhost:3000/api-docs/index.html
docker-compose build web
docker-compose run web bundle exec rspecEntry point is API controller Api::V1::EmployeesController (spec). This controller gets a list of employees using EmployeesRepository#all. The controller fetches country info for every employee using ApiClients::Restcountries (spec) and converts it into JSON for a response using Employees::List::Decorator (spec).
Employees::List::Decorator gets employee info, converts it into a hash, and adds country info to conutryInfo field. Also it generates regionalId using Employees::List::RegionalIdFactory (spec). Employees::List::RegionalIdFactory generates special ids for Europe and Asia and can be extended for other regions or countries.
ApiClients::Restcountries is a simple wrapper for making requests to https://restcountries.com, but it acts as a singleton. It makes a request for specific country info only once, and after that is uses previous info. We can do that since country info does not change very often. Later solutions can utilize any other cache solutions, for example, Redis or storing all countries' data in DB.