pike13 0.1.0.beta → 0.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +71 -117
- data/README.md +1222 -315
- data/lib/pike13/api/v2/account/business.rb +0 -4
- data/lib/pike13/api/v2/account.rb +19 -0
- data/lib/pike13/api/v2/desk/booking.rb +10 -0
- data/lib/pike13/api/v2/desk/business.rb +2 -1
- data/lib/pike13/api/v2/desk/event_occurrence.rb +2 -2
- data/lib/pike13/api/v2/desk/person.rb +5 -3
- data/lib/pike13/api/v2/desk/plan.rb +2 -2
- data/lib/pike13/api/v2/desk/plan_product.rb +2 -2
- data/lib/pike13/api/v2/desk/service.rb +2 -2
- data/lib/pike13/api/v2/desk/visit.rb +2 -2
- data/lib/pike13/api/v2/front/branding.rb +2 -1
- data/lib/pike13/api/v2/front/business.rb +2 -1
- data/lib/pike13/api/v2/front/event_occurrence.rb +2 -2
- data/lib/pike13/api/v2/front/plan_product.rb +2 -2
- data/lib/pike13/api/v2/front/service.rb +2 -2
- data/lib/pike13/api/v2/front/visit.rb +2 -2
- data/lib/pike13/api/v3/desk/base.rb +46 -0
- data/lib/pike13/api/v3/desk/clients.rb +180 -0
- data/lib/pike13/api/v3/desk/enrollments.rb +203 -0
- data/lib/pike13/api/v3/desk/event_occurrence_staff_members.rb +170 -0
- data/lib/pike13/api/v3/desk/event_occurrences.rb +154 -0
- data/lib/pike13/api/v3/desk/invoice_item_transactions.rb +189 -0
- data/lib/pike13/api/v3/desk/invoice_items.rb +193 -0
- data/lib/pike13/api/v3/desk/invoices.rb +167 -0
- data/lib/pike13/api/v3/desk/monthly_business_metrics.rb +151 -0
- data/lib/pike13/api/v3/desk/pays.rb +128 -0
- data/lib/pike13/api/v3/desk/person_plans.rb +265 -0
- data/lib/pike13/api/v3/desk/staff_members.rb +127 -0
- data/lib/pike13/api/v3/desk/transactions.rb +169 -0
- data/lib/pike13/http_client.rb +4 -1
- data/lib/pike13/http_client_v3.rb +101 -0
- data/lib/pike13/validators.rb +136 -0
- data/lib/pike13/version.rb +1 -1
- data/lib/pike13.rb +26 -7
- metadata +19 -4
- data/lib/pike13/api/v2/account/me.rb +0 -20
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pike13
|
|
4
|
+
# Validation helpers for Pike13 API parameters
|
|
5
|
+
module Validators
|
|
6
|
+
class ValidationError < StandardError; end
|
|
7
|
+
|
|
8
|
+
# Validates idempotency token format (should be a non-empty string)
|
|
9
|
+
#
|
|
10
|
+
# @param token [String] The idempotency token
|
|
11
|
+
# @raise [ValidationError] if token is invalid
|
|
12
|
+
# @return [Boolean] true if valid
|
|
13
|
+
def self.validate_idempotency_token!(token)
|
|
14
|
+
if token.nil? || token.to_s.strip.empty?
|
|
15
|
+
raise ValidationError, "Idempotency token cannot be blank"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
unless token.is_a?(String)
|
|
19
|
+
raise ValidationError, "Idempotency token must be a string, got #{token.class}"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
if token.length > 255
|
|
23
|
+
raise ValidationError, "Idempotency token must be 255 characters or less, got #{token.length}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Validates note attributes (must have 'note' key, not 'body')
|
|
30
|
+
#
|
|
31
|
+
# @param attributes [Hash] Note attributes
|
|
32
|
+
# @raise [ValidationError] if attributes are invalid
|
|
33
|
+
# @return [Boolean] true if valid
|
|
34
|
+
def self.validate_note_attributes!(attributes)
|
|
35
|
+
unless attributes.is_a?(Hash)
|
|
36
|
+
raise ValidationError, "Note attributes must be a hash, got #{attributes.class}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if attributes.key?(:body) || attributes.key?("body")
|
|
40
|
+
raise ValidationError,
|
|
41
|
+
"Note attributes should use 'note' key, not 'body'. " \
|
|
42
|
+
"Example: { note: 'text', subject: 'optional' }"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if !attributes.key?(:note) && !attributes.key?("note")
|
|
46
|
+
raise ValidationError, "Note attributes must include 'note' key"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
note_value = attributes[:note] || attributes["note"]
|
|
50
|
+
if note_value.to_s.strip.empty?
|
|
51
|
+
raise ValidationError, "Note text cannot be blank"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
true
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Validates form of payment type
|
|
58
|
+
#
|
|
59
|
+
# @param type [String] Form of payment type
|
|
60
|
+
# @raise [ValidationError] if type is invalid
|
|
61
|
+
# @return [Boolean] true if valid
|
|
62
|
+
def self.validate_form_of_payment_type!(type)
|
|
63
|
+
valid_types = %w[creditcard ach]
|
|
64
|
+
|
|
65
|
+
unless type.is_a?(String)
|
|
66
|
+
raise ValidationError, "Form of payment type must be a string, got #{type.class}"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
unless valid_types.include?(type.downcase)
|
|
70
|
+
raise ValidationError,
|
|
71
|
+
"Form of payment type must be one of: #{valid_types.join(', ')}. Got: '#{type}'"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
true
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Validates booking parameters
|
|
78
|
+
#
|
|
79
|
+
# @param params [Hash] Booking parameters
|
|
80
|
+
# @raise [ValidationError] if parameters are invalid
|
|
81
|
+
# @return [Boolean] true if valid
|
|
82
|
+
def self.validate_booking_params!(params)
|
|
83
|
+
unless params.is_a?(Hash)
|
|
84
|
+
raise ValidationError, "Booking parameters must be a hash, got #{params.class}"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Check for idempotency token
|
|
88
|
+
token = params[:idempotency_token] || params["idempotency_token"]
|
|
89
|
+
if token
|
|
90
|
+
validate_idempotency_token!(token)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Require either event_occurrence_id or leases array
|
|
94
|
+
has_event = params[:event_occurrence_id] || params["event_occurrence_id"]
|
|
95
|
+
has_leases = params[:leases] || params["leases"]
|
|
96
|
+
|
|
97
|
+
unless has_event || has_leases
|
|
98
|
+
raise ValidationError,
|
|
99
|
+
"Booking must have either 'event_occurrence_id' or 'leases' parameter"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
true
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Validates person attributes for creation
|
|
106
|
+
#
|
|
107
|
+
# @param attributes [Hash] Person attributes
|
|
108
|
+
# @raise [ValidationError] if attributes are invalid
|
|
109
|
+
# @return [Boolean] true if valid
|
|
110
|
+
def self.validate_person_attributes!(attributes)
|
|
111
|
+
unless attributes.is_a?(Hash)
|
|
112
|
+
raise ValidationError, "Person attributes must be a hash, got #{attributes.class}"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Check required fields
|
|
116
|
+
first_name = attributes[:first_name] || attributes["first_name"]
|
|
117
|
+
last_name = attributes[:last_name] || attributes["last_name"]
|
|
118
|
+
|
|
119
|
+
if first_name.to_s.strip.empty?
|
|
120
|
+
raise ValidationError, "Person must have a first_name"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
if last_name.to_s.strip.empty?
|
|
124
|
+
raise ValidationError, "Person must have a last_name"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Validate email format if provided
|
|
128
|
+
email = attributes[:email] || attributes["email"]
|
|
129
|
+
if email && !email.to_s.match?(/\A[^@\s]+@[^@\s]+\z/)
|
|
130
|
+
raise ValidationError, "Invalid email format: #{email}"
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
true
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
data/lib/pike13/version.rb
CHANGED
data/lib/pike13.rb
CHANGED
|
@@ -4,14 +4,17 @@ require_relative "pike13/version"
|
|
|
4
4
|
require_relative "pike13/configuration"
|
|
5
5
|
require_relative "pike13/errors"
|
|
6
6
|
require_relative "pike13/http_client"
|
|
7
|
+
require_relative "pike13/http_client_v3"
|
|
8
|
+
require_relative "pike13/validators"
|
|
7
9
|
|
|
8
10
|
# Namespace base classes
|
|
9
11
|
require_relative "pike13/api/v2/desk/base"
|
|
10
12
|
require_relative "pike13/api/v2/front/base"
|
|
11
13
|
require_relative "pike13/api/v2/account/base"
|
|
14
|
+
require_relative "pike13/api/v3/desk/base"
|
|
12
15
|
|
|
13
16
|
# Account namespace resources
|
|
14
|
-
require_relative "pike13/api/v2/account
|
|
17
|
+
require_relative "pike13/api/v2/account"
|
|
15
18
|
require_relative "pike13/api/v2/account/business"
|
|
16
19
|
require_relative "pike13/api/v2/account/person"
|
|
17
20
|
require_relative "pike13/api/v2/account/password"
|
|
@@ -78,6 +81,20 @@ require_relative "pike13/api/v2/front/visit"
|
|
|
78
81
|
require_relative "pike13/api/v2/front/waitlist_entry"
|
|
79
82
|
require_relative "pike13/api/v2/front/payment"
|
|
80
83
|
|
|
84
|
+
# V3 Reporting resources
|
|
85
|
+
require_relative "pike13/api/v3/desk/clients"
|
|
86
|
+
require_relative "pike13/api/v3/desk/enrollments"
|
|
87
|
+
require_relative "pike13/api/v3/desk/event_occurrences"
|
|
88
|
+
require_relative "pike13/api/v3/desk/event_occurrence_staff_members"
|
|
89
|
+
require_relative "pike13/api/v3/desk/invoice_items"
|
|
90
|
+
require_relative "pike13/api/v3/desk/invoice_item_transactions"
|
|
91
|
+
require_relative "pike13/api/v3/desk/invoices"
|
|
92
|
+
require_relative "pike13/api/v3/desk/monthly_business_metrics"
|
|
93
|
+
require_relative "pike13/api/v3/desk/pays"
|
|
94
|
+
require_relative "pike13/api/v3/desk/person_plans"
|
|
95
|
+
require_relative "pike13/api/v3/desk/staff_members"
|
|
96
|
+
require_relative "pike13/api/v3/desk/transactions"
|
|
97
|
+
|
|
81
98
|
# Pike13 Ruby Client
|
|
82
99
|
#
|
|
83
100
|
# A Ruby gem for interacting with the Pike13 API.
|
|
@@ -94,21 +111,22 @@ require_relative "pike13/api/v2/front/payment"
|
|
|
94
111
|
#
|
|
95
112
|
# @example Using different namespaces
|
|
96
113
|
# # Account namespace (not scoped to business subdomain)
|
|
97
|
-
# account = Pike13::
|
|
98
|
-
# businesses = Pike13::
|
|
114
|
+
# account = Pike13::Account.me
|
|
115
|
+
# businesses = Pike13::Account::Business.all
|
|
99
116
|
#
|
|
100
117
|
# # Desk namespace (staff interface)
|
|
101
|
-
# people = Pike13::
|
|
102
|
-
# events = Pike13::
|
|
118
|
+
# people = Pike13::Desk::Person.all
|
|
119
|
+
# events = Pike13::Desk::Event.all
|
|
103
120
|
#
|
|
104
121
|
# # Front namespace (client interface)
|
|
105
|
-
# locations = Pike13::
|
|
106
|
-
# branding = Pike13::
|
|
122
|
+
# locations = Pike13::Front::Location.all
|
|
123
|
+
# branding = Pike13::Front::Branding.all.first
|
|
107
124
|
module Pike13
|
|
108
125
|
# Simplified namespace aliases
|
|
109
126
|
Account = API::V2::Account
|
|
110
127
|
Desk = API::V2::Desk
|
|
111
128
|
Front = API::V2::Front
|
|
129
|
+
Reporting = API::V3::Desk
|
|
112
130
|
|
|
113
131
|
class << self
|
|
114
132
|
attr_writer :configuration
|
|
@@ -154,6 +172,7 @@ module Pike13
|
|
|
154
172
|
API::V2::Desk::Base.configure(configuration)
|
|
155
173
|
API::V2::Front::Base.configure(configuration)
|
|
156
174
|
API::V2::Account::Base.configure(configuration)
|
|
175
|
+
API::V3::Desk::Base.configure(configuration)
|
|
157
176
|
end
|
|
158
177
|
end
|
|
159
178
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pike13
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Huttemann
|
|
@@ -23,7 +23,7 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0.21'
|
|
26
|
-
description: A Ruby gem for interacting with the Pike13
|
|
26
|
+
description: A Ruby gem for interacting with the Pike13 API
|
|
27
27
|
email:
|
|
28
28
|
- juanfhuttemann@gmail.com
|
|
29
29
|
executables: []
|
|
@@ -34,10 +34,10 @@ files:
|
|
|
34
34
|
- LICENSE.txt
|
|
35
35
|
- README.md
|
|
36
36
|
- lib/pike13.rb
|
|
37
|
+
- lib/pike13/api/v2/account.rb
|
|
37
38
|
- lib/pike13/api/v2/account/base.rb
|
|
38
39
|
- lib/pike13/api/v2/account/business.rb
|
|
39
40
|
- lib/pike13/api/v2/account/confirmation.rb
|
|
40
|
-
- lib/pike13/api/v2/account/me.rb
|
|
41
41
|
- lib/pike13/api/v2/account/password.rb
|
|
42
42
|
- lib/pike13/api/v2/account/person.rb
|
|
43
43
|
- lib/pike13/api/v2/desk/appointment.rb
|
|
@@ -99,9 +99,24 @@ files:
|
|
|
99
99
|
- lib/pike13/api/v2/front/staff_member.rb
|
|
100
100
|
- lib/pike13/api/v2/front/visit.rb
|
|
101
101
|
- lib/pike13/api/v2/front/waitlist_entry.rb
|
|
102
|
+
- lib/pike13/api/v3/desk/base.rb
|
|
103
|
+
- lib/pike13/api/v3/desk/clients.rb
|
|
104
|
+
- lib/pike13/api/v3/desk/enrollments.rb
|
|
105
|
+
- lib/pike13/api/v3/desk/event_occurrence_staff_members.rb
|
|
106
|
+
- lib/pike13/api/v3/desk/event_occurrences.rb
|
|
107
|
+
- lib/pike13/api/v3/desk/invoice_item_transactions.rb
|
|
108
|
+
- lib/pike13/api/v3/desk/invoice_items.rb
|
|
109
|
+
- lib/pike13/api/v3/desk/invoices.rb
|
|
110
|
+
- lib/pike13/api/v3/desk/monthly_business_metrics.rb
|
|
111
|
+
- lib/pike13/api/v3/desk/pays.rb
|
|
112
|
+
- lib/pike13/api/v3/desk/person_plans.rb
|
|
113
|
+
- lib/pike13/api/v3/desk/staff_members.rb
|
|
114
|
+
- lib/pike13/api/v3/desk/transactions.rb
|
|
102
115
|
- lib/pike13/configuration.rb
|
|
103
116
|
- lib/pike13/errors.rb
|
|
104
117
|
- lib/pike13/http_client.rb
|
|
118
|
+
- lib/pike13/http_client_v3.rb
|
|
119
|
+
- lib/pike13/validators.rb
|
|
105
120
|
- lib/pike13/version.rb
|
|
106
121
|
homepage: https://github.com/juanhuttemann/pike13-ruby
|
|
107
122
|
licenses:
|
|
@@ -127,5 +142,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
127
142
|
requirements: []
|
|
128
143
|
rubygems_version: 3.6.9
|
|
129
144
|
specification_version: 4
|
|
130
|
-
summary: Ruby client for the Pike13
|
|
145
|
+
summary: Ruby client for the Pike13 API
|
|
131
146
|
test_files: []
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Pike13
|
|
4
|
-
module API
|
|
5
|
-
module V2
|
|
6
|
-
module Account
|
|
7
|
-
# Account resource for fetching current account details
|
|
8
|
-
class Me < Base
|
|
9
|
-
class << self
|
|
10
|
-
# GET /account
|
|
11
|
-
# Returns { accounts: [...] }
|
|
12
|
-
def me
|
|
13
|
-
client.get("account")
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|