pike13 0.1.0.beta

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 (75) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +134 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +634 -0
  5. data/lib/pike13/api/v2/account/base.rb +31 -0
  6. data/lib/pike13/api/v2/account/business.rb +23 -0
  7. data/lib/pike13/api/v2/account/confirmation.rb +18 -0
  8. data/lib/pike13/api/v2/account/me.rb +20 -0
  9. data/lib/pike13/api/v2/account/password.rb +18 -0
  10. data/lib/pike13/api/v2/account/person.rb +18 -0
  11. data/lib/pike13/api/v2/desk/appointment.rb +28 -0
  12. data/lib/pike13/api/v2/desk/base.rb +30 -0
  13. data/lib/pike13/api/v2/desk/booking.rb +43 -0
  14. data/lib/pike13/api/v2/desk/business.rb +23 -0
  15. data/lib/pike13/api/v2/desk/custom_field.rb +23 -0
  16. data/lib/pike13/api/v2/desk/event.rb +23 -0
  17. data/lib/pike13/api/v2/desk/event_occurrence.rb +33 -0
  18. data/lib/pike13/api/v2/desk/event_occurrence_note.rb +38 -0
  19. data/lib/pike13/api/v2/desk/event_occurrence_visit.rb +18 -0
  20. data/lib/pike13/api/v2/desk/event_occurrence_waitlist_entry.rb +18 -0
  21. data/lib/pike13/api/v2/desk/form_of_payment.rb +38 -0
  22. data/lib/pike13/api/v2/desk/invoice.rb +83 -0
  23. data/lib/pike13/api/v2/desk/location.rb +23 -0
  24. data/lib/pike13/api/v2/desk/make_up.rb +36 -0
  25. data/lib/pike13/api/v2/desk/note.rb +38 -0
  26. data/lib/pike13/api/v2/desk/pack.rb +28 -0
  27. data/lib/pike13/api/v2/desk/pack_product.rb +43 -0
  28. data/lib/pike13/api/v2/desk/payment.rb +31 -0
  29. data/lib/pike13/api/v2/desk/person.rb +48 -0
  30. data/lib/pike13/api/v2/desk/person_plan.rb +18 -0
  31. data/lib/pike13/api/v2/desk/person_visit.rb +18 -0
  32. data/lib/pike13/api/v2/desk/person_waitlist_entry.rb +18 -0
  33. data/lib/pike13/api/v2/desk/person_waiver.rb +18 -0
  34. data/lib/pike13/api/v2/desk/plan.rb +28 -0
  35. data/lib/pike13/api/v2/desk/plan_product.rb +23 -0
  36. data/lib/pike13/api/v2/desk/punch.rb +33 -0
  37. data/lib/pike13/api/v2/desk/refund.rb +23 -0
  38. data/lib/pike13/api/v2/desk/revenue_category.rb +23 -0
  39. data/lib/pike13/api/v2/desk/sales_tax.rb +23 -0
  40. data/lib/pike13/api/v2/desk/service.rb +28 -0
  41. data/lib/pike13/api/v2/desk/staff_member.rb +28 -0
  42. data/lib/pike13/api/v2/desk/visit.rb +43 -0
  43. data/lib/pike13/api/v2/desk/waitlist_entry.rb +38 -0
  44. data/lib/pike13/api/v2/front/appointment.rb +28 -0
  45. data/lib/pike13/api/v2/front/base.rb +30 -0
  46. data/lib/pike13/api/v2/front/booking.rb +53 -0
  47. data/lib/pike13/api/v2/front/branding.rb +18 -0
  48. data/lib/pike13/api/v2/front/business.rb +23 -0
  49. data/lib/pike13/api/v2/front/event.rb +23 -0
  50. data/lib/pike13/api/v2/front/event_occurrence.rb +33 -0
  51. data/lib/pike13/api/v2/front/event_occurrence_note.rb +23 -0
  52. data/lib/pike13/api/v2/front/event_occurrence_waitlist_eligibility.rb +18 -0
  53. data/lib/pike13/api/v2/front/form_of_payment.rb +43 -0
  54. data/lib/pike13/api/v2/front/invoice.rb +58 -0
  55. data/lib/pike13/api/v2/front/location.rb +23 -0
  56. data/lib/pike13/api/v2/front/note.rb +24 -0
  57. data/lib/pike13/api/v2/front/payment.rb +23 -0
  58. data/lib/pike13/api/v2/front/person.rb +23 -0
  59. data/lib/pike13/api/v2/front/person_plan.rb +18 -0
  60. data/lib/pike13/api/v2/front/person_visit.rb +18 -0
  61. data/lib/pike13/api/v2/front/person_waitlist_entry.rb +18 -0
  62. data/lib/pike13/api/v2/front/person_waiver.rb +18 -0
  63. data/lib/pike13/api/v2/front/plan.rb +28 -0
  64. data/lib/pike13/api/v2/front/plan_product.rb +23 -0
  65. data/lib/pike13/api/v2/front/plan_terms.rb +28 -0
  66. data/lib/pike13/api/v2/front/service.rb +28 -0
  67. data/lib/pike13/api/v2/front/staff_member.rb +23 -0
  68. data/lib/pike13/api/v2/front/visit.rb +33 -0
  69. data/lib/pike13/api/v2/front/waitlist_entry.rb +33 -0
  70. data/lib/pike13/configuration.rb +58 -0
  71. data/lib/pike13/errors.rb +104 -0
  72. data/lib/pike13/http_client.rb +175 -0
  73. data/lib/pike13/version.rb +5 -0
  74. data/lib/pike13.rb +159 -0
  75. metadata +131 -0
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class FormOfPayment < Base
8
+ class << self
9
+ # GET /front/people/:person_id/form_of_payments
10
+ def all(person_id:, **params)
11
+ client.get("front/people/#{person_id}/form_of_payments", params)
12
+ end
13
+
14
+ # GET /front/people/:person_id/form_of_payments/:id
15
+ def find(person_id:, id:)
16
+ client.get("front/people/#{person_id}/form_of_payments/#{id}")
17
+ end
18
+
19
+ # GET /front/people/me/form_of_payments/:id
20
+ def find_me(id:)
21
+ client.get("front/people/me/form_of_payments/#{id}")
22
+ end
23
+
24
+ # POST /front/people/:person_id/form_of_payments
25
+ def create(person_id:, attributes:)
26
+ client.post("front/people/#{person_id}/form_of_payments", { form_of_payment: attributes })
27
+ end
28
+
29
+ # PUT /front/people/:person_id/form_of_payments/:id
30
+ def update(person_id:, id:, attributes:)
31
+ client.put("front/people/#{person_id}/form_of_payments/#{id}", { form_of_payment: attributes })
32
+ end
33
+
34
+ # DELETE /front/people/:person_id/form_of_payments/:id
35
+ def destroy(person_id:, id:)
36
+ client.delete("front/people/#{person_id}/form_of_payments/#{id}")
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class Invoice < Base
8
+ class << self
9
+ # GET /front/invoices
10
+ def all
11
+ client.get("front/invoices")
12
+ end
13
+
14
+ # GET /front/invoices/:id
15
+ def find(id)
16
+ client.get("front/invoices/#{id}")
17
+ end
18
+
19
+ # GET /front/invoices/:id/payment_methods
20
+ def payment_methods(id)
21
+ client.get("front/invoices/#{id}/payment_methods")
22
+ end
23
+
24
+ # POST /front/invoices
25
+ def create(attributes)
26
+ client.post("front/invoices", { invoice: attributes })
27
+ end
28
+
29
+ # PUT /front/invoices/:invoice_id
30
+ def update(invoice_id, attributes)
31
+ client.put("front/invoices/#{invoice_id}", { invoice: attributes })
32
+ end
33
+
34
+ # POST /front/invoices/:invoice_id/invoice_items
35
+ def create_invoice_item(invoice_id, attributes)
36
+ client.post("front/invoices/#{invoice_id}/invoice_items", { invoice_item: attributes })
37
+ end
38
+
39
+ # DELETE /front/invoices/:invoice_id/invoice_items/:id
40
+ def destroy_invoice_item(invoice_id, id)
41
+ client.delete("front/invoices/#{invoice_id}/invoice_items/#{id}")
42
+ end
43
+
44
+ # POST /front/invoices/:invoice_id/payments
45
+ def create_payment(invoice_id, attributes)
46
+ client.post("front/invoices/#{invoice_id}/payments", attributes)
47
+ end
48
+
49
+ # DELETE /front/invoices/:invoice_id/payments/:payment_id
50
+ def destroy_payment(invoice_id, payment_id)
51
+ client.delete("front/invoices/#{invoice_id}/payments/#{payment_id}")
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class Location < Base
8
+ class << self
9
+ # GET /front/locations
10
+ def all
11
+ client.get("front/locations")
12
+ end
13
+
14
+ # GET /front/locations/:id
15
+ def find(id)
16
+ client.get("front/locations/#{id}")
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ # Notes in Front API are nested under people
8
+ class Note < Base
9
+ class << self
10
+ # GET /front/people/:person_id/notes
11
+ def all(person_id:)
12
+ client.get("front/people/#{person_id}/notes")
13
+ end
14
+
15
+ # GET /front/people/:person_id/notes/:id
16
+ def find(person_id:, id:)
17
+ client.get("front/people/#{person_id}/notes/#{id}")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class Payment < Base
8
+ class << self
9
+ # GET /front/payments/:id
10
+ def find(id)
11
+ client.get("front/payments/#{id}")
12
+ end
13
+
14
+ # GET /front/payments/configuration
15
+ def configuration
16
+ client.get("front/payments/configuration")
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class Person < Base
8
+ class << self
9
+ # GET /front/people/:id
10
+ def find(id)
11
+ client.get("front/people/#{id}")
12
+ end
13
+
14
+ # GET /front/people/me
15
+ def me
16
+ find(:me)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class PersonPlan < Base
8
+ class << self
9
+ # GET /front/people/:person_id/plans
10
+ def all(person_id:, **params)
11
+ client.get("front/people/#{person_id}/plans", params)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class PersonVisit < Base
8
+ class << self
9
+ # GET /front/people/:person_id/visits
10
+ def all(person_id:, **params)
11
+ client.get("front/people/#{person_id}/visits", params)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class PersonWaitlistEntry < Base
8
+ class << self
9
+ # GET /front/people/:person_id/waitlist_entries
10
+ def all(person_id:, **params)
11
+ client.get("front/people/#{person_id}/waitlist_entries", params)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class PersonWaiver < Base
8
+ class << self
9
+ # GET /front/people/:person_id/waivers
10
+ def all(person_id:, **params)
11
+ client.get("front/people/#{person_id}/waivers", params)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class Plan < Base
8
+ class << self
9
+ # GET /front/plans
10
+ def all
11
+ client.get("front/plans")
12
+ end
13
+
14
+ # GET /front/plans/:id
15
+ def find(id)
16
+ client.get("front/plans/#{id}")
17
+ end
18
+
19
+ # GET /front/plans/:id/plan_terms
20
+ def plan_terms(id)
21
+ client.get("front/plans/#{id}/plan_terms")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class PlanProduct < Base
8
+ class << self
9
+ # GET /front/plan_products
10
+ def all
11
+ client.get("front/plan_products")
12
+ end
13
+
14
+ # GET /front/plan_products/:id
15
+ def find(id)
16
+ client.get("front/plan_products/#{id}")
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class PlanTerms < Base
8
+ class << self
9
+ # GET /front/plans/:plan_id/plan_terms
10
+ def all(plan_id:, **params)
11
+ client.get("front/plans/#{plan_id}/plan_terms", params)
12
+ end
13
+
14
+ # GET /front/plans/:plan_id/plan_terms/:plan_terms_id
15
+ def find(plan_id:, plan_terms_id:)
16
+ client.get("front/plans/#{plan_id}/plan_terms/#{plan_terms_id}")
17
+ end
18
+
19
+ # GET /front/plans/:plan_id/plan_terms/:plan_terms_id/complete
20
+ def complete(plan_id:, plan_terms_id:)
21
+ client.get("front/plans/#{plan_id}/plan_terms/#{plan_terms_id}/complete")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class Service < Base
8
+ class << self
9
+ # GET /front/services
10
+ def all
11
+ client.get("front/services")
12
+ end
13
+
14
+ # GET /front/services/:id
15
+ def find(id)
16
+ client.get("front/services/#{id}")
17
+ end
18
+
19
+ # GET /front/services/:service_id/enrollment_eligibilities
20
+ def enrollment_eligibilities(service_id:, **params)
21
+ client.get("front/services/#{service_id}/enrollment_eligibilities", params)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class StaffMember < Base
8
+ class << self
9
+ # GET /front/staff_members
10
+ def all
11
+ client.get("front/staff_members")
12
+ end
13
+
14
+ # GET /front/staff_members/:id
15
+ def find(id)
16
+ client.get("front/staff_members/#{id}")
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class Visit < Base
8
+ class << self
9
+ # GET /front/visits
10
+ def all
11
+ client.get("front/visits")
12
+ end
13
+
14
+ # GET /front/visits/:id
15
+ def find(id)
16
+ client.get("front/visits/#{id}")
17
+ end
18
+
19
+ # POST /front/visits
20
+ def create(attributes)
21
+ client.post("front/visits", { visit: attributes })
22
+ end
23
+
24
+ # DELETE /front/visits/:id
25
+ def destroy(id, **params)
26
+ client.delete("front/visits/#{id}", params)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module API
5
+ module V2
6
+ module Front
7
+ class WaitlistEntry < Base
8
+ class << self
9
+ # GET /front/waitlist_entries
10
+ def all
11
+ client.get("front/waitlist_entries")
12
+ end
13
+
14
+ # GET /front/waitlist_entries/:id
15
+ def find(id)
16
+ client.get("front/waitlist_entries/#{id}")
17
+ end
18
+
19
+ # POST /front/waitlist_entries
20
+ def create(attributes)
21
+ client.post("front/waitlist_entries", { waitlist_entry: attributes })
22
+ end
23
+
24
+ # DELETE /front/waitlist_entries/:id
25
+ def destroy(id)
26
+ client.delete("front/waitlist_entries/#{id}")
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ class Configuration
5
+ attr_accessor :access_token, :base_url
6
+
7
+ def initialize
8
+ @access_token = nil
9
+ @base_url = "https://pike13.com"
10
+ end
11
+
12
+ # Returns the normalized base URL (adds https:// if missing)
13
+ # Infers http:// for localhost/.test domains, https:// otherwise
14
+ #
15
+ # @return [String]
16
+ def full_url
17
+ return base_url if base_url.to_s.start_with?("http://", "https://")
18
+
19
+ "#{inferred_scheme}://#{base_url}"
20
+ end
21
+
22
+ # Returns the normalized account base URL
23
+ # Extracts the domain and port from base_url
24
+ #
25
+ # @return [String]
26
+ def account_full_url
27
+ # Extract domain from base_url (strip subdomain, keep domain + port)
28
+ url = base_url.to_s.sub(%r{^https?://}, "")
29
+
30
+ # Extract domain and port
31
+ parts = url.split(".")
32
+ if parts.length >= 2
33
+ # Keep last two parts (domain.tld) plus port if exists
34
+ domain_parts = parts[-2..]
35
+ domain_with_port = domain_parts.join(".")
36
+ else
37
+ # Single part (like localhost), keep as is
38
+ domain_with_port = url
39
+ end
40
+
41
+ "#{inferred_scheme}://#{domain_with_port}"
42
+ end
43
+
44
+ # Validates the configuration
45
+ #
46
+ # @raise [Pike13::ConfigurationError] if configuration is invalid
47
+ def validate!
48
+ raise Pike13::ConfigurationError, "access_token is required" unless access_token
49
+ end
50
+
51
+ private
52
+
53
+ def inferred_scheme
54
+ url = base_url.to_s.sub(%r{^https?://}, "")
55
+ url.start_with?("localhost") || url.include?(".test") ? "http" : "https"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ # Base error class for all Pike13 errors
5
+ class Error < StandardError; end
6
+
7
+ # Raised when configuration is invalid or missing
8
+ #
9
+ # @example
10
+ # Pike13::Client.new # raises ConfigurationError: "access_token is required"
11
+ class ConfigurationError < Error; end
12
+
13
+ # Base class for all API-related errors
14
+ # Provides access to HTTP status and response body
15
+ #
16
+ # @attr_reader [Integer, nil] http_status HTTP status code from the API
17
+ # @attr_reader [Hash, String, nil] response_body Response body from the API
18
+ class APIError < Error
19
+ attr_reader :http_status, :response_body
20
+
21
+ # @param message [String, nil] Error message
22
+ # @param http_status [Integer, nil] HTTP status code
23
+ # @param response_body [Hash, String, nil] API response body
24
+ def initialize(message = nil, http_status: nil, response_body: nil)
25
+ @http_status = http_status
26
+ @response_body = response_body
27
+ super(message)
28
+ end
29
+ end
30
+
31
+ # Raised when authentication fails (HTTP 401)
32
+ #
33
+ # @example
34
+ # begin
35
+ # client.desk.people.all
36
+ # rescue Pike13::AuthenticationError => e
37
+ # puts "Invalid access token: #{e.message}"
38
+ # end
39
+ class AuthenticationError < APIError; end
40
+
41
+ # Alias for backward compatibility
42
+ UnauthorizedError = AuthenticationError
43
+
44
+ # Raised when rate limit is exceeded (HTTP 429)
45
+ #
46
+ # @attr_reader [String, nil] rate_limit_reset Timestamp when rate limit resets
47
+ #
48
+ # @example Handle rate limiting
49
+ # begin
50
+ # client.desk.people.all
51
+ # rescue Pike13::RateLimitError => e
52
+ # puts "Rate limit exceeded. Resets at: #{e.rate_limit_reset}"
53
+ # sleep 60
54
+ # retry
55
+ # end
56
+ class RateLimitError < APIError
57
+ attr_reader :rate_limit_reset
58
+
59
+ # @param message [String, nil] Error message
60
+ # @param http_status [Integer, nil] HTTP status code
61
+ # @param response_body [Hash, String, nil] API response body
62
+ # @param rate_limit_reset [String, nil] Timestamp when rate limit resets
63
+ def initialize(message = nil, http_status: nil, response_body: nil, rate_limit_reset: nil)
64
+ @rate_limit_reset = rate_limit_reset
65
+ super(message, http_status: http_status, response_body: response_body)
66
+ end
67
+ end
68
+
69
+ # Raised when a resource is not found (HTTP 404)
70
+ #
71
+ # @example
72
+ # begin
73
+ # person = client.desk.people.find(999999)
74
+ # rescue Pike13::NotFoundError => e
75
+ # puts "Person not found"
76
+ # end
77
+ class NotFoundError < APIError; end
78
+
79
+ # Raised when validation fails (HTTP 422)
80
+ #
81
+ # @example
82
+ # begin
83
+ # # attempt to create/update with invalid data
84
+ # rescue Pike13::ValidationError => e
85
+ # puts "Validation failed: #{e.response_body}"
86
+ # end
87
+ class ValidationError < APIError; end
88
+
89
+ # Raised when server error occurs (HTTP 5xx)
90
+ #
91
+ # @example
92
+ # begin
93
+ # client.desk.people.all
94
+ # rescue Pike13::ServerError => e
95
+ # puts "Server error: #{e.http_status}"
96
+ # end
97
+ class ServerError < APIError; end
98
+
99
+ # Raised when request is malformed (HTTP 400)
100
+ class BadRequestError < APIError; end
101
+
102
+ # Raised when connection to API fails
103
+ class ConnectionError < Error; end
104
+ end