API v1 financial_transactions endpoints (#627)

This commit is contained in:
wvengen 2020-07-25 14:18:59 +00:00 committed by GitHub
parent 8c8b42c2b2
commit b96ce06d94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 397 additions and 1 deletions

View file

@ -0,0 +1,24 @@
class Api::V1::FinancialTransactionsController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'finance:read', 'finance:write' }
def index
render_collection search_scope
end
def show
render json: scope.find(params.require(:id))
end
private
def scope
FinancialTransaction.includes(:user)
end
def ransack_auth_object
:finance
end
end

View file

@ -0,0 +1,21 @@
class Api::V1::User::FinancialTransactionsController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'finance:user' }
before_action :require_ordergroup
def index
render_collection search_scope
end
def show
render json: scope.find(params.require(:id))
end
private
def scope
current_ordergroup.financial_transactions.includes(:user)
end
end