Skip to content

Commit

Permalink
Merge pull request #11 from darth-dodo/hotfix/missing-api-documentation
Browse files Browse the repository at this point in the history
lame api documentation
  • Loading branch information
darth-dodo authored Jun 1, 2019
2 parents 6afa350 + 5796908 commit 1c37816
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HelperCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
- Application Log stream: `heroku logs -t --app=gringotts-backend`
112 changes: 112 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/expense_logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 1c37816

Please sign in to comment.