From 1686c352bced9bb5bea9499729fa3b72797b59df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Thu, 8 Oct 2020 16:28:05 +0300 Subject: [PATCH] REPP: Port accounts controller from Grape to Rails API --- app/api/repp/account_v1.rb | 16 ---------------- app/controllers/repp/v1/accounts_controller.rb | 11 +++++++++++ config/routes.rb | 5 +++++ 3 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 app/api/repp/account_v1.rb create mode 100644 app/controllers/repp/v1/accounts_controller.rb diff --git a/app/api/repp/account_v1.rb b/app/api/repp/account_v1.rb deleted file mode 100644 index fe3acd387..000000000 --- a/app/api/repp/account_v1.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Repp - class AccountV1 < Grape::API - version 'v1', using: :path - - resource :accounts do - desc 'Return current cash account balance' - - get 'balance' do - @response = { - balance: current_user.registrar.cash_account.balance, - currency: current_user.registrar.cash_account.currency - } - end - end - end -end diff --git a/app/controllers/repp/v1/accounts_controller.rb b/app/controllers/repp/v1/accounts_controller.rb new file mode 100644 index 000000000..5adf99ea1 --- /dev/null +++ b/app/controllers/repp/v1/accounts_controller.rb @@ -0,0 +1,11 @@ +module Repp + module V1 + class AccountsController < BaseController + def balance + resp = { balance: current_user.registrar.cash_account.balance, + currency: current_user.registrar.cash_account.currency } + render(json: resp, status: :ok) + end + end + end +end diff --git a/config/routes.rb b/config/routes.rb index afad7b947..5c518a533 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -40,6 +40,11 @@ Rails.application.routes.draw do namespace :repp do namespace :v1 do resources :contacts + resources :accounts do + collection do + get 'balance' + end + end resources :auctions, only: %i[index] resources :retained_domains, only: %i[index] end