From dd1bae98f8166fe924d0ad05fd5090b62f4583fa Mon Sep 17 00:00:00 2001 From: Abhishek Juneja Date: Sat, 1 Jun 2019 22:29:52 +0530 Subject: [PATCH 1/2] lame api documentation --- README.md | 112 +++++++++++++++++++++ app/controllers/accounts_controller.rb | 26 +++++ app/controllers/expense_logs_controller.rb | 3 +- app/controllers/users_controller.rb | 8 ++ 4 files changed, 147 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b2b2d0..d867b65 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,118 @@ - The dev app is hosted at [gringotts-backend.herokuapp.com](https://gringotts-backend.herokuapp.com) +## Lame API Docs + +### Signup +- URL: POST /signup/ +```json +{ + "email": "demo@gg.com", + "password": "demouserfordemo" +} +``` + +### Login to extract the JWT +- URL: POST /auth/login/ +```json +{ + "email": "demo@gg.com", + "password": "demouserfordemo" +} +``` + +### Account +- URL: GET /accounts/ +- URL: GET /accounts/id/ +- URL: POST /accounts/ + +```json +{ + "name": "Salary" +} +``` + +```json +{ + "name": "Cash Wallet" +} +``` +- URL: PUT /accounts/id/ + +```json +{ + "name": "Wallet" +} +``` + + +### Category +- URL: GET /categories/ +- URL: GET /categories/id/ + +**Gotta remove eligible_mode** +- URL: POST /categories/ + +```json +{ + "name": "Salary", + "eligible_mode": "creditable" +} +``` + +```json +{ + "name": "Commute", + "eligible_mode": "debitable" +} +``` + +```json +{ + "name": "Cash Transfer", + "eligible_mode": "creditable", + "category_type": "internal_transfer" +} +``` +- URL: PUT /categories/id/ +```json +{ + "name": "Cash Refill" +} +``` + +### Expense Log +- URL: POST /expense_logs/ + +```json +{ + "account_id":4, + "category_id":3, + "amount":5000, + "mode": "credit", + "note":"Salary Credit" +} +``` + +```json +{ + "user_id":7, + "account_id":4, + "destination_account_id": 3, + "category_id":2, + "amount":500, + "mode": "debit", + "note":"Wallet refill from new salary" +} +``` + +### Internal Transfer Log +- URL: GET /internal-transfer-logs/ +- URL: GET /internal-transfer-logs/id/ + +-- + + ## ToDo - [ ] Specs setup - [ ] Swagger diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 14d35e8..98f43c1 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -2,20 +2,46 @@ class AccountsController < ApiController before_action :set_account_from_param!, only: [:show, :update] def index +=begin + url: https://gringotts-backend.herokuapp.com/accounts/ + payload: + { + "email": "test@test12.com", + "password": "apples2" + } +=end accounts = Account.for_user(current_user) json_response accounts end def create +=begin + POST url: https://gringotts-backend.herokuapp.com/accounts/ + payload: + { + "name": "Salary" + } +=end account = Account.create!(account_creation_params) json_response account, :created end def show +=begin + GET url: https://gringotts-backend.herokuapp.com/accounts/1/ +=end json_response @account end def update +=begin + url: https://gringotts-backend.herokuapp.com/signup + payload: + { + "email": "test@test12.com", + "password": "apples2" + } +=end @account.update!(account_update_params) json_response @account, :ok end diff --git a/app/controllers/expense_logs_controller.rb b/app/controllers/expense_logs_controller.rb index d26e61f..a9d6eee 100644 --- a/app/controllers/expense_logs_controller.rb +++ b/app/controllers/expense_logs_controller.rb @@ -29,14 +29,13 @@ def set_expense_log_from_param! def expense_log_creation_params params.permit( - :user_id, :account_id, :category_id, :amount, :mode, :note, :destination_account_id - ) + ).merge( {user_id: current_user.id }) end def expense_log_update_params diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c383144..fb99519 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,6 +3,14 @@ class UsersController < ApiController def create +=begin + url: https://gringotts-backend.herokuapp.com/signup + payload: + { + "email": "test@test12.com", + "password": "apples2" + } +=end user = User.create!(user_params) auth_token = AuthServices::AuthenticateUser.new(user.email, user.password).call response = { message: Message.user_created, auth_token: auth_token } From 5796908e0f325836e88a4f47cd581657402922e7 Mon Sep 17 00:00:00 2001 From: Abhishek Juneja Date: Sat, 1 Jun 2019 22:31:19 +0530 Subject: [PATCH 2/2] heroku logs tail config --- HelperCommands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HelperCommands.md b/HelperCommands.md index 42ef02a..37821ef 100644 --- a/HelperCommands.md +++ b/HelperCommands.md @@ -20,4 +20,4 @@ dropdb gringotts_dev && createdb gringotts_dev && rake db:migrate && rake db:see - Rake db migrate: `heroku run rake db:migrate --app=gringotts-backend` - Rake db seed: `heroku run rake db:seed --app=gringotts-backend` - Rails Console: `heroku run rails c --app=gringotts-backend` -- Application Log stream: `heroku logs --app=gringotts-backend` \ No newline at end of file +- Application Log stream: `heroku logs -t --app=gringotts-backend` \ No newline at end of file