Class: Pike13::API::V3::Desk::MonthlyBusinessMetrics

Inherits:
Base
  • Object
show all
Defined in:
lib/pike13/api/v3/desk/monthly_business_metrics.rb

Overview

Monthly Business Metrics resource Summary of monthly transaction amounts, members, and enrollments

Examples:

Basic query

Pike13::Reporting::MonthlyBusinessMetrics.query(
  fields: ['month_start_date', 'net_paid_amount', 'new_client_count']
)

Query with filters and sorting

Pike13::Reporting::MonthlyBusinessMetrics.query(
  fields: ['month_start_date', 'net_paid_amount', 'member_count'],
  filter: ['btw', 'month_start_date', '2024-01-01', '2024-12-31'],
  sort: ['month_start_date-']
)

Query with grouping

Pike13::Reporting::MonthlyBusinessMetrics.query(
  fields: ['total_net_paid_amount', 'total_new_client_count'],
  group: 'year_start_date'
)

Query with pagination

Pike13::Reporting::MonthlyBusinessMetrics.query(
  fields: ['month_start_date', 'net_paid_amount'],
  page: { limit: 50, starting_after: 'abc123' }
)

Constant Summary collapse

DETAIL_FIELDS =

Available detail fields (when not grouping)

%w[
  appointment_count
  attendance_completed_count
  business_id
  business_name
  business_subdomain
  class_count
  client_booked_count
  client_completed_enrollment_count
  client_w_plan_count
  completed_appointment_enrollment_count
  completed_class_enrollment_count
  completed_course_enrollment_count
  completed_enrollment_count
  completed_enrollment_per_client
  completed_unpaid_count
  course_count
  currency_code
  due_invoice_count
  enrollment_count
  event_occurrence_count
  event_occurrence_organizer_count
  expected_amount
  expired_enrollment_count
  failed_transaction_count
  first_visit_count
  franchise_id
  key
  late_canceled_enrollment_count
  member_count
  membership_count
  month_start_date
  net_paid_amount
  net_paid_pass_revenue_amount
  net_paid_prepaid_revenue_amount
  net_paid_recurring_revenue_amount
  net_paid_retail_revenue_amount
  net_paid_revenue_amount
  new_client_count
  new_client_w_plan_count
  new_member_count
  new_staff_count
  noshowed_enrollment_count
  outstanding_amount
  pack_count
  payments_amount
  plan_end_count
  plan_start_count
  prepaid_count
  refunds_amount
  registered_enrollment_count
  removed_enrollment_count
  reserved_enrollment_count
  waiting_enrollment_count
].freeze
SUMMARY_FIELDS =

Available summary fields (when grouping)

%w[
  avg_client_completed_enrollment_count
  avg_client_w_plan_count
  avg_member_count
  business_id_summary
  business_subdomain_summary
  monthly_business_count
  total_attendance_completed_count
  total_completed_enrollment_count
  total_count
  total_enrollment_count
  total_event_occurrence_count
  total_first_visit_count
  total_net_paid_amount
  total_net_paid_revenue_amount
  total_new_client_count
  total_new_client_w_plan_count
  total_new_member_count
  total_payments_amount
  total_refunds_amount
].freeze
GROUPINGS =

Available grouping fields

%w[
  business_id
  business_name
  business_subdomain
  currency_code
  quarter_start_date
  year_start_date
].freeze

Class Method Summary collapse

Methods inherited from Base

client, configure

Class Method Details

.query(fields:, filter: nil, group: nil, sort: nil, page: nil, total_count: nil) ⇒ Hash

Execute a monthly business metrics query

Parameters:

  • fields (Array<String>)

    Fields to return (detail or summary fields)

  • filter (Array, nil) (defaults to: nil)

    Filter criteria (optional)

  • group (String, nil) (defaults to: nil)

    Grouping field (optional)

  • sort (Array<String>, nil) (defaults to: nil)

    Sort order (optional)

  • page (Hash, nil) (defaults to: nil)

    Pagination options (optional)

  • total_count (Boolean) (defaults to: nil)

    Whether to return total count (optional)

Returns:

  • (Hash)

    Query result with rows, fields, and metadata

See Also:



46
47
48
49
50
51
52
53
54
55
# File 'lib/pike13/api/v3/desk/monthly_business_metrics.rb', line 46

def query(fields:, filter: nil, group: nil, sort: nil, page: nil, total_count: nil)
  query_params = { fields: fields }
  query_params[:filter] = filter if filter
  query_params[:group] = group if group
  query_params[:sort] = sort if sort
  query_params[:page] = page if page
  query_params[:total_count] = total_count if total_count

  super("monthly_business_metrics", query_params)
end