- You need to transfer funds between accounts. Think about what classes and DB tables you need for this task. Implement the models and a service class that wires them together.
- Build a REST endpoint to show the balance of the account and 10 latest transactions.
- Build a REST endpoint to transfer money between accounts. Your REST action should use the service class you built in task 1.
Framework and language dependencies:
- Rails version: 6.0
- Ruby version: 2.5.3
- PostgreSql: 9.6
- SQLite for development environment only
For development environment you don't need to do anything.
For production environment you need to setup PostgreSQL connection credential in .env.production
file.
Here is the example:
RDS_HOST=localhost
RDS_DATABASE=visable_development
RDS_USER=visable_user
RDS_PASSWORD=<STRONG PASSWORD>
gem install bundler
bundle install
- Make sure all tests are passes on your environment
bundle exec rspec
- Start rails
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails s
You can create some test data on your local environment with following command
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:seed
bundle exec rails s
Then you test with curl
as like following examples:
Last 10 transaction list
curl localhost:3000/transactions
Or specify limit with 1
curl localhost:3000/transactions?limit_number=1
Do some transfer with curl
curl -X POST -H "Content-Type: application/json" -d '{"account_from":"2", "account_to":"4", "transfer_amount": "100"}' localhost:3000/transactions/transfer
- Add more edge case tests
- Create Docker compose file for local environment
- Create API document with Swagger