REST API based implementation of EMP task
This application uses Rails version 6.1, Ruby version 2.5
This application is dockerized
To run the application:
- Build
docker-compose build
- Migrate
docker-compose run web bundle exec rails db:migrate
- Run
docker-compose up
- Rspecs
docker-compose run web rspec
- Rubocop
docker-compose run web rubocop
- Run Sidekiq for Background jobs
docker-compose run web bundle exec sidekiq
- update
users.csv
file with users - run rake task to create users:
docker-compose run web rake users:create_users
You need to authorize your user before making requests to other endpoints
- Make
POST /auth/login
request withemail
andpassword
params - You will get JWT token
- Insert token into
Authorization
header
GET /transactions
POST /transactions/authorize
with the following params:customer_email
,customer_phone
,amount
- After successfull request you will get
uuid
of the Auhorize transaction
POST /transactions/charge
with the following params:uuid
of authorize transaction,amount
- After successfull request you will get
uuid
of the Charge transaction
POST /transactions/refund
with the following params:uuid
of charge transaction,amount
- After successfull request you will get
uuid
of the Charge transaction - It changes Charge Transaction's state to
refunded
POST /transactions/reverse
with the following params:uuid
of authorize transaction- After successfull request you will get
uuid
of the reversal transaction - It changes Authorize Transaction's state to
reversed
- To get access to admin endpoints user's
admin
attribute should betrue
- Endpoints return following attributes:
uuid
,type
,customer_email
,customer_phone
,status
,amount
,parent_transaction_uuid
,merchant_id
GET /admin/transactions/authorize
GET /admin/transactions/charge
GET /admin/transactions/refund
GET /admin/transactions/reversal
GET /admin/transactions/{uuid}
Delete Transactions created one hour before. (It runs sidekiq background job to delete transactions. You need to run sidekiq)
DELETE /admin/del_old
- Endpoints return following attributes:
id
,email
,name
,description
,status
,admin
GET /admin/users
GET /admin/{id}
PUT /admin/update/{id}
with permitted params:name
,email
,description
,status
DELETE /admin/user/{id}
- it will not delete user if there are active transactions for the user which is going to be deleted