Class: Pike13::API::V3::Desk::Enrollments

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

Overview

Enrollments resource Data about visit and waitlist history, behavior, and trends

Examples:

Basic query

Pike13::Reporting::Enrollments.query(
  fields: ['visit_id', 'full_name', 'service_name', 'state', 'service_date']
)

Query completed visits

Pike13::Reporting::Enrollments.query(
  fields: ['full_name', 'service_name', 'service_date', 'estimated_amount'],
  filter: ['eq', 'state', 'completed']
)

Group by service

Pike13::Reporting::Enrollments.query(
  fields: ['completed_enrollment_count', 'total_visits_amount'],
  group: 'service_name'
)

Constant Summary collapse

DETAIL_FIELDS =

Available detail fields (when not grouping)

%w[
  account_manager_emails
  account_manager_names
  account_manager_phones
  address
  available_plans
  birthdate
  bulk_enrolled
  business_id
  business_name
  business_subdomain
  cancelled_at
  cancelled_to_start
  client_booked
  completed_at
  consider_member
  currency_code
  duration_in_hours
  duration_in_minutes
  email
  end_at
  estimated_amount
  event_id
  event_name
  event_occurrence_id
  first_visit
  franchise_id
  full_name
  home_location_name
  instructor_names
  is_paid
  is_rollover
  is_waitlist
  key
  make_up_issued
  noshow_at
  paid_with
  paid_with_complimentary_pass
  paid_with_type
  person_id
  phone
  plan_id
  plan_product_id
  primary_staff_name
  punch_id
  punchcard_id
  registered_at
  service_category
  service_date
  service_day
  service_id
  service_location_id
  service_location_name
  service_name
  service_state
  service_time
  service_type
  start_at
  state
  visit_id
  waitlist_id
  waitlisted_at
].freeze
SUMMARY_FIELDS =

Available summary fields (when grouping)

%w[
  avg_per_visit_amount
  business_id_summary
  business_subdomain_summary
  client_booked_count
  completed_enrollment_count
  consider_member_count
  enrollment_count
  event_count
  event_occurrence_count
  expired_enrollment_count
  first_visit_count
  is_paid_count
  is_rollover_count
  is_waitlist_count
  late_canceled_enrollment_count
  noshowed_enrollment_count
  person_count
  registered_enrollment_count
  removed_enrollment_count
  reserved_enrollment_count
  service_count
  total_count
  total_duration_in_hours
  total_duration_in_minutes
  total_visits_amount
  unpaid_visit_count
  unpaid_visit_percent
  visit_count
  waiting_enrollment_count
  weekday_0_enrollment_count
  weekday_1_enrollment_count
  weekday_2_enrollment_count
  weekday_3_enrollment_count
  weekday_4_enrollment_count
  weekday_5_enrollment_count
  weekday_6_enrollment_count
].freeze
GROUPINGS =

Available grouping fields

%w[
  business_id
  business_name
  business_subdomain
  client_booked
  consider_member
  event_id
  event_name
  event_occurrence_id
  first_visit
  full_name
  home_location_name
  instructor_names
  is_paid
  is_rollover
  is_waitlist
  paid_with
  paid_with_complimentary_pass
  paid_with_type
  person_id
  plan_id
  plan_product_id
  primary_staff_name
  punch_id
  punchcard_id
  service_category
  service_date
  service_day
  service_id
  service_location_id
  service_location_name
  service_month_start_date
  service_name
  service_quarter_start_date
  service_state
  service_time
  service_type
  service_week_mon_start_date
  service_week_sun_start_date
  service_year_start_date
  state
].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 an enrollments 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:



39
40
41
42
43
44
45
46
47
48
# File 'lib/pike13/api/v3/desk/enrollments.rb', line 39

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("enrollments", query_params)
end