Chatwoot/app/controllers/api/v2/accounts/reports_controller.rb
Sojan Jose 051871a3cd
Chore: Code Cleanup in API controllers (#932)
* Chore: Code Cleanup in API controllers

* Remove unnecessary scoping for accounts controller
2020-06-07 13:58:05 +05:30

35 lines
725 B
Ruby

class Api::V2::Accounts::ReportsController < Api::V1::Accounts::BaseController
def account
builder = V2::ReportBuilder.new(Current.account, account_report_params)
data = builder.build
render json: data
end
def account_summary
render json: account_summary_metrics
end
private
def account_summary_params
{
type: :account,
since: params[:since],
until: params[:until]
}
end
def account_report_params
{
metric: params[:metric],
type: :account,
since: params[:since],
until: params[:until]
}
end
def account_summary_metrics
builder = V2::ReportBuilder.new(Current.account, account_summary_params)
builder.summary
end
end