supersaas-api-client 2.0.4 → 2.0.5
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/.rubocop_todo.yml +2 -0
- data/Gemfile.lock +15 -15
- data/README.md +7 -6
- data/lib/supersaas-api-client/api/appointments.rb +13 -9
- data/lib/supersaas-api-client/api/forms.rb +3 -1
- data/lib/supersaas-api-client/api/users.rb +14 -6
- data/lib/supersaas-api-client/client.rb +5 -3
- data/lib/supersaas-api-client/models/appointment.rb +5 -4
- data/lib/supersaas-api-client/models/form.rb +1 -2
- data/lib/supersaas-api-client/models/user.rb +2 -0
- data/lib/supersaas-api-client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c1167242f50872bf5bcce7d66d0e66af3f5ce2e6e90d9c14142c5c41536b83c
|
4
|
+
data.tar.gz: 3e93e114c2778055521baa9aa0828d3dd01ad9409af0796f60f22d0a55c20ff3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f530da06419d03c7eba52a8a8fe8971e70d6aad06ea71e99d612c6cf1954ff66e8737bf2c26e77c447fb28f19a032f98637d0ee5a0698d6649ee3581b15ef214
|
7
|
+
data.tar.gz: 159298164a8e0b4af53a7c424495d3a8752edac213068aaa30c87fb53546d9b93069fa924f98a35c00d34d73c4d125043aa78fef854271ad5fa9585332ee3186
|
data/.rubocop_todo.yml
CHANGED
@@ -62,9 +62,11 @@ Naming/VariableNumber:
|
|
62
62
|
- 'lib/supersaas-api-client/api/appointments.rb'
|
63
63
|
- 'lib/supersaas-api-client/api/users.rb'
|
64
64
|
- 'lib/supersaas-api-client/models/appointment.rb'
|
65
|
+
- 'lib/supersaas-api-client/models/user.rb'
|
65
66
|
- 'test/appointments_test.rb'
|
66
67
|
- 'test/users_test.rb'
|
67
68
|
|
69
|
+
|
68
70
|
# Offense count: 18
|
69
71
|
# Configuration parameters: AllowedConstants.
|
70
72
|
Style/Documentation:
|
data/Gemfile.lock
CHANGED
@@ -1,37 +1,37 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
supersaas-api-client (2.0.
|
4
|
+
supersaas-api-client (2.0.5)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.2)
|
10
|
-
json (2.7.
|
10
|
+
json (2.7.2)
|
11
11
|
language_server-protocol (3.17.0.3)
|
12
|
-
minitest (5.
|
13
|
-
parallel (1.
|
14
|
-
parser (3.3.0
|
12
|
+
minitest (5.24.1)
|
13
|
+
parallel (1.25.1)
|
14
|
+
parser (3.3.4.0)
|
15
15
|
ast (~> 2.4.1)
|
16
16
|
racc
|
17
|
-
racc (1.
|
17
|
+
racc (1.8.0)
|
18
18
|
rainbow (3.1.1)
|
19
|
-
rake (13.1
|
20
|
-
regexp_parser (2.9.
|
21
|
-
rexml (3.
|
22
|
-
rubocop (1.
|
19
|
+
rake (13.2.1)
|
20
|
+
regexp_parser (2.9.2)
|
21
|
+
rexml (3.3.9)
|
22
|
+
rubocop (1.65.0)
|
23
23
|
json (~> 2.3)
|
24
24
|
language_server-protocol (>= 3.17.0)
|
25
25
|
parallel (~> 1.10)
|
26
26
|
parser (>= 3.3.0.2)
|
27
27
|
rainbow (>= 2.2.2, < 4.0)
|
28
|
-
regexp_parser (>=
|
28
|
+
regexp_parser (>= 2.4, < 3.0)
|
29
29
|
rexml (>= 3.2.5, < 4.0)
|
30
|
-
rubocop-ast (>= 1.
|
30
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
31
31
|
ruby-progressbar (~> 1.7)
|
32
32
|
unicode-display_width (>= 2.4.0, < 3.0)
|
33
|
-
rubocop-ast (1.
|
34
|
-
parser (>= 3.
|
33
|
+
rubocop-ast (1.31.3)
|
34
|
+
parser (>= 3.3.1.0)
|
35
35
|
ruby-progressbar (1.13.0)
|
36
36
|
unicode-display_width (2.5.0)
|
37
37
|
|
@@ -46,4 +46,4 @@ DEPENDENCIES
|
|
46
46
|
supersaas-api-client!
|
47
47
|
|
48
48
|
BUNDLED WITH
|
49
|
-
2.
|
49
|
+
2.5.11
|
data/README.md
CHANGED
@@ -87,12 +87,13 @@ You only need to specify the attributes you wish to update:
|
|
87
87
|
#### Delete User
|
88
88
|
|
89
89
|
Delete a single user by `user_id`, and if the user does not exist 404 error will be raised.
|
90
|
+
If webhook=true is present it will trigger any webhooks connected to the account.
|
90
91
|
|
91
92
|
Supersaas::Client.instance.users.delete(12345) #=> nil
|
92
93
|
|
93
94
|
#### Get User
|
94
95
|
|
95
|
-
Get a single user by `user_id`, and if the user does not exist 404 error will be raised
|
96
|
+
Get a single user by `user_id`, and if the user does not exist 404 error will be raised, you may use optional `form`:
|
96
97
|
|
97
98
|
Supersaas::Client.instance.users.get(12345) #=> <Supersaas::User>
|
98
99
|
|
@@ -125,7 +126,7 @@ Update an appointment by `schedule_id` and `appointment_id` with appointment att
|
|
125
126
|
|
126
127
|
#### Delete Appointment/Booking
|
127
128
|
|
128
|
-
Delete a single appointment by `schedule_id` and `appointment_id`:
|
129
|
+
Delete a single appointment by `schedule_id` and `appointment_id` with optional `webhook`:
|
129
130
|
|
130
131
|
Supersaas::Client.instance.appointments.delete(12345, 67890) #=> nil
|
131
132
|
|
@@ -151,6 +152,7 @@ Get agenda (upcoming) appointments by `schedule_id` and `user_id`, with `from_ti
|
|
151
152
|
|
152
153
|
#### Get Agenda Slots
|
153
154
|
|
155
|
+
This method is deprecated and will be removed in the future.
|
154
156
|
Get agenda (upcoming) slots by `schedule_id` and `user_id`, with `from_time` view param,
|
155
157
|
`agenda_slots(schedule_id, user_id, from_time = nil)`:
|
156
158
|
|
@@ -181,7 +183,7 @@ Get range of appointments by `schedule_id`, with `today`, `from` time, `to` time
|
|
181
183
|
|
182
184
|
#### List Template Forms
|
183
185
|
|
184
|
-
Get all forms by template `superform_id`, with `from_time`, and `user` params ([see](https://www.supersaas.com/info/dev/form_api)):
|
186
|
+
Get all forms by template `superform_id`, with `from_time`, and `user` params ([see](https://www.supersaas.com/info/dev/form_api)) and `limit`/`offset` pagination params:
|
185
187
|
|
186
188
|
Supersaas::Client.instance.forms.list(12345, '2018-01-31 00:00:00') #=> [<Supersaas::Form>, ...]
|
187
189
|
|
@@ -200,7 +202,7 @@ Get a list of Form templates (SuperForms):
|
|
200
202
|
#### List Promotions
|
201
203
|
|
202
204
|
Get a list of promotional coupon codes with pagination parameters `limit` and `offset` (see [docs](https://www.supersaas.com/info/dev/promotion_api)),
|
203
|
-
`list(
|
205
|
+
`list(limit = nil, offset = nil)`:
|
204
206
|
|
205
207
|
Supersaas::Client.instance.promotions.list #=> [<Supersaas::Promotion>, ...]
|
206
208
|
|
@@ -213,8 +215,7 @@ Retrieve information about a single coupon code use with `promotion_code`:
|
|
213
215
|
#### Duplicate promotion code
|
214
216
|
|
215
217
|
Duplicate a template promotion by giving (new) `promotion_code` and `template_code` in that order,
|
216
|
-
duplicate_promotion_code(promotion_code, template_code)
|
217
|
-
|
218
|
+
`duplicate_promotion_code(promotion_code, template_code)`:
|
218
219
|
|
219
220
|
Supersaas::Client.instance.promotions.duplicate_promotion_code(12345, 94832838) #=> nil
|
220
221
|
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module Supersaas
|
4
4
|
# REF: https://www.supersaas.com/info/dev/appointment_api
|
5
5
|
class Appointments < BaseApi
|
6
|
-
def agenda(schedule_id,
|
6
|
+
def agenda(schedule_id, user, from_time = nil, slot = false)
|
7
7
|
path = "/agenda/#{validate_id(schedule_id)}"
|
8
8
|
params = {
|
9
|
-
user: validate_present(
|
9
|
+
user: validate_present(user),
|
10
10
|
from: from_time && validate_datetime(from_time)
|
11
11
|
}
|
12
12
|
params.merge!(slot: true) if slot
|
@@ -14,6 +14,7 @@ module Supersaas
|
|
14
14
|
map_slots_or_bookings(res)
|
15
15
|
end
|
16
16
|
|
17
|
+
# LEGACY METHOD WILL BE REMOVED USE AGENDA
|
17
18
|
def agenda_slots(schedule_id, user_id, from_time = nil)
|
18
19
|
path = "/agenda/#{validate_id(schedule_id)}"
|
19
20
|
params = {
|
@@ -38,14 +39,16 @@ module Supersaas
|
|
38
39
|
map_slots_or_bookings(res)
|
39
40
|
end
|
40
41
|
|
41
|
-
def list(schedule_id, form = nil, start_time = nil, limit = nil)
|
42
|
+
def list(schedule_id, form = nil, start_time = nil, limit = nil, finish = nil, offset = nil)
|
42
43
|
path = '/bookings'
|
43
44
|
params = {
|
44
45
|
schedule_id: validate_id(schedule_id),
|
45
46
|
form: form ? true : nil,
|
46
|
-
start: start_time ? validate_datetime(start_time) : nil
|
47
|
+
start: start_time ? validate_datetime(start_time) : nil,
|
48
|
+
finish: finish ? validate_datetime(finish) : nil
|
47
49
|
}
|
48
50
|
params.merge!(limit: validate_number(limit)) if limit
|
51
|
+
params.merge!(offset: validate_number(offset)) if offset
|
49
52
|
res = client.get(path, params)
|
50
53
|
map_slots_or_bookings(res)
|
51
54
|
end
|
@@ -67,8 +70,8 @@ module Supersaas
|
|
67
70
|
booking: {
|
68
71
|
start: attributes[:start],
|
69
72
|
finish: attributes[:finish],
|
70
|
-
name: attributes[:name],
|
71
73
|
email: attributes[:email],
|
74
|
+
res_name: attributes[:name],
|
72
75
|
full_name: attributes[:full_name],
|
73
76
|
address: attributes[:address],
|
74
77
|
mobile: attributes[:mobile],
|
@@ -94,8 +97,8 @@ module Supersaas
|
|
94
97
|
booking: {
|
95
98
|
start: attributes[:start],
|
96
99
|
finish: attributes[:finish],
|
97
|
-
name: attributes[:name],
|
98
100
|
email: attributes[:email],
|
101
|
+
res_name: attributes[:name],
|
99
102
|
full_name: attributes[:full_name],
|
100
103
|
address: attributes[:address],
|
101
104
|
mobile: attributes[:mobile],
|
@@ -117,9 +120,10 @@ module Supersaas
|
|
117
120
|
client.put(path, params)
|
118
121
|
end
|
119
122
|
|
120
|
-
def delete(schedule_id, appointment_id)
|
123
|
+
def delete(schedule_id, appointment_id, webhook = nil)
|
121
124
|
path = "/bookings/#{validate_id(appointment_id)}"
|
122
125
|
params = { schedule_id: validate_id(schedule_id) }
|
126
|
+
params.merge!(webhook: webhook) if webhook
|
123
127
|
client.delete(path, nil, params)
|
124
128
|
end
|
125
129
|
|
@@ -130,8 +134,8 @@ module Supersaas
|
|
130
134
|
map_slots_or_bookings(res)
|
131
135
|
end
|
132
136
|
|
133
|
-
def range(schedule_id, today = false, from_time = nil, to = nil, slot = false, user = nil, resource_id = nil,
|
134
|
-
limit = nil, offset = nil)
|
137
|
+
def range(schedule_id, today = false, from_time = nil, to = nil, slot = false, user = nil, resource_id = nil,
|
138
|
+
service_id = nil, limit = nil, offset = nil)
|
135
139
|
path = "/range/#{validate_id(schedule_id)}"
|
136
140
|
params = {}
|
137
141
|
params = build_param(params, from_time, to, slot, user, limit, offset, resource_id, service_id)
|
@@ -3,11 +3,13 @@
|
|
3
3
|
module Supersaas
|
4
4
|
# REF: https://www.supersaas.com/info/dev/form_api
|
5
5
|
class Forms < BaseApi
|
6
|
-
def list(template_form_id, from_time = nil, user = nil)
|
6
|
+
def list(template_form_id, from_time = nil, user = nil, limit = nil, offset = nil)
|
7
7
|
path = '/forms'
|
8
8
|
params = { form_id: validate_id(template_form_id) }
|
9
9
|
params.merge!(from: validate_datetime(from_time)) if from_time
|
10
10
|
params.merge!(user: validate_user(user)) if user
|
11
|
+
params.merge!(limit: limit) if limit
|
12
|
+
params.merge!(offset: offset) if offset
|
11
13
|
res = client.get(path, params)
|
12
14
|
res.map { |attributes| Supersaas::Form.new(attributes) }
|
13
15
|
end
|
@@ -10,13 +10,17 @@ module Supersaas
|
|
10
10
|
limit: limit && validate_number(limit),
|
11
11
|
offset: offset && validate_number(offset)
|
12
12
|
}
|
13
|
+
params.compact!
|
13
14
|
res = client.get(path, params)
|
14
15
|
res.map { |attributes| Supersaas::User.new(attributes) }
|
15
16
|
end
|
16
17
|
|
17
|
-
def get(user_id)
|
18
|
+
def get(user_id, form = nil)
|
18
19
|
path = user_path(user_id)
|
19
|
-
|
20
|
+
params = {
|
21
|
+
form: form ? true : nil
|
22
|
+
}
|
23
|
+
res = client.get(path, params)
|
20
24
|
Supersaas::User.new(res)
|
21
25
|
end
|
22
26
|
|
@@ -39,9 +43,11 @@ module Supersaas
|
|
39
43
|
field_2: attributes[:field_2],
|
40
44
|
super_field: attributes[:super_field],
|
41
45
|
credit: attributes[:credit] && validate_number(attributes[:credit]),
|
42
|
-
role: attributes[:role] && validate_options(attributes[:role], User::ROLES)
|
46
|
+
role: attributes[:role] && validate_options(attributes[:role], User::ROLES),
|
47
|
+
group: attributes[:group] && validate_number(attributes[:group])
|
43
48
|
}
|
44
49
|
}
|
50
|
+
params[:user].compact!
|
45
51
|
client.post(path, params, query)
|
46
52
|
end
|
47
53
|
|
@@ -64,16 +70,18 @@ module Supersaas
|
|
64
70
|
field_2: attributes[:field_2],
|
65
71
|
super_field: attributes[:super_field],
|
66
72
|
credit: attributes[:credit] && validate_number(attributes[:credit]),
|
67
|
-
role: attributes[:role] && validate_options(attributes[:role], User::ROLES)
|
73
|
+
role: attributes[:role] && validate_options(attributes[:role], User::ROLES),
|
74
|
+
group: attributes[:group] && validate_number(attributes[:group])
|
68
75
|
}
|
69
76
|
}
|
70
77
|
params[:user].compact!
|
71
78
|
client.put(path, params, query)
|
72
79
|
end
|
73
80
|
|
74
|
-
def delete(user_id)
|
81
|
+
def delete(user_id, webhook = nil)
|
75
82
|
path = user_path(user_id)
|
76
|
-
|
83
|
+
params = { webhook: webhook }
|
84
|
+
client.delete(path, nil, params)
|
77
85
|
end
|
78
86
|
|
79
87
|
def field_list
|
@@ -77,12 +77,14 @@ module Supersaas
|
|
77
77
|
|
78
78
|
private
|
79
79
|
|
80
|
-
# The rate limiter allows a maximum of
|
80
|
+
# The rate limiter allows a maximum of 1 requests within the specified time window
|
81
81
|
WINDOW_SIZE = 1 # seconds
|
82
|
-
|
82
|
+
MAX_REQUESTS = 4
|
83
|
+
|
83
84
|
def throttle
|
84
85
|
# A queue to store timestamps of requests made within the rate limiting window
|
85
|
-
@queue ||= Array.new(
|
86
|
+
@queue ||= Array.new(MAX_REQUESTS)
|
87
|
+
|
86
88
|
# Represents the timestamp of the oldest request within the time window
|
87
89
|
oldest_request = @queue.push(Time.now).shift
|
88
90
|
# This ensures that the client does not make requests faster than the defined rate limit
|
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
module Supersaas
|
4
4
|
class Appointment < BaseModel
|
5
|
-
attr_accessor :
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
5
|
+
attr_accessor :field_1, :field_2, :field_2_r, :field_1_r, :country, :address, :mobile, :phone, :email, :price_cents,
|
6
|
+
:finish, :start, :service_name, :res_name, :id, :quantity, :status_message, :deleted,
|
7
|
+
:created_on, :slot_id, :created_by, :price, :status, :full_name, :super_field, :updated_by, :form_id,
|
8
|
+
:updated_on, :user_id, :waitlisted, :resource_id, :schedule_name, :schedule_id, :service_id
|
9
|
+
|
9
10
|
attr_reader :form, :slot
|
10
11
|
|
11
12
|
def form=(value)
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Supersaas
|
4
4
|
class Form < BaseModel
|
5
|
-
attr_accessor :content, :created_on, :deleted, :id, :reservation_process_id, :super_form_id, :
|
6
|
-
:updated_on, :user_id
|
5
|
+
attr_accessor :content, :created_on, :deleted, :id, :reservation_process_id, :super_form_id, :updated_on, :user_id
|
7
6
|
end
|
8
7
|
end
|
@@ -5,6 +5,8 @@ module Supersaas
|
|
5
5
|
ROLES = [3, 4, -1].freeze
|
6
6
|
|
7
7
|
attr_reader :form
|
8
|
+
attr_accessor :name, :email, :password, :full_name, :address, :mobile, :phone, :country, :timezone, :field_1,
|
9
|
+
:field_2, :super_field, :credit, :role, :group, :webhook, :id, :fk, :created_on, :updated_on
|
8
10
|
|
9
11
|
def form=(value)
|
10
12
|
@form = value.is_a?(Hash) ? Supersaas::Form.new(value) : value
|
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.0.5
|
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: 2025-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
rubygems_version: 3.5.
|
140
|
+
rubygems_version: 3.5.11
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Manage appointments and users on the SuperSaaS scheduling platform
|