pike13 0.1.0.beta → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +67 -116
  3. data/README.md +1222 -315
  4. data/lib/pike13/api/v2/account.rb +19 -0
  5. data/lib/pike13/api/v2/desk/booking.rb +10 -0
  6. data/lib/pike13/api/v2/desk/business.rb +2 -1
  7. data/lib/pike13/api/v2/desk/event_occurrence.rb +2 -2
  8. data/lib/pike13/api/v2/desk/person.rb +5 -3
  9. data/lib/pike13/api/v2/desk/plan.rb +2 -2
  10. data/lib/pike13/api/v2/desk/plan_product.rb +2 -2
  11. data/lib/pike13/api/v2/desk/service.rb +2 -2
  12. data/lib/pike13/api/v2/desk/visit.rb +2 -2
  13. data/lib/pike13/api/v2/front/branding.rb +2 -1
  14. data/lib/pike13/api/v2/front/business.rb +2 -1
  15. data/lib/pike13/api/v2/front/event_occurrence.rb +2 -2
  16. data/lib/pike13/api/v2/front/plan_product.rb +2 -2
  17. data/lib/pike13/api/v2/front/service.rb +2 -2
  18. data/lib/pike13/api/v2/front/visit.rb +2 -2
  19. data/lib/pike13/api/v3/desk/base.rb +46 -0
  20. data/lib/pike13/api/v3/desk/clients.rb +180 -0
  21. data/lib/pike13/api/v3/desk/enrollments.rb +203 -0
  22. data/lib/pike13/api/v3/desk/event_occurrence_staff_members.rb +170 -0
  23. data/lib/pike13/api/v3/desk/event_occurrences.rb +154 -0
  24. data/lib/pike13/api/v3/desk/invoice_item_transactions.rb +189 -0
  25. data/lib/pike13/api/v3/desk/invoice_items.rb +193 -0
  26. data/lib/pike13/api/v3/desk/invoices.rb +167 -0
  27. data/lib/pike13/api/v3/desk/monthly_business_metrics.rb +151 -0
  28. data/lib/pike13/api/v3/desk/pays.rb +128 -0
  29. data/lib/pike13/api/v3/desk/person_plans.rb +265 -0
  30. data/lib/pike13/api/v3/desk/staff_members.rb +127 -0
  31. data/lib/pike13/api/v3/desk/transactions.rb +169 -0
  32. data/lib/pike13/http_client.rb +4 -1
  33. data/lib/pike13/http_client_v3.rb +101 -0
  34. data/lib/pike13/validators.rb +136 -0
  35. data/lib/pike13/version.rb +1 -1
  36. data/lib/pike13.rb +26 -7
  37. metadata +17 -2
  38. data/lib/pike13/api/v2/account/me.rb +0 -20
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Account
7
+ # Get current authenticated account
8
+ #
9
+ # @return [Hash] Account information
10
+ # @example
11
+ # account = Pike13::Account.me
12
+ # email = account["accounts"].first["email"]
13
+ def self.me
14
+ Base.client.get("account")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -26,6 +26,11 @@ module Pike13
26
26
  client.delete("desk/bookings/#{id}")
27
27
  end
28
28
 
29
+ # GET /desk/bookings/:booking_id/leases/:id
30
+ def find_lease(booking_id:, id:, **params)
31
+ client.get("desk/bookings/#{booking_id}/leases/#{id}", params)
32
+ end
33
+
29
34
  # POST /desk/bookings/:booking_id/leases
30
35
  def create_lease(booking_id, attributes)
31
36
  client.post("desk/bookings/#{booking_id}/leases", { lease: attributes })
@@ -35,6 +40,11 @@ module Pike13
35
40
  def update_lease(booking_id, id, attributes)
36
41
  client.put("desk/bookings/#{booking_id}/leases/#{id}", { lease: attributes })
37
42
  end
43
+
44
+ # DELETE /desk/bookings/:booking_id/leases/:lease_id
45
+ def destroy_lease(booking_id, lease_id)
46
+ client.delete("desk/bookings/#{booking_id}/leases/#{lease_id}")
47
+ end
38
48
  end
39
49
  end
40
50
  end
@@ -7,9 +7,10 @@ module Pike13
7
7
  class Business < Base
8
8
  class << self
9
9
  # GET /desk/business
10
- def get
10
+ def find
11
11
  client.get("desk/business")
12
12
  end
13
+ alias get find
13
14
 
14
15
  # GET /desk/business/franchisees
15
16
  def franchisees
@@ -7,8 +7,8 @@ module Pike13
7
7
  class EventOccurrence < Base
8
8
  class << self
9
9
  # GET /desk/event_occurrences
10
- def all
11
- client.get("desk/event_occurrences")
10
+ def all(**params)
11
+ client.get("desk/event_occurrences", params)
12
12
  end
13
13
 
14
14
  # GET /desk/event_occurrences/:id
@@ -21,9 +21,11 @@ module Pike13
21
21
  find(:me)
22
22
  end
23
23
 
24
- # GET /desk/people/search?q=query
25
- def search(query)
26
- client.get("desk/people/search", q: query)
24
+ # GET /desk/people/search?q=query&fields=fields
25
+ def search(query, fields: nil)
26
+ params = { q: query }
27
+ params[:fields] = fields if fields
28
+ client.get("desk/people/search", params)
27
29
  end
28
30
 
29
31
  # POST /desk/people
@@ -7,8 +7,8 @@ module Pike13
7
7
  class Plan < Base
8
8
  class << self
9
9
  # GET /desk/plans
10
- def all
11
- client.get("desk/plans")
10
+ def all(**params)
11
+ client.get("desk/plans", params)
12
12
  end
13
13
 
14
14
  # GET /desk/plans/:id
@@ -7,8 +7,8 @@ module Pike13
7
7
  class PlanProduct < Base
8
8
  class << self
9
9
  # GET /desk/plan_products
10
- def all
11
- client.get("desk/plan_products")
10
+ def all(**params)
11
+ client.get("desk/plan_products", params)
12
12
  end
13
13
 
14
14
  # GET /desk/plan_products/:id
@@ -7,8 +7,8 @@ module Pike13
7
7
  class Service < Base
8
8
  class << self
9
9
  # GET /desk/services
10
- def all
11
- client.get("desk/services")
10
+ def all(**params)
11
+ client.get("desk/services", params)
12
12
  end
13
13
 
14
14
  # GET /desk/services/:id
@@ -7,8 +7,8 @@ module Pike13
7
7
  class Visit < Base
8
8
  class << self
9
9
  # GET /desk/visits
10
- def all
11
- client.get("desk/visits")
10
+ def all(**params)
11
+ client.get("desk/visits", params)
12
12
  end
13
13
 
14
14
  # GET /desk/visits/:id
@@ -7,9 +7,10 @@ module Pike13
7
7
  class Branding < Base
8
8
  class << self
9
9
  # GET /front/branding
10
- def get
10
+ def find
11
11
  client.get("front/branding")
12
12
  end
13
+ alias get find
13
14
  end
14
15
  end
15
16
  end
@@ -7,9 +7,10 @@ module Pike13
7
7
  class Business < Base
8
8
  class << self
9
9
  # GET /front/business
10
- def get
10
+ def find
11
11
  client.get("front/business")
12
12
  end
13
+ alias get find
13
14
 
14
15
  # GET /front/business/franchisees
15
16
  def franchisees
@@ -7,8 +7,8 @@ module Pike13
7
7
  class EventOccurrence < Base
8
8
  class << self
9
9
  # GET /front/event_occurrences
10
- def all
11
- client.get("front/event_occurrences")
10
+ def all(**params)
11
+ client.get("front/event_occurrences", params)
12
12
  end
13
13
 
14
14
  # GET /front/event_occurrences/:id
@@ -7,8 +7,8 @@ module Pike13
7
7
  class PlanProduct < Base
8
8
  class << self
9
9
  # GET /front/plan_products
10
- def all
11
- client.get("front/plan_products")
10
+ def all(**params)
11
+ client.get("front/plan_products", params)
12
12
  end
13
13
 
14
14
  # GET /front/plan_products/:id
@@ -7,8 +7,8 @@ module Pike13
7
7
  class Service < Base
8
8
  class << self
9
9
  # GET /front/services
10
- def all
11
- client.get("front/services")
10
+ def all(**params)
11
+ client.get("front/services", params)
12
12
  end
13
13
 
14
14
  # GET /front/services/:id
@@ -7,8 +7,8 @@ module Pike13
7
7
  class Visit < Base
8
8
  class << self
9
9
  # GET /front/visits
10
- def all
11
- client.get("front/visits")
10
+ def all(**params)
11
+ client.get("front/visits", params)
12
12
  end
13
13
 
14
14
  # GET /front/visits/:id
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V3
6
+ module Desk
7
+ # Base class for all V3 Desk reporting resources
8
+ # V3 Reporting API uses POST requests to /desk/api/v3/reports/{resource}/queries
9
+ class Base
10
+ class << self
11
+ def configure(config)
12
+ @client = Pike13::HTTPClientV3.new(
13
+ base_url: config.full_url,
14
+ access_token: config.access_token
15
+ )
16
+ end
17
+
18
+ def client
19
+ # Return this class's client if set, otherwise traverse up to Base
20
+ return @client if instance_variable_defined?(:@client) && @client
21
+ return superclass.client if superclass.respond_to?(:client) && superclass != Object
22
+
23
+ raise "Client not configured. Call Pike13.configure first."
24
+ end
25
+
26
+ # Execute a reporting query
27
+ #
28
+ # @param resource [String] The resource name (e.g., 'monthly_business_metrics')
29
+ # @param query_params [Hash] Query parameters including fields, filters, etc.
30
+ # @return [Hash] Query result with rows, fields, and metadata
31
+ def query(resource, query_params)
32
+ data = {
33
+ data: {
34
+ type: "queries",
35
+ attributes: query_params
36
+ }
37
+ }
38
+
39
+ client.post("desk/api/v3/reports/#{resource}/queries", data)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V3
6
+ module Desk
7
+ # Clients resource
8
+ # All client data — from tenure and unpaid bills to birthdays and passes held
9
+ #
10
+ # @example Basic query
11
+ # Pike13::Reporting::Clients.query(
12
+ # fields: ['person_id', 'full_name', 'email', 'client_since_date']
13
+ # )
14
+ #
15
+ # @example Query with filters
16
+ # Pike13::Reporting::Clients.query(
17
+ # fields: ['full_name', 'email', 'tenure', 'has_membership'],
18
+ # filter: ['eq', 'has_membership', true]
19
+ # )
20
+ #
21
+ # @example Query with grouping
22
+ # Pike13::Reporting::Clients.query(
23
+ # fields: ['person_count', 'has_membership_count'],
24
+ # group: 'tenure_group'
25
+ # )
26
+ class Clients < Base
27
+ class << self
28
+ # Execute a clients query
29
+ #
30
+ # @param fields [Array<String>] Fields to return (detail or summary fields)
31
+ # @param filter [Array, nil] Filter criteria (optional)
32
+ # @param group [String, nil] Grouping field (optional)
33
+ # @param sort [Array<String>, nil] Sort order (optional)
34
+ # @param page [Hash, nil] Pagination options (optional)
35
+ # @param total_count [Boolean] Whether to return total count (optional)
36
+ # @return [Hash] Query result with rows, fields, and metadata
37
+ #
38
+ # @see https://developer.pike13.com/docs/api/v3/reports/clients
39
+ def query(fields:, filter: nil, group: nil, sort: nil, page: nil, total_count: nil)
40
+ query_params = { fields: fields }
41
+ query_params[:filter] = filter if filter
42
+ query_params[:group] = group if group
43
+ query_params[:sort] = sort if sort
44
+ query_params[:page] = page if page
45
+ query_params[:total_count] = total_count if total_count
46
+
47
+ super("clients", query_params)
48
+ end
49
+
50
+ # Available detail fields (when not grouping)
51
+ DETAIL_FIELDS = %w[
52
+ account_claim_date
53
+ account_credit_amount
54
+ account_manager_emails
55
+ account_manager_names
56
+ account_manager_phones
57
+ address
58
+ street_address
59
+ street_address2
60
+ city
61
+ state_code
62
+ postal_code
63
+ country_code
64
+ age
65
+ also_staff
66
+ birthdate
67
+ business_id
68
+ business_name
69
+ business_subdomain
70
+ client_since_date
71
+ completed_visits
72
+ currency_code
73
+ current_plan_revenue_category
74
+ current_plan_types
75
+ current_plans
76
+ custom_fields
77
+ days_since_last_visit
78
+ days_until_birthday
79
+ dependent_names
80
+ email
81
+ first_name
82
+ first_visit_date
83
+ franchise_id
84
+ full_name
85
+ future_visits
86
+ guardian_email
87
+ guardian_name
88
+ has_membership
89
+ has_payment_on_file
90
+ has_plan_on_hold
91
+ has_signed_waiver
92
+ home_location_name
93
+ is_schedulable
94
+ key
95
+ last_email_bounced
96
+ last_invoice_amount
97
+ last_invoice_date
98
+ last_invoice_id
99
+ last_invoice_unpaid
100
+ last_membership_end_date
101
+ last_name
102
+ last_signed_waiver_name
103
+ last_site_access_date
104
+ last_visit_date
105
+ last_visit_id
106
+ last_visit_service
107
+ middle_name
108
+ net_paid_amount
109
+ next_pass_plan_end_date
110
+ person_id
111
+ person_state
112
+ phone
113
+ primary_staff_name
114
+ revenue_amount
115
+ source_name
116
+ staff_member_who_added
117
+ tenure
118
+ tenure_group
119
+ unpaid_visits
120
+ ].freeze
121
+
122
+ # Available summary fields (when grouping)
123
+ SUMMARY_FIELDS = %w[
124
+ account_claim_count
125
+ also_staff_count
126
+ business_id_summary
127
+ business_subdomain_summary
128
+ has_membership_count
129
+ has_payment_on_file_count
130
+ has_plan_on_hold_count
131
+ has_signed_waiver_count
132
+ is_schedulable_count
133
+ last_email_bounced_count
134
+ last_invoice_unpaid_count
135
+ person_count
136
+ total_account_credit_amount
137
+ total_completed_visits
138
+ total_count
139
+ total_future_visits
140
+ total_net_paid_amount
141
+ total_revenue_amount
142
+ total_unpaid_visits
143
+ visited_site_count
144
+ ].freeze
145
+
146
+ # Available grouping fields
147
+ GROUPINGS = %w[
148
+ account_claim_date
149
+ account_manager_names
150
+ age
151
+ also_staff
152
+ business_id
153
+ business_name
154
+ business_subdomain
155
+ client_since_date
156
+ client_since_month_start_date
157
+ client_since_quarter_start_date
158
+ client_since_week_mon_start_date
159
+ client_since_week_sun_start_date
160
+ client_since_year_start_date
161
+ has_membership
162
+ has_payment_on_file
163
+ has_plan_on_hold
164
+ has_signed_waiver
165
+ home_location_name
166
+ is_schedulable
167
+ last_email_bounced
168
+ last_invoice_unpaid
169
+ person_state
170
+ primary_staff_name
171
+ source_name
172
+ staff_member_who_added
173
+ tenure_group
174
+ ].freeze
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,203 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V3
6
+ module Desk
7
+ # Enrollments resource
8
+ # Data about visit and waitlist history, behavior, and trends
9
+ #
10
+ # @example Basic query
11
+ # Pike13::Reporting::Enrollments.query(
12
+ # fields: ['visit_id', 'full_name', 'service_name', 'state', 'service_date']
13
+ # )
14
+ #
15
+ # @example Query completed visits
16
+ # Pike13::Reporting::Enrollments.query(
17
+ # fields: ['full_name', 'service_name', 'service_date', 'estimated_amount'],
18
+ # filter: ['eq', 'state', 'completed']
19
+ # )
20
+ #
21
+ # @example Group by service
22
+ # Pike13::Reporting::Enrollments.query(
23
+ # fields: ['completed_enrollment_count', 'total_visits_amount'],
24
+ # group: 'service_name'
25
+ # )
26
+ class Enrollments < Base
27
+ class << self
28
+ # Execute an enrollments query
29
+ #
30
+ # @param fields [Array<String>] Fields to return (detail or summary fields)
31
+ # @param filter [Array, nil] Filter criteria (optional)
32
+ # @param group [String, nil] Grouping field (optional)
33
+ # @param sort [Array<String>, nil] Sort order (optional)
34
+ # @param page [Hash, nil] Pagination options (optional)
35
+ # @param total_count [Boolean] Whether to return total count (optional)
36
+ # @return [Hash] Query result with rows, fields, and metadata
37
+ #
38
+ # @see https://developer.pike13.com/docs/api/v3/reports/enrollments
39
+ def query(fields:, filter: nil, group: nil, sort: nil, page: nil, total_count: nil)
40
+ query_params = { fields: fields }
41
+ query_params[:filter] = filter if filter
42
+ query_params[:group] = group if group
43
+ query_params[:sort] = sort if sort
44
+ query_params[:page] = page if page
45
+ query_params[:total_count] = total_count if total_count
46
+
47
+ super("enrollments", query_params)
48
+ end
49
+
50
+ # Available detail fields (when not grouping)
51
+ DETAIL_FIELDS = %w[
52
+ account_manager_emails
53
+ account_manager_names
54
+ account_manager_phones
55
+ address
56
+ available_plans
57
+ birthdate
58
+ bulk_enrolled
59
+ business_id
60
+ business_name
61
+ business_subdomain
62
+ cancelled_at
63
+ cancelled_to_start
64
+ client_booked
65
+ completed_at
66
+ consider_member
67
+ currency_code
68
+ duration_in_hours
69
+ duration_in_minutes
70
+ email
71
+ end_at
72
+ estimated_amount
73
+ event_id
74
+ event_name
75
+ event_occurrence_id
76
+ first_visit
77
+ franchise_id
78
+ full_name
79
+ home_location_name
80
+ instructor_names
81
+ is_paid
82
+ is_rollover
83
+ is_waitlist
84
+ key
85
+ make_up_issued
86
+ noshow_at
87
+ paid_with
88
+ paid_with_complimentary_pass
89
+ paid_with_type
90
+ person_id
91
+ phone
92
+ plan_id
93
+ plan_product_id
94
+ primary_staff_name
95
+ punch_id
96
+ punchcard_id
97
+ registered_at
98
+ service_category
99
+ service_date
100
+ service_day
101
+ service_id
102
+ service_location_id
103
+ service_location_name
104
+ service_name
105
+ service_state
106
+ service_time
107
+ service_type
108
+ start_at
109
+ state
110
+ visit_id
111
+ waitlist_id
112
+ waitlisted_at
113
+ ].freeze
114
+
115
+ # Available summary fields (when grouping)
116
+ SUMMARY_FIELDS = %w[
117
+ avg_per_visit_amount
118
+ business_id_summary
119
+ business_subdomain_summary
120
+ client_booked_count
121
+ completed_enrollment_count
122
+ consider_member_count
123
+ enrollment_count
124
+ event_count
125
+ event_occurrence_count
126
+ expired_enrollment_count
127
+ first_visit_count
128
+ is_paid_count
129
+ is_rollover_count
130
+ is_waitlist_count
131
+ late_canceled_enrollment_count
132
+ noshowed_enrollment_count
133
+ person_count
134
+ registered_enrollment_count
135
+ removed_enrollment_count
136
+ reserved_enrollment_count
137
+ service_count
138
+ total_count
139
+ total_duration_in_hours
140
+ total_duration_in_minutes
141
+ total_visits_amount
142
+ unpaid_visit_count
143
+ unpaid_visit_percent
144
+ visit_count
145
+ waiting_enrollment_count
146
+ weekday_0_enrollment_count
147
+ weekday_1_enrollment_count
148
+ weekday_2_enrollment_count
149
+ weekday_3_enrollment_count
150
+ weekday_4_enrollment_count
151
+ weekday_5_enrollment_count
152
+ weekday_6_enrollment_count
153
+ ].freeze
154
+
155
+ # Available grouping fields
156
+ GROUPINGS = %w[
157
+ business_id
158
+ business_name
159
+ business_subdomain
160
+ client_booked
161
+ consider_member
162
+ event_id
163
+ event_name
164
+ event_occurrence_id
165
+ first_visit
166
+ full_name
167
+ home_location_name
168
+ instructor_names
169
+ is_paid
170
+ is_rollover
171
+ is_waitlist
172
+ paid_with
173
+ paid_with_complimentary_pass
174
+ paid_with_type
175
+ person_id
176
+ plan_id
177
+ plan_product_id
178
+ primary_staff_name
179
+ punch_id
180
+ punchcard_id
181
+ service_category
182
+ service_date
183
+ service_day
184
+ service_id
185
+ service_location_id
186
+ service_location_name
187
+ service_month_start_date
188
+ service_name
189
+ service_quarter_start_date
190
+ service_state
191
+ service_time
192
+ service_type
193
+ service_week_mon_start_date
194
+ service_week_sun_start_date
195
+ service_year_start_date
196
+ state
197
+ ].freeze
198
+ end
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end