supersaas-api-client 2.0.5 → 2.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.
- checksums.yaml +4 -4
- data/README.md +122 -37
- data/examples/appointments.rb +16 -22
- data/examples/forms.rb +9 -5
- data/examples/groups.rb +2 -1
- data/examples/promotions.rb +5 -4
- data/examples/schedules.rb +7 -7
- data/examples/slots.rb +42 -0
- data/examples/users.rb +1 -1
- data/lib/supersaas-api-client/api/appointments.rb +27 -36
- data/lib/supersaas-api-client/api/base_api.rb +2 -0
- data/lib/supersaas-api-client/api/groups.rb +1 -1
- data/lib/supersaas-api-client/api/hooks.rb +25 -0
- data/lib/supersaas-api-client/api/promotions.rb +1 -1
- data/lib/supersaas-api-client/api/schedules.rb +9 -1
- data/lib/supersaas-api-client/api/slots.rb +63 -0
- data/lib/supersaas-api-client/api/users.rb +30 -40
- data/lib/supersaas-api-client/client.rb +44 -30
- data/lib/supersaas-api-client/exception.rb +8 -0
- data/lib/supersaas-api-client/models/base_model.rb +18 -2
- data/lib/supersaas-api-client/models/field_list.rb +11 -2
- data/lib/supersaas-api-client/models/slot.rb +1 -1
- data/lib/supersaas-api-client/version.rb +1 -1
- data/lib/supersaas.rb +2 -0
- metadata +11 -17
- data/.github/workflows/actions.yaml +0 -21
- data/.gitignore +0 -13
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -298
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -49
- data/Rakefile +0 -12
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/supersaas-api-client.gemspec +0 -28
|
@@ -67,24 +67,7 @@ module Supersaas
|
|
|
67
67
|
webhook: webhook,
|
|
68
68
|
user_id: validate_id(user_id),
|
|
69
69
|
form: form ? true : nil,
|
|
70
|
-
booking:
|
|
71
|
-
start: attributes[:start],
|
|
72
|
-
finish: attributes[:finish],
|
|
73
|
-
email: attributes[:email],
|
|
74
|
-
res_name: attributes[:name],
|
|
75
|
-
full_name: attributes[:full_name],
|
|
76
|
-
address: attributes[:address],
|
|
77
|
-
mobile: attributes[:mobile],
|
|
78
|
-
phone: attributes[:phone],
|
|
79
|
-
country: attributes[:country],
|
|
80
|
-
field_1: attributes[:field_1],
|
|
81
|
-
field_2: attributes[:field_2],
|
|
82
|
-
field_1_r: attributes[:field_1_r],
|
|
83
|
-
field_2_r: attributes[:field_2_r],
|
|
84
|
-
super_field: attributes[:super_field],
|
|
85
|
-
resource_id: attributes[:resource_id],
|
|
86
|
-
slot_id: attributes[:slot_id]
|
|
87
|
-
}
|
|
70
|
+
booking: booking_params(attributes)
|
|
88
71
|
}
|
|
89
72
|
params[:booking].compact!
|
|
90
73
|
client.post(path, params)
|
|
@@ -94,24 +77,7 @@ module Supersaas
|
|
|
94
77
|
path = "/bookings/#{validate_id(appointment_id)}"
|
|
95
78
|
params = {
|
|
96
79
|
schedule_id: schedule_id,
|
|
97
|
-
booking:
|
|
98
|
-
start: attributes[:start],
|
|
99
|
-
finish: attributes[:finish],
|
|
100
|
-
email: attributes[:email],
|
|
101
|
-
res_name: attributes[:name],
|
|
102
|
-
full_name: attributes[:full_name],
|
|
103
|
-
address: attributes[:address],
|
|
104
|
-
mobile: attributes[:mobile],
|
|
105
|
-
phone: attributes[:phone],
|
|
106
|
-
country: attributes[:country],
|
|
107
|
-
field_1: attributes[:field_1],
|
|
108
|
-
field_2: attributes[:field_2],
|
|
109
|
-
field_1_r: attributes[:field_1_r],
|
|
110
|
-
field_2_r: attributes[:field_2_r],
|
|
111
|
-
super_field: attributes[:super_field],
|
|
112
|
-
resource_id: attributes[:resource_id],
|
|
113
|
-
slot_id: attributes[:slot_id]
|
|
114
|
-
}
|
|
80
|
+
booking: booking_params(attributes)
|
|
115
81
|
}
|
|
116
82
|
|
|
117
83
|
params.merge!(form: form) if form
|
|
@@ -146,6 +112,31 @@ module Supersaas
|
|
|
146
112
|
|
|
147
113
|
private
|
|
148
114
|
|
|
115
|
+
# Input attributes only. description is for resource schedules, quantity (number of places) for capacity schedules, form_id attaches an existing form
|
|
116
|
+
def booking_params(attributes)
|
|
117
|
+
{
|
|
118
|
+
start: attributes[:start],
|
|
119
|
+
finish: attributes[:finish],
|
|
120
|
+
email: attributes[:email],
|
|
121
|
+
res_name: attributes[:name],
|
|
122
|
+
full_name: attributes[:full_name],
|
|
123
|
+
address: attributes[:address],
|
|
124
|
+
mobile: attributes[:mobile],
|
|
125
|
+
phone: attributes[:phone],
|
|
126
|
+
country: attributes[:country],
|
|
127
|
+
field_1: attributes[:field_1],
|
|
128
|
+
field_2: attributes[:field_2],
|
|
129
|
+
field_1_r: attributes[:field_1_r],
|
|
130
|
+
field_2_r: attributes[:field_2_r],
|
|
131
|
+
super_field: attributes[:super_field],
|
|
132
|
+
resource_id: attributes[:resource_id],
|
|
133
|
+
slot_id: attributes[:slot_id],
|
|
134
|
+
description: attributes[:description],
|
|
135
|
+
quantity: attributes[:quantity],
|
|
136
|
+
form_id: attributes[:form_id]
|
|
137
|
+
}
|
|
138
|
+
end
|
|
139
|
+
|
|
149
140
|
def map_slots_or_bookings(obj, slot = false)
|
|
150
141
|
if obj.is_a?(Array) && slot
|
|
151
142
|
obj.map { |attributes| Supersaas::Slot.new(attributes) }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Supersaas
|
|
4
|
+
# REF: https://www.supersaas.com/info/dev/information_api#groups
|
|
4
5
|
class Groups < BaseApi
|
|
5
|
-
# REF: https://www.supersaas.com/info/dev/information_api#groups
|
|
6
6
|
def list
|
|
7
7
|
path = '/groups'
|
|
8
8
|
res = client.get(path)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Supersaas
|
|
4
|
+
# REF: https://www.supersaas.com/info/dev/webhooks
|
|
5
|
+
class Hooks < BaseApi
|
|
6
|
+
# event: the trigger, e.g. 'U' (user created), 'M' (user changed), 'N' (new appointment), 'C' (changed appointment)
|
|
7
|
+
# parent_id: the schedule id for appointment events, the super form id for form events, else the account id
|
|
8
|
+
# Returns { 'id' => ..., 'parent_id' => ... }
|
|
9
|
+
def create(target_url, event, parent_id)
|
|
10
|
+
path = '/hooks'
|
|
11
|
+
params = {
|
|
12
|
+
target_url: validate_present(target_url),
|
|
13
|
+
event: validate_present(event),
|
|
14
|
+
parent_id: validate_id(parent_id)
|
|
15
|
+
}
|
|
16
|
+
client.post(path, params)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def delete(hook_id, parent_id)
|
|
20
|
+
path = '/hooks'
|
|
21
|
+
query = { id: validate_id(hook_id), parent_id: validate_id(parent_id) }
|
|
22
|
+
client.delete(path, nil, query)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Supersaas
|
|
4
|
+
# REF: https://www.supersaas.com/info/dev/promotion_api
|
|
4
5
|
class Promotions < BaseApi
|
|
5
|
-
# REF: https://www.supersaas.com/info/dev/promotion_api
|
|
6
6
|
def list(limit = nil, offset = nil)
|
|
7
7
|
path = '/promotions'
|
|
8
8
|
params = {}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Supersaas
|
|
4
|
+
# REF: https://www.supersaas.com/info/dev/information_api
|
|
4
5
|
class Schedules < BaseApi
|
|
5
|
-
# REF: https://www.supersaas.com/info/dev/information_api
|
|
6
6
|
def list
|
|
7
7
|
path = '/schedules'
|
|
8
8
|
res = client.get(path)
|
|
@@ -22,5 +22,13 @@ module Supersaas
|
|
|
22
22
|
res = client.get(path, query)
|
|
23
23
|
res.map { |attributes| Supersaas::FieldList.new(attributes) }
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
# The fields that can be set when creating a booking
|
|
27
|
+
def input_field_list(schedule_id)
|
|
28
|
+
path = '/input_field_list'
|
|
29
|
+
query = { schedule_id: validate_id(schedule_id) }
|
|
30
|
+
res = client.get(path, query)
|
|
31
|
+
res.map { |attributes| Supersaas::FieldList.new(attributes) }
|
|
32
|
+
end
|
|
25
33
|
end
|
|
26
34
|
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Supersaas
|
|
4
|
+
# REF: https://www.supersaas.com/info/dev/appointment_api#slots_api
|
|
5
|
+
# Only available for capacity type schedules.
|
|
6
|
+
class Slots < BaseApi
|
|
7
|
+
def list(schedule_id, start_time = nil, finish = nil, limit = nil, offset = nil)
|
|
8
|
+
path = '/slots'
|
|
9
|
+
params = {
|
|
10
|
+
schedule_id: validate_id(schedule_id),
|
|
11
|
+
start: start_time ? validate_datetime(start_time) : nil,
|
|
12
|
+
finish: finish ? validate_datetime(finish) : nil
|
|
13
|
+
}
|
|
14
|
+
params.merge!(limit: validate_number(limit)) if limit
|
|
15
|
+
params.merge!(offset: validate_number(offset)) if offset
|
|
16
|
+
res = client.get(path, params)
|
|
17
|
+
res.map { |attributes| Supersaas::Slot.new(attributes) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def get(schedule_id, slot_id)
|
|
21
|
+
params = { schedule_id: validate_id(schedule_id) }
|
|
22
|
+
path = "/slots/#{validate_id(slot_id)}"
|
|
23
|
+
res = client.get(path, params)
|
|
24
|
+
Supersaas::Slot.new(res)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def create(schedule_id, attributes)
|
|
28
|
+
path = '/slots'
|
|
29
|
+
query = { schedule_id: validate_id(schedule_id) }
|
|
30
|
+
client.post(path, { slot: slot_params(attributes) }, query)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def update(schedule_id, slot_id, attributes)
|
|
34
|
+
path = "/slots/#{validate_id(slot_id)}"
|
|
35
|
+
query = { schedule_id: validate_id(schedule_id) }
|
|
36
|
+
client.put(path, { slot: slot_params(attributes) }, query)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def delete(schedule_id, slot_id)
|
|
40
|
+
path = "/slots/#{validate_id(slot_id)}"
|
|
41
|
+
params = { schedule_id: validate_id(schedule_id) }
|
|
42
|
+
client.delete(path, nil, params)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
# capacity: an Integer, or '-' for unlimited, '0' for no places
|
|
48
|
+
def slot_params(attributes)
|
|
49
|
+
params = {
|
|
50
|
+
start: attributes[:start] && validate_datetime(attributes[:start]),
|
|
51
|
+
finish: attributes[:finish] && validate_datetime(attributes[:finish]),
|
|
52
|
+
title: attributes[:title],
|
|
53
|
+
description: attributes[:description],
|
|
54
|
+
location: attributes[:location],
|
|
55
|
+
capacity: attributes[:capacity],
|
|
56
|
+
price: attributes[:price],
|
|
57
|
+
color: attributes[:color]
|
|
58
|
+
}
|
|
59
|
+
params.compact!
|
|
60
|
+
params
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -28,26 +28,7 @@ module Supersaas
|
|
|
28
28
|
path = user_path(user_id)
|
|
29
29
|
query = { webhook: webhook }
|
|
30
30
|
query.merge!(duplicate: validate_duplicate(duplicate)) if duplicate
|
|
31
|
-
params = {
|
|
32
|
-
user: {
|
|
33
|
-
name: validate_name(attributes[:name]),
|
|
34
|
-
email: attributes[:email],
|
|
35
|
-
password: attributes[:password],
|
|
36
|
-
full_name: attributes[:full_name],
|
|
37
|
-
address: attributes[:address],
|
|
38
|
-
mobile: attributes[:mobile],
|
|
39
|
-
phone: attributes[:phone],
|
|
40
|
-
country: attributes[:country],
|
|
41
|
-
timezone: attributes[:timezone],
|
|
42
|
-
field_1: attributes[:field_1],
|
|
43
|
-
field_2: attributes[:field_2],
|
|
44
|
-
super_field: attributes[:super_field],
|
|
45
|
-
credit: attributes[:credit] && validate_number(attributes[:credit]),
|
|
46
|
-
role: attributes[:role] && validate_options(attributes[:role], User::ROLES),
|
|
47
|
-
group: attributes[:group] && validate_number(attributes[:group])
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
params[:user].compact!
|
|
31
|
+
params = { user: user_params(attributes) }
|
|
51
32
|
client.post(path, params, query)
|
|
52
33
|
end
|
|
53
34
|
|
|
@@ -55,26 +36,7 @@ module Supersaas
|
|
|
55
36
|
path = user_path(user_id)
|
|
56
37
|
query = { webhook: webhook }
|
|
57
38
|
query.merge!(notfound: validate_notfound(notfound)) if notfound
|
|
58
|
-
params = {
|
|
59
|
-
user: {
|
|
60
|
-
name: validate_name(attributes[:name]),
|
|
61
|
-
email: attributes[:email],
|
|
62
|
-
password: attributes[:password],
|
|
63
|
-
full_name: attributes[:full_name],
|
|
64
|
-
address: attributes[:address],
|
|
65
|
-
mobile: attributes[:mobile],
|
|
66
|
-
phone: attributes[:phone],
|
|
67
|
-
country: attributes[:country],
|
|
68
|
-
timezone: attributes[:timezone],
|
|
69
|
-
field_1: attributes[:field_1],
|
|
70
|
-
field_2: attributes[:field_2],
|
|
71
|
-
super_field: attributes[:super_field],
|
|
72
|
-
credit: attributes[:credit] && validate_number(attributes[:credit]),
|
|
73
|
-
role: attributes[:role] && validate_options(attributes[:role], User::ROLES),
|
|
74
|
-
group: attributes[:group] && validate_number(attributes[:group])
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
params[:user].compact!
|
|
39
|
+
params = { user: user_params(attributes) }
|
|
78
40
|
client.put(path, params, query)
|
|
79
41
|
end
|
|
80
42
|
|
|
@@ -90,6 +52,13 @@ module Supersaas
|
|
|
90
52
|
res.map { |attributes| Supersaas::FieldList.new(attributes) }
|
|
91
53
|
end
|
|
92
54
|
|
|
55
|
+
# The fields that can be set when creating a user
|
|
56
|
+
def input_field_list
|
|
57
|
+
path = '/input_field_list'
|
|
58
|
+
res = client.get(path)
|
|
59
|
+
res.map { |attributes| Supersaas::FieldList.new(attributes) }
|
|
60
|
+
end
|
|
61
|
+
|
|
93
62
|
private
|
|
94
63
|
|
|
95
64
|
def user_path(user_id)
|
|
@@ -99,5 +68,26 @@ module Supersaas
|
|
|
99
68
|
"/users/#{validate_user(user_id)}"
|
|
100
69
|
end
|
|
101
70
|
end
|
|
71
|
+
|
|
72
|
+
# The user attributes the API accepts, leaving out the ones that are nil
|
|
73
|
+
def user_params(attributes)
|
|
74
|
+
{
|
|
75
|
+
name: validate_name(attributes[:name]),
|
|
76
|
+
email: attributes[:email],
|
|
77
|
+
password: attributes[:password],
|
|
78
|
+
full_name: attributes[:full_name],
|
|
79
|
+
address: attributes[:address],
|
|
80
|
+
mobile: attributes[:mobile],
|
|
81
|
+
phone: attributes[:phone],
|
|
82
|
+
country: attributes[:country],
|
|
83
|
+
timezone: attributes[:timezone],
|
|
84
|
+
field_1: attributes[:field_1],
|
|
85
|
+
field_2: attributes[:field_2],
|
|
86
|
+
super_field: attributes[:super_field],
|
|
87
|
+
credit: attributes[:credit] && validate_number(attributes[:credit]),
|
|
88
|
+
role: attributes[:role] && validate_options(attributes[:role], User::ROLES),
|
|
89
|
+
group: attributes[:group] && validate_number(attributes[:group])
|
|
90
|
+
}.compact
|
|
91
|
+
end
|
|
102
92
|
end
|
|
103
93
|
end
|
|
@@ -47,6 +47,10 @@ module Supersaas
|
|
|
47
47
|
@schedules ||= Schedules.new(self)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
def slots
|
|
51
|
+
@slots ||= Slots.new(self)
|
|
52
|
+
end
|
|
53
|
+
|
|
50
54
|
def users
|
|
51
55
|
@users ||= Users.new(self)
|
|
52
56
|
end
|
|
@@ -59,6 +63,16 @@ module Supersaas
|
|
|
59
63
|
@groups ||= Groups.new(self)
|
|
60
64
|
end
|
|
61
65
|
|
|
66
|
+
def hooks
|
|
67
|
+
@hooks ||= Hooks.new(self)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Checks the credentials, returns true or raises Supersaas::Exception
|
|
71
|
+
def ping
|
|
72
|
+
get('/ping')
|
|
73
|
+
true
|
|
74
|
+
end
|
|
75
|
+
|
|
62
76
|
def get(path, query = {})
|
|
63
77
|
request(:get, path, {}, query)
|
|
64
78
|
end
|
|
@@ -77,7 +91,7 @@ module Supersaas
|
|
|
77
91
|
|
|
78
92
|
private
|
|
79
93
|
|
|
80
|
-
# The rate limiter allows
|
|
94
|
+
# The rate limiter allows at most MAX_REQUESTS requests per WINDOW_SIZE seconds
|
|
81
95
|
WINDOW_SIZE = 1 # seconds
|
|
82
96
|
MAX_REQUESTS = 4
|
|
83
97
|
|
|
@@ -138,7 +152,7 @@ module Supersaas
|
|
|
138
152
|
if verbose
|
|
139
153
|
puts '### SuperSaaS Client Request:'
|
|
140
154
|
puts "#{http_method} #{path}"
|
|
141
|
-
puts params.to_json
|
|
155
|
+
puts filter_secrets(params).to_json
|
|
142
156
|
puts '------------------------------'
|
|
143
157
|
end
|
|
144
158
|
|
|
@@ -161,6 +175,8 @@ module Supersaas
|
|
|
161
175
|
|
|
162
176
|
code = res.code.to_i
|
|
163
177
|
case code
|
|
178
|
+
when 204
|
|
179
|
+
{}
|
|
164
180
|
when 200, 201
|
|
165
181
|
if http_method == :post && res['location'] =~ /www.supersaas.com/
|
|
166
182
|
res['location']
|
|
@@ -173,34 +189,24 @@ module Supersaas
|
|
|
173
189
|
end
|
|
174
190
|
|
|
175
191
|
def handle_errors(code, res)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
def print_errors(res)
|
|
198
|
-
json_body = json_body(res)
|
|
199
|
-
return unless json_body[:errors]
|
|
200
|
-
|
|
201
|
-
errors each do |error|
|
|
202
|
-
puts "Error code: #{error['code']}, #{error['title']}"
|
|
203
|
-
end
|
|
192
|
+
message = case code
|
|
193
|
+
when 422 then 'HTTP Request Error: Unprocessable Content'
|
|
194
|
+
when 400 then 'HTTP Request Error: Bad Request'
|
|
195
|
+
when 401 then 'HTTP Request Error: Unauthorised'
|
|
196
|
+
when 404 then 'HTTP Request Error: Not Found'
|
|
197
|
+
when 501 then 'Not yet implemented for service type schedule'
|
|
198
|
+
when 403 then 'Unauthorized'
|
|
199
|
+
when 405 then 'Not available for this schedule type'
|
|
200
|
+
else "HTTP Request Error: #{code}"
|
|
201
|
+
end
|
|
202
|
+
raise Supersaas::Exception.new(message, status: code, errors: parsed_errors(res))
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# The errors array of a JSON error body like {"errors":[{"status":"404","title":"Not found"}]}
|
|
206
|
+
def parsed_errors(res)
|
|
207
|
+
body = json_body(res)
|
|
208
|
+
errors = body['errors'] if body.is_a?(Hash)
|
|
209
|
+
errors.is_a?(Array) ? errors : []
|
|
204
210
|
end
|
|
205
211
|
|
|
206
212
|
def json_body(res)
|
|
@@ -218,6 +224,14 @@ module Supersaas
|
|
|
218
224
|
end
|
|
219
225
|
end
|
|
220
226
|
|
|
227
|
+
# A copy of the params with password values replaced, for verbose output only
|
|
228
|
+
def filter_secrets(value)
|
|
229
|
+
return value.map { |v| filter_secrets(v) } if value.is_a?(Array)
|
|
230
|
+
return value unless value.is_a?(Hash)
|
|
231
|
+
|
|
232
|
+
value.each_with_object({}) { |(k, v), h| h[k] = k.to_s == 'password' ? '[FILTERED]' : filter_secrets(v) }
|
|
233
|
+
end
|
|
234
|
+
|
|
221
235
|
class Configuration
|
|
222
236
|
DEFAULT_HOST = 'https://www.supersaas.com'
|
|
223
237
|
|
|
@@ -6,5 +6,13 @@ module Supersaas
|
|
|
6
6
|
@code = nil
|
|
7
7
|
|
|
8
8
|
attr_accessor :field, :code
|
|
9
|
+
# HTTP status code and the server's parsed errors, e.g. [{"status"=>"404", "title"=>"Not found"}]
|
|
10
|
+
attr_reader :status, :errors
|
|
11
|
+
|
|
12
|
+
def initialize(message = nil, status: nil, errors: [])
|
|
13
|
+
super(message)
|
|
14
|
+
@status = status
|
|
15
|
+
@errors = errors
|
|
16
|
+
end
|
|
9
17
|
end
|
|
10
18
|
end
|
|
@@ -10,12 +10,28 @@ module Supersaas
|
|
|
10
10
|
assign_attributes(attributes)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
# Hash-style access to the raw attribute value, with a String or Symbol key.
|
|
14
|
+
# Keeps code working that read nested data as a Hash, e.g. appointment.form['content'].
|
|
15
|
+
def [](key)
|
|
16
|
+
return attributes[key] if attributes.key?(key)
|
|
17
|
+
|
|
18
|
+
case key
|
|
19
|
+
when Symbol then attributes[key.to_s]
|
|
20
|
+
when String then attributes[key.to_sym]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def to_h
|
|
25
|
+
attributes.to_h
|
|
26
|
+
end
|
|
27
|
+
|
|
13
28
|
private
|
|
14
29
|
|
|
15
30
|
def assign_attributes(attributes)
|
|
16
31
|
attributes.each do |key, value|
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
# Keep custom writers such as Appointment#form=, which wrap nested data in models
|
|
33
|
+
self.class.module_eval { attr_accessor key } unless self.class.method_defined?("#{key}=")
|
|
34
|
+
public_send("#{key}=", value)
|
|
19
35
|
end
|
|
20
36
|
end
|
|
21
37
|
end
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
module Supersaas
|
|
4
4
|
class FieldList < BaseModel
|
|
5
|
-
attr_accessor :name, :type, :label, :advanced
|
|
5
|
+
attr_accessor :name, :type, :label, :advanced, :required
|
|
6
6
|
attr_reader :spec
|
|
7
7
|
|
|
8
8
|
def spec=(value)
|
|
9
|
-
@spec = value.is_a?(Array) ? value.map { |
|
|
9
|
+
@spec = value.is_a?(Array) ? value.map { |item| parse_spec_item(item) } : value
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
# Items arrive as JSON strings; anything else (or invalid JSON) is kept as is
|
|
15
|
+
def parse_spec_item(item)
|
|
16
|
+
item.is_a?(String) ? JSON.parse(item) : item
|
|
17
|
+
rescue JSON::ParserError
|
|
18
|
+
item
|
|
10
19
|
end
|
|
11
20
|
end
|
|
12
21
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Supersaas
|
|
4
4
|
class Slot < BaseModel
|
|
5
|
-
attr_accessor :count, :description, :finish, :id, :location, :name, :start, :title
|
|
5
|
+
attr_accessor :capacity, :color, :count, :description, :finish, :id, :location, :name, :price, :start, :title
|
|
6
6
|
attr_reader :bookings
|
|
7
7
|
|
|
8
8
|
def bookings=(value)
|
data/lib/supersaas.rb
CHANGED
|
@@ -17,7 +17,9 @@ require 'supersaas-api-client/api/base_api'
|
|
|
17
17
|
require 'supersaas-api-client/api/appointments'
|
|
18
18
|
require 'supersaas-api-client/api/forms'
|
|
19
19
|
require 'supersaas-api-client/api/schedules'
|
|
20
|
+
require 'supersaas-api-client/api/slots'
|
|
20
21
|
require 'supersaas-api-client/api/groups'
|
|
22
|
+
require 'supersaas-api-client/api/hooks'
|
|
21
23
|
require 'supersaas-api-client/api/promotions'
|
|
22
24
|
require 'supersaas-api-client/api/users'
|
|
23
25
|
require 'supersaas-api-client/client'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: supersaas-api-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kaarle Kulvik
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-11-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -70,36 +70,28 @@ description: Online appointment scheduling for any type of business. Flexible an
|
|
|
70
70
|
affordable booking software that can be integrated into any site. Free basic version.
|
|
71
71
|
email:
|
|
72
72
|
- kaarle@supersaas.com
|
|
73
|
-
executables:
|
|
74
|
-
- console
|
|
75
|
-
- setup
|
|
73
|
+
executables: []
|
|
76
74
|
extensions: []
|
|
77
75
|
extra_rdoc_files: []
|
|
78
76
|
files:
|
|
79
|
-
- ".github/workflows/actions.yaml"
|
|
80
|
-
- ".gitignore"
|
|
81
|
-
- ".rubocop.yml"
|
|
82
|
-
- ".rubocop_todo.yml"
|
|
83
|
-
- Gemfile
|
|
84
|
-
- Gemfile.lock
|
|
85
77
|
- LICENSE
|
|
86
78
|
- README.md
|
|
87
|
-
- Rakefile
|
|
88
|
-
- bin/console
|
|
89
|
-
- bin/setup
|
|
90
79
|
- examples/appointments.rb
|
|
91
80
|
- examples/forms.rb
|
|
92
81
|
- examples/groups.rb
|
|
93
82
|
- examples/promotions.rb
|
|
94
83
|
- examples/schedules.rb
|
|
84
|
+
- examples/slots.rb
|
|
95
85
|
- examples/users.rb
|
|
96
86
|
- lib/supersaas-api-client.rb
|
|
97
87
|
- lib/supersaas-api-client/api/appointments.rb
|
|
98
88
|
- lib/supersaas-api-client/api/base_api.rb
|
|
99
89
|
- lib/supersaas-api-client/api/forms.rb
|
|
100
90
|
- lib/supersaas-api-client/api/groups.rb
|
|
91
|
+
- lib/supersaas-api-client/api/hooks.rb
|
|
101
92
|
- lib/supersaas-api-client/api/promotions.rb
|
|
102
93
|
- lib/supersaas-api-client/api/schedules.rb
|
|
94
|
+
- lib/supersaas-api-client/api/slots.rb
|
|
103
95
|
- lib/supersaas-api-client/api/users.rb
|
|
104
96
|
- lib/supersaas-api-client/client.rb
|
|
105
97
|
- lib/supersaas-api-client/exception.rb
|
|
@@ -116,11 +108,13 @@ files:
|
|
|
116
108
|
- lib/supersaas-api-client/models/user.rb
|
|
117
109
|
- lib/supersaas-api-client/version.rb
|
|
118
110
|
- lib/supersaas.rb
|
|
119
|
-
- supersaas-api-client.gemspec
|
|
120
111
|
homepage: https://www.supersaas.com
|
|
121
112
|
licenses:
|
|
122
113
|
- MIT
|
|
123
114
|
metadata:
|
|
115
|
+
source_code_uri: https://github.com/SuperSaaS/supersaas-ruby-api-client
|
|
116
|
+
bug_tracker_uri: https://github.com/SuperSaaS/supersaas-ruby-api-client/issues
|
|
117
|
+
documentation_uri: https://www.supersaas.com/info/dev
|
|
124
118
|
rubygems_mfa_required: 'true'
|
|
125
119
|
post_install_message:
|
|
126
120
|
rdoc_options: []
|
|
@@ -130,14 +124,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
130
124
|
requirements:
|
|
131
125
|
- - ">="
|
|
132
126
|
- !ruby/object:Gem::Version
|
|
133
|
-
version: '
|
|
127
|
+
version: '2.5'
|
|
134
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
129
|
requirements:
|
|
136
130
|
- - ">="
|
|
137
131
|
- !ruby/object:Gem::Version
|
|
138
132
|
version: '0'
|
|
139
133
|
requirements: []
|
|
140
|
-
rubygems_version: 3.5.
|
|
134
|
+
rubygems_version: 3.5.22
|
|
141
135
|
signing_key:
|
|
142
136
|
specification_version: 4
|
|
143
137
|
summary: Manage appointments and users on the SuperSaaS scheduling platform
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: SuperSaaS Ruby API Client CI
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches: [ main ]
|
|
5
|
-
pull_request:
|
|
6
|
-
branches: [ main ]
|
|
7
|
-
jobs:
|
|
8
|
-
test:
|
|
9
|
-
strategy:
|
|
10
|
-
fail-fast: false
|
|
11
|
-
matrix:
|
|
12
|
-
os: [ubuntu-latest, macos-latest]
|
|
13
|
-
ruby: ['3.0', '3.1', '3.2', '3.3', 'head', 'jruby', 'jruby-head']
|
|
14
|
-
runs-on: ${{ matrix.os }}
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v2
|
|
17
|
-
- uses: ruby/setup-ruby@v1
|
|
18
|
-
with:
|
|
19
|
-
ruby-version: ${{ matrix.ruby }}
|
|
20
|
-
bundler-cache: true
|
|
21
|
-
- run: bundle exec rake
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|