gonebusy-ruby-client 0.0.9 → 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.
- checksums.yaml +4 -4
- data/README.md +29 -68
- data/lib/gonebusy/api_helper.rb +181 -149
- data/lib/gonebusy/configuration.rb +51 -16
- data/lib/gonebusy/controllers/base_controller.rb +46 -45
- data/lib/gonebusy/controllers/bookings_controller.rb +257 -293
- data/lib/gonebusy/controllers/categories_controller.rb +151 -180
- data/lib/gonebusy/controllers/pricing_models_controller.rb +202 -241
- data/lib/gonebusy/controllers/resources_controller.rb +295 -355
- data/lib/gonebusy/controllers/schedules_controller.rb +361 -428
- data/lib/gonebusy/controllers/search_controller.rb +52 -63
- data/lib/gonebusy/controllers/services_controller.rb +310 -367
- data/lib/gonebusy/controllers/users_controller.rb +199 -239
- data/lib/gonebusy/exceptions/api_exception.rb +16 -16
- data/lib/gonebusy/exceptions/entities_error_error_exception.rb +27 -0
- data/lib/gonebusy/exceptions/entities_error_exception.rb +26 -26
- data/lib/gonebusy/gonebusy_client.rb +58 -58
- data/lib/gonebusy/http/auth/custom_auth.rb +15 -15
- data/lib/gonebusy/http/faraday_client.rb +43 -41
- data/lib/gonebusy/http/http_call_back.rb +17 -17
- data/lib/gonebusy/http/http_client.rb +84 -82
- data/lib/gonebusy/http/http_context.rb +15 -15
- data/lib/gonebusy/http/http_method_enum.rb +7 -7
- data/lib/gonebusy/http/http_request.rb +44 -44
- data/lib/gonebusy/http/http_response.rb +19 -19
- data/lib/gonebusy/models/base_model.rb +31 -31
- data/lib/gonebusy/models/cancel_booking_by_id_response.rb +35 -35
- data/lib/gonebusy/models/create_booking_body.rb +134 -80
- data/lib/gonebusy/models/create_booking_response.rb +35 -35
- data/lib/gonebusy/models/create_category_body.rb +71 -71
- data/lib/gonebusy/models/create_category_response.rb +35 -35
- data/lib/gonebusy/models/create_pricing_model_body.rb +80 -80
- data/lib/gonebusy/models/create_pricing_model_response.rb +35 -35
- data/lib/gonebusy/models/create_resource_body.rb +89 -89
- data/lib/gonebusy/models/create_resource_response.rb +35 -35
- data/lib/gonebusy/models/create_schedule_body.rb +143 -144
- data/lib/gonebusy/models/create_schedule_response.rb +35 -35
- data/lib/gonebusy/models/create_schedule_time_window_body.rb +116 -117
- data/lib/gonebusy/models/create_schedule_time_window_response.rb +35 -35
- data/lib/gonebusy/models/create_service_body.rb +107 -107
- data/lib/gonebusy/models/create_service_response.rb +35 -35
- data/lib/gonebusy/models/create_user_body.rb +89 -89
- data/lib/gonebusy/models/create_user_response.rb +35 -35
- data/lib/gonebusy/models/date_recurs_by_enum.rb +12 -12
- data/lib/gonebusy/models/delete_resource_by_id_response.rb +35 -35
- data/lib/gonebusy/models/delete_schedule_by_id_response.rb +35 -35
- data/lib/gonebusy/models/delete_schedule_time_window_by_id_response.rb +35 -35
- data/lib/gonebusy/models/delete_service_by_id_response.rb +35 -35
- data/lib/gonebusy/models/entities_address_entity.rb +116 -116
- data/lib/gonebusy/models/entities_availability_response.rb +58 -58
- data/lib/gonebusy/models/entities_booking_response.rb +71 -71
- data/lib/gonebusy/models/entities_category_response.rb +98 -98
- data/lib/gonebusy/models/entities_pricing_model_response.rb +89 -89
- data/lib/gonebusy/models/entities_resource_availabilities.rb +49 -49
- data/lib/gonebusy/models/entities_resource_response.rb +107 -107
- data/lib/gonebusy/models/entities_schedule_response.rb +76 -76
- data/lib/gonebusy/models/entities_search_response.rb +54 -54
- data/lib/gonebusy/models/entities_service_response.rb +134 -130
- data/lib/gonebusy/models/entities_slots.rb +44 -45
- data/lib/gonebusy/models/entities_thing_type_response.rb +44 -44
- data/lib/gonebusy/models/entities_time_window_response.rb +134 -135
- data/lib/gonebusy/models/entities_user_response.rb +152 -152
- data/lib/gonebusy/models/frequency_enum.rb +17 -17
- data/lib/gonebusy/models/gender_enum.rb +9 -9
- data/lib/gonebusy/models/get_booking_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_bookings_response.rb +40 -40
- data/lib/gonebusy/models/get_categories_response.rb +40 -40
- data/lib/gonebusy/models/get_category_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_pricing_model_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_pricing_models_response.rb +40 -40
- data/lib/gonebusy/models/get_resource_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_resource_things_response.rb +40 -40
- data/lib/gonebusy/models/get_resources_response.rb +40 -40
- data/lib/gonebusy/models/get_schedule_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_schedules_response.rb +40 -40
- data/lib/gonebusy/models/get_service_available_slots_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_service_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_services_response.rb +40 -40
- data/lib/gonebusy/models/get_user_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_users_response.rb +40 -40
- data/lib/gonebusy/models/occurrence_enum.rb +21 -21
- data/lib/gonebusy/models/recurs_by_enum.rb +15 -15
- data/lib/gonebusy/models/search_query_response.rb +35 -35
- data/lib/gonebusy/models/update_booking_by_id_body.rb +116 -0
- data/lib/gonebusy/models/update_booking_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_pricing_model_by_id_body.rb +62 -62
- data/lib/gonebusy/models/update_pricing_model_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_resource_by_id_body.rb +71 -71
- data/lib/gonebusy/models/update_resource_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_schedule_time_window_by_id_body.rb +116 -117
- data/lib/gonebusy/models/update_schedule_time_window_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_service_by_id_body.rb +98 -98
- data/lib/gonebusy/models/update_service_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_user_by_id_body.rb +89 -89
- data/lib/gonebusy/models/update_user_by_id_response.rb +35 -35
- data/lib/gonebusy.rb +108 -104
- metadata +53 -17
@@ -1,430 +1,363 @@
|
|
1
|
-
# This file was automatically generated
|
2
|
-
|
3
|
-
module Gonebusy
|
4
|
-
class SchedulesController < BaseController
|
5
|
-
@@instance = SchedulesController.new
|
6
|
-
# Singleton instance of the controller class
|
7
|
-
def self.instance
|
8
|
-
@@instance
|
9
|
-
end
|
10
|
-
|
11
|
-
#
|
12
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
-
# @param [
|
14
|
-
# @param [
|
15
|
-
# @return DeleteScheduleTimeWindowByIdResponse response from the API call
|
16
|
-
def delete_schedule_time_window_by_id(options = Hash.new)
|
17
|
-
|
18
|
-
# the base uri for api requests
|
19
|
-
_query_builder = Configuration.base_uri.dup
|
20
|
-
|
21
|
-
# prepare query string for API call
|
22
|
-
_query_builder << '/schedules/{id}/time_windows/{time_window_id}'
|
23
|
-
|
24
|
-
# process optional query parameters
|
25
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
26
|
-
'id' => options['id'],
|
27
|
-
'time_window_id' => options['time_window_id']
|
28
|
-
}
|
29
|
-
|
30
|
-
# validate and preprocess url
|
31
|
-
_query_url = APIHelper.clean_url _query_builder
|
32
|
-
|
33
|
-
# prepare headers
|
34
|
-
_headers = {
|
35
|
-
'accept' => 'application/json',
|
36
|
-
'Authorization' => Configuration.authorization,
|
37
|
-
'Authorization' => options['authorization']
|
38
|
-
}
|
39
|
-
|
40
|
-
# create the HttpRequest object for the call
|
41
|
-
_request = @http_client.delete _query_url, headers: _headers
|
42
|
-
|
43
|
-
# apply authentication
|
44
|
-
CustomAuth.apply(_request)
|
45
|
-
|
46
|
-
# execute the request
|
47
|
-
_context = execute_request(_request)
|
48
|
-
|
49
|
-
# endpoint error handling using HTTP status codes.
|
50
|
-
if _context.response.status_code == 400
|
51
|
-
raise EntitiesErrorException.new '400 - Bad Request', _context
|
52
|
-
elsif _context.response.status_code == 401
|
53
|
-
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
54
|
-
elsif _context.response.status_code == 403
|
55
|
-
raise EntitiesErrorException.new '403 - Forbidden', _context
|
56
|
-
elsif _context.response.status_code == 404
|
57
|
-
raise EntitiesErrorException.new '404 - Not Found', _context
|
58
|
-
elsif _context.response.status_code == 500
|
59
|
-
raise APIException.new '500 - Unexpected error', _context
|
60
|
-
end
|
61
|
-
|
62
|
-
# global error handling using HTTP status codes.
|
63
|
-
validate_response(_context)
|
64
|
-
|
65
|
-
# return appropriate response type
|
66
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
67
|
-
return DeleteScheduleTimeWindowByIdResponse.from_hash(decoded)
|
68
|
-
end
|
69
|
-
|
70
|
-
# Add a TimeWindow to a Schedule.
|
71
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
72
|
-
# @param [CreateScheduleTimeWindowBody] create_schedule_time_window_body Required parameter: the content of the request
|
73
|
-
# @param [String] id Required parameter: Example:
|
74
|
-
# @return CreateScheduleTimeWindowResponse response from the API call
|
75
|
-
def create_schedule_time_window(options = Hash.new)
|
76
|
-
|
77
|
-
# the base uri for api requests
|
78
|
-
_query_builder = Configuration.base_uri.dup
|
79
|
-
|
80
|
-
# prepare query string for API call
|
81
|
-
_query_builder << '/schedules/{id}/time_windows/new'
|
82
|
-
|
83
|
-
# process optional query parameters
|
84
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
85
|
-
'id' => options['id']
|
86
|
-
}
|
87
|
-
|
88
|
-
# validate and preprocess url
|
89
|
-
_query_url = APIHelper.clean_url _query_builder
|
90
|
-
|
91
|
-
# prepare headers
|
92
|
-
_headers = {
|
93
|
-
'accept' => 'application/json',
|
94
|
-
'content-type' => 'application/json; charset=utf-8',
|
95
|
-
'Authorization' => Configuration.authorization,
|
96
|
-
'Authorization' => options['authorization']
|
97
|
-
}
|
98
|
-
|
99
|
-
# create the HttpRequest object for the call
|
100
|
-
_request = @http_client.post _query_url, headers: _headers, parameters: options['create_schedule_time_window_body'].to_json
|
101
|
-
|
102
|
-
# apply authentication
|
103
|
-
CustomAuth.apply(_request)
|
104
|
-
|
105
|
-
# execute the request
|
106
|
-
_context = execute_request(_request)
|
107
|
-
|
108
|
-
# endpoint error handling using HTTP status codes.
|
109
|
-
if _context.response.status_code == 400
|
110
|
-
raise EntitiesErrorException.new '400 - Bad Request', _context
|
111
|
-
elsif _context.response.status_code == 401
|
112
|
-
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
113
|
-
elsif _context.response.status_code == 403
|
114
|
-
raise EntitiesErrorException.new '403 - Forbidden', _context
|
115
|
-
elsif _context.response.status_code == 404
|
116
|
-
raise EntitiesErrorException.new '404 - Not Found', _context
|
117
|
-
elsif _context.response.status_code == 422
|
118
|
-
raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
|
119
|
-
elsif _context.response.status_code == 500
|
120
|
-
raise APIException.new '500 - Unexpected error', _context
|
121
|
-
end
|
122
|
-
|
123
|
-
# global error handling using HTTP status codes.
|
124
|
-
validate_response(_context)
|
125
|
-
|
126
|
-
# return appropriate response type
|
127
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
128
|
-
return CreateScheduleTimeWindowResponse.from_hash(decoded)
|
129
|
-
end
|
130
|
-
|
131
|
-
# Delete a Schedule
|
132
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
133
|
-
# @param [String] id Required parameter: Example:
|
134
|
-
# @return DeleteScheduleByIdResponse response from the API call
|
135
|
-
def delete_schedule_by_id(options = Hash.new)
|
136
|
-
|
137
|
-
# the base uri for api requests
|
138
|
-
_query_builder = Configuration.base_uri.dup
|
139
|
-
|
140
|
-
# prepare query string for API call
|
141
|
-
_query_builder << '/schedules/{id}'
|
142
|
-
|
143
|
-
# process optional query parameters
|
144
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
145
|
-
'id' => options['id']
|
146
|
-
}
|
147
|
-
|
148
|
-
# validate and preprocess url
|
149
|
-
_query_url = APIHelper.clean_url _query_builder
|
150
|
-
|
151
|
-
# prepare headers
|
152
|
-
_headers = {
|
153
|
-
'accept' => 'application/json',
|
154
|
-
'Authorization' => Configuration.authorization,
|
155
|
-
'Authorization' => options['authorization']
|
156
|
-
}
|
157
|
-
|
158
|
-
# create the HttpRequest object for the call
|
159
|
-
_request = @http_client.delete _query_url, headers: _headers
|
160
|
-
|
161
|
-
# apply authentication
|
162
|
-
CustomAuth.apply(_request)
|
163
|
-
|
164
|
-
# execute the request
|
165
|
-
_context = execute_request(_request)
|
166
|
-
|
167
|
-
# endpoint error handling using HTTP status codes.
|
168
|
-
if _context.response.status_code == 400
|
169
|
-
raise EntitiesErrorException.new '400 - Bad Request', _context
|
170
|
-
elsif _context.response.status_code == 401
|
171
|
-
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
172
|
-
elsif _context.response.status_code == 403
|
173
|
-
raise EntitiesErrorException.new '403 - Forbidden', _context
|
174
|
-
elsif _context.response.status_code == 404
|
175
|
-
raise EntitiesErrorException.new '404 - Not Found', _context
|
176
|
-
elsif _context.response.status_code == 500
|
177
|
-
raise APIException.new '500 - Unexpected error', _context
|
178
|
-
end
|
179
|
-
|
180
|
-
# global error handling using HTTP status codes.
|
181
|
-
validate_response(_context)
|
182
|
-
|
183
|
-
# return appropriate response type
|
184
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
185
|
-
return DeleteScheduleByIdResponse.from_hash(decoded)
|
186
|
-
end
|
187
|
-
|
188
|
-
# Return a Schedule by id.
|
189
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
190
|
-
# @param [String] id Required parameter: Example:
|
191
|
-
# @return GetScheduleByIdResponse response from the API call
|
192
|
-
def get_schedule_by_id(options = Hash.new)
|
193
|
-
|
194
|
-
# the base uri for api requests
|
195
|
-
_query_builder = Configuration.base_uri.dup
|
196
|
-
|
197
|
-
# prepare query string for API call
|
198
|
-
_query_builder << '/schedules/{id}'
|
199
|
-
|
200
|
-
# process optional query parameters
|
201
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
202
|
-
'id' => options['id']
|
203
|
-
}
|
204
|
-
|
205
|
-
# validate and preprocess url
|
206
|
-
_query_url = APIHelper.clean_url _query_builder
|
207
|
-
|
208
|
-
# prepare headers
|
209
|
-
_headers = {
|
210
|
-
'accept' => 'application/json',
|
211
|
-
'Authorization' => Configuration.authorization,
|
212
|
-
'Authorization' => options['authorization']
|
213
|
-
}
|
214
|
-
|
215
|
-
# create the HttpRequest object for the call
|
216
|
-
_request = @http_client.get _query_url, headers: _headers
|
217
|
-
|
218
|
-
# apply authentication
|
219
|
-
CustomAuth.apply(_request)
|
220
|
-
|
221
|
-
# execute the request
|
222
|
-
_context = execute_request(_request)
|
223
|
-
|
224
|
-
# endpoint error handling using HTTP status codes.
|
225
|
-
if _context.response.status_code == 400
|
226
|
-
raise EntitiesErrorException.new '400 - Bad Request', _context
|
227
|
-
elsif _context.response.status_code == 401
|
228
|
-
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
229
|
-
elsif _context.response.status_code == 403
|
230
|
-
raise EntitiesErrorException.new '403 - Forbidden', _context
|
231
|
-
elsif _context.response.status_code == 404
|
232
|
-
raise EntitiesErrorException.new '404 - Not Found', _context
|
233
|
-
elsif _context.response.status_code == 410
|
234
|
-
raise EntitiesErrorException.new '410 - Gone', _context
|
235
|
-
elsif _context.response.status_code == 500
|
236
|
-
raise APIException.new '500 - Unexpected error', _context
|
237
|
-
end
|
238
|
-
|
239
|
-
# global error handling using HTTP status codes.
|
240
|
-
validate_response(_context)
|
241
|
-
|
242
|
-
# return appropriate response type
|
243
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
244
|
-
return GetScheduleByIdResponse.from_hash(decoded)
|
245
|
-
end
|
246
|
-
|
247
|
-
# Create a Schedule with params.
|
248
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
249
|
-
# @param [CreateScheduleBody] create_schedule_body Required parameter: the content of the request
|
250
|
-
# @return CreateScheduleResponse response from the API call
|
251
|
-
def create_schedule(options = Hash.new)
|
252
|
-
|
253
|
-
# the base uri for api requests
|
254
|
-
_query_builder = Configuration.base_uri.dup
|
255
|
-
|
256
|
-
# prepare query string for API call
|
257
|
-
_query_builder << '/schedules/new'
|
258
|
-
|
259
|
-
# validate and preprocess url
|
260
|
-
_query_url = APIHelper.clean_url _query_builder
|
261
|
-
|
262
|
-
# prepare headers
|
263
|
-
_headers = {
|
264
|
-
'accept' => 'application/json',
|
265
|
-
'content-type' => 'application/json; charset=utf-8',
|
266
|
-
'Authorization' => Configuration.authorization,
|
267
|
-
'Authorization' => options['authorization']
|
268
|
-
}
|
269
|
-
|
270
|
-
# create the HttpRequest object for the call
|
271
|
-
_request = @http_client.post _query_url, headers: _headers, parameters: options['create_schedule_body'].to_json
|
272
|
-
|
273
|
-
# apply authentication
|
274
|
-
CustomAuth.apply(_request)
|
275
|
-
|
276
|
-
# execute the request
|
277
|
-
_context = execute_request(_request)
|
278
|
-
|
279
|
-
# endpoint error handling using HTTP status codes.
|
280
|
-
if _context.response.status_code == 400
|
281
|
-
raise EntitiesErrorException.new '400 - Bad Request', _context
|
282
|
-
elsif _context.response.status_code == 401
|
283
|
-
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
284
|
-
elsif _context.response.status_code == 403
|
285
|
-
raise EntitiesErrorException.new '403 - Forbidden', _context
|
286
|
-
elsif _context.response.status_code == 404
|
287
|
-
raise EntitiesErrorException.new '404 - Not Found', _context
|
288
|
-
elsif _context.response.status_code == 422
|
289
|
-
raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
|
290
|
-
elsif _context.response.status_code == 500
|
291
|
-
raise APIException.new '500 - Unexpected error', _context
|
292
|
-
end
|
293
|
-
|
294
|
-
# global error handling using HTTP status codes.
|
295
|
-
validate_response(_context)
|
296
|
-
|
297
|
-
# return appropriate response type
|
298
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
299
|
-
return CreateScheduleResponse.from_hash(decoded)
|
300
|
-
end
|
301
|
-
|
302
|
-
# Update a TimeWindow for a Schedule.
|
303
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
304
|
-
# @param [String] id Required parameter: Example:
|
305
|
-
# @param [String] time_window_id Required parameter: Example:
|
306
|
-
# @param [UpdateScheduleTimeWindowByIdBody] update_schedule_time_window_by_id_body Required parameter: the content of the request
|
307
|
-
# @return UpdateScheduleTimeWindowByIdResponse response from the API call
|
308
|
-
def update_schedule_time_window_by_id(options = Hash.new)
|
309
|
-
|
310
|
-
# the base uri for api requests
|
311
|
-
_query_builder = Configuration.base_uri.dup
|
312
|
-
|
313
|
-
# prepare query string for API call
|
314
|
-
_query_builder << '/schedules/{id}/time_windows/{time_window_id}'
|
315
|
-
|
316
|
-
# process optional query parameters
|
317
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
318
|
-
'id' => options['id'],
|
319
|
-
'time_window_id' => options['time_window_id']
|
320
|
-
}
|
321
|
-
|
322
|
-
# validate and preprocess url
|
323
|
-
_query_url = APIHelper.clean_url _query_builder
|
324
|
-
|
325
|
-
# prepare headers
|
326
|
-
_headers = {
|
327
|
-
'accept' => 'application/json',
|
328
|
-
'content-type' => 'application/json; charset=utf-8',
|
329
|
-
'Authorization' => Configuration.authorization,
|
330
|
-
'Authorization' => options['authorization']
|
331
|
-
}
|
332
|
-
|
333
|
-
# create the HttpRequest object for the call
|
334
|
-
_request = @http_client.put _query_url, headers: _headers, parameters: options['update_schedule_time_window_by_id_body'].to_json
|
335
|
-
|
336
|
-
# apply authentication
|
337
|
-
CustomAuth.apply(_request)
|
338
|
-
|
339
|
-
# execute the request
|
340
|
-
_context = execute_request(_request)
|
341
|
-
|
342
|
-
# endpoint error handling using HTTP status codes.
|
343
|
-
if _context.response.status_code == 400
|
344
|
-
raise EntitiesErrorException.new '400 - Bad Request', _context
|
345
|
-
elsif _context.response.status_code == 401
|
346
|
-
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
347
|
-
elsif _context.response.status_code == 403
|
348
|
-
raise EntitiesErrorException.new '403 - Forbidden', _context
|
349
|
-
elsif _context.response.status_code == 404
|
350
|
-
raise EntitiesErrorException.new '404 - Not Found', _context
|
351
|
-
elsif _context.response.status_code == 422
|
352
|
-
raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
|
353
|
-
elsif _context.response.status_code == 500
|
354
|
-
raise APIException.new '500 - Unexpected error', _context
|
355
|
-
end
|
356
|
-
|
357
|
-
# global error handling using HTTP status codes.
|
358
|
-
validate_response(_context)
|
359
|
-
|
360
|
-
# return appropriate response type
|
361
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
362
|
-
return UpdateScheduleTimeWindowByIdResponse.from_hash(decoded)
|
363
|
-
end
|
364
|
-
|
365
|
-
# Return all Schedules that your account has access to. Includes Schedules for your own User as well as any Users for which you are the Account Manager.
|
366
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
367
|
-
# @param [Integer] page Optional parameter: Page offset to fetch.
|
368
|
-
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Gonebusy
|
4
|
+
class SchedulesController < BaseController
|
5
|
+
@@instance = SchedulesController.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# Return all Schedules that your account has access to. Includes Schedules for your own User as well as any Users for which you are the Account Manager.
|
12
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
+
# @param [Integer] page Optional parameter: Page offset to fetch.
|
14
|
+
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
369
15
|
# @param [Integer] resource_id Optional parameter: Retrieve Schedules only for this Resource. You, or provided :user_id, must be authorized to manage this Resource.
|
370
16
|
# @param [Integer] service_id Optional parameter: Retrieve Schedules only for this Service. You, or provided :user_id, must be authorized to manage this Service.
|
371
|
-
# @param [Integer] user_id Optional parameter: Retrieve Schedules owned only by this User Id. You must be authorized to manage this User Id.
|
372
|
-
# @return GetSchedulesResponse response from the API call
|
373
|
-
def get_schedules(
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
_query_builder
|
383
|
-
|
384
|
-
'
|
385
|
-
'
|
386
|
-
'
|
387
|
-
'
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
'
|
396
|
-
'Authorization' =>
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
_request
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
_context
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
17
|
+
# @param [Integer] user_id Optional parameter: Retrieve Schedules owned only by this User Id. You must be authorized to manage this User Id.
|
18
|
+
# @return GetSchedulesResponse response from the API call
|
19
|
+
def get_schedules(authorization,
|
20
|
+
page = 1,
|
21
|
+
per_page = 10,
|
22
|
+
resource_id = nil,
|
23
|
+
service_id = nil,
|
24
|
+
user_id = nil)
|
25
|
+
|
26
|
+
# prepare query url
|
27
|
+
_query_builder = Configuration.get_base_uri()
|
28
|
+
_query_builder << '/schedules'
|
29
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
30
|
+
'page' => page,
|
31
|
+
'per_page' => per_page,
|
32
|
+
'resource_id' => resource_id,
|
33
|
+
'service_id' => service_id,
|
34
|
+
'user_id' => user_id
|
35
|
+
}, array_serialization: Configuration.array_serialization
|
36
|
+
_query_url = APIHelper.clean_url _query_builder
|
37
|
+
|
38
|
+
# prepare headers
|
39
|
+
_headers = {
|
40
|
+
'accept' => 'application/json',
|
41
|
+
'Authorization' => Configuration.authorization,
|
42
|
+
'Authorization' => authorization
|
43
|
+
}
|
44
|
+
|
45
|
+
# prepare and execute HttpRequest
|
46
|
+
_request = @http_client.get _query_url, headers: _headers
|
47
|
+
CustomAuth.apply(_request)
|
48
|
+
_context = execute_request(_request)
|
49
|
+
|
50
|
+
# validate response against endpoint and global error codes
|
51
|
+
if _context.response.status_code == 400
|
52
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
53
|
+
elsif _context.response.status_code == 401
|
54
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
55
|
+
elsif _context.response.status_code == 403
|
56
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
57
|
+
elsif _context.response.status_code == 404
|
58
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
59
|
+
elsif !_context.response.status_code.between?(200, 208)
|
60
|
+
raise APIException.new 'Unexpected error', _context
|
61
|
+
end
|
62
|
+
validate_response(_context)
|
63
|
+
|
64
|
+
# return appropriate response type
|
65
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
66
|
+
return GetSchedulesResponse.from_hash(decoded)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create a Schedule with params.
|
70
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
71
|
+
# @param [CreateScheduleBody] create_schedule_body Optional parameter: the content of the request
|
72
|
+
# @return CreateScheduleResponse response from the API call
|
73
|
+
def create_schedule(authorization,
|
74
|
+
create_schedule_body = nil)
|
75
|
+
|
76
|
+
# prepare query url
|
77
|
+
_query_builder = Configuration.get_base_uri()
|
78
|
+
_query_builder << '/schedules/new'
|
79
|
+
_query_url = APIHelper.clean_url _query_builder
|
80
|
+
|
81
|
+
# prepare headers
|
82
|
+
_headers = {
|
83
|
+
'accept' => 'application/json',
|
84
|
+
'content-type' => 'application/json; charset=utf-8',
|
85
|
+
'Authorization' => Configuration.authorization,
|
86
|
+
'Authorization' => authorization
|
87
|
+
}
|
88
|
+
|
89
|
+
# prepare and execute HttpRequest
|
90
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: create_schedule_body.to_json
|
91
|
+
CustomAuth.apply(_request)
|
92
|
+
_context = execute_request(_request)
|
93
|
+
|
94
|
+
# validate response against endpoint and global error codes
|
95
|
+
if _context.response.status_code == 400
|
96
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
97
|
+
elsif _context.response.status_code == 401
|
98
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
99
|
+
elsif _context.response.status_code == 403
|
100
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
101
|
+
elsif _context.response.status_code == 404
|
102
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
103
|
+
elsif _context.response.status_code == 422
|
104
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
105
|
+
elsif !_context.response.status_code.between?(200, 208)
|
106
|
+
raise APIException.new 'Unexpected error', _context
|
107
|
+
end
|
108
|
+
validate_response(_context)
|
109
|
+
|
110
|
+
# return appropriate response type
|
111
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
112
|
+
return CreateScheduleResponse.from_hash(decoded)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Return a Schedule by id.
|
116
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
117
|
+
# @param [String] id Required parameter: Example:
|
118
|
+
# @return GetScheduleByIdResponse response from the API call
|
119
|
+
def get_schedule_by_id(authorization,
|
120
|
+
id)
|
121
|
+
|
122
|
+
# prepare query url
|
123
|
+
_query_builder = Configuration.get_base_uri()
|
124
|
+
_query_builder << '/schedules/{id}'
|
125
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
126
|
+
'id' => id
|
127
|
+
}
|
128
|
+
_query_url = APIHelper.clean_url _query_builder
|
129
|
+
|
130
|
+
# prepare headers
|
131
|
+
_headers = {
|
132
|
+
'accept' => 'application/json',
|
133
|
+
'Authorization' => Configuration.authorization,
|
134
|
+
'Authorization' => authorization
|
135
|
+
}
|
136
|
+
|
137
|
+
# prepare and execute HttpRequest
|
138
|
+
_request = @http_client.get _query_url, headers: _headers
|
139
|
+
CustomAuth.apply(_request)
|
140
|
+
_context = execute_request(_request)
|
141
|
+
|
142
|
+
# validate response against endpoint and global error codes
|
143
|
+
if _context.response.status_code == 400
|
144
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
145
|
+
elsif _context.response.status_code == 401
|
146
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
147
|
+
elsif _context.response.status_code == 403
|
148
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
149
|
+
elsif _context.response.status_code == 404
|
150
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
151
|
+
elsif _context.response.status_code == 410
|
152
|
+
raise EntitiesErrorErrorException.new 'Gone', _context
|
153
|
+
elsif !_context.response.status_code.between?(200, 208)
|
154
|
+
raise APIException.new 'Unexpected error', _context
|
155
|
+
end
|
156
|
+
validate_response(_context)
|
157
|
+
|
158
|
+
# return appropriate response type
|
159
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
160
|
+
return GetScheduleByIdResponse.from_hash(decoded)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Delete a Schedule
|
164
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
165
|
+
# @param [String] id Required parameter: Example:
|
166
|
+
# @return DeleteScheduleByIdResponse response from the API call
|
167
|
+
def delete_schedule_by_id(authorization,
|
168
|
+
id)
|
169
|
+
|
170
|
+
# prepare query url
|
171
|
+
_query_builder = Configuration.get_base_uri()
|
172
|
+
_query_builder << '/schedules/{id}'
|
173
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
174
|
+
'id' => id
|
175
|
+
}
|
176
|
+
_query_url = APIHelper.clean_url _query_builder
|
177
|
+
|
178
|
+
# prepare headers
|
179
|
+
_headers = {
|
180
|
+
'accept' => 'application/json',
|
181
|
+
'Authorization' => Configuration.authorization,
|
182
|
+
'Authorization' => authorization
|
183
|
+
}
|
184
|
+
|
185
|
+
# prepare and execute HttpRequest
|
186
|
+
_request = @http_client.delete _query_url, headers: _headers
|
187
|
+
CustomAuth.apply(_request)
|
188
|
+
_context = execute_request(_request)
|
189
|
+
|
190
|
+
# validate response against endpoint and global error codes
|
191
|
+
if _context.response.status_code == 400
|
192
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
193
|
+
elsif _context.response.status_code == 401
|
194
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
195
|
+
elsif _context.response.status_code == 403
|
196
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
197
|
+
elsif _context.response.status_code == 404
|
198
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
199
|
+
elsif !_context.response.status_code.between?(200, 208)
|
200
|
+
raise APIException.new 'Unexpected error', _context
|
201
|
+
end
|
202
|
+
validate_response(_context)
|
203
|
+
|
204
|
+
# return appropriate response type
|
205
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
206
|
+
return DeleteScheduleByIdResponse.from_hash(decoded)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Add a TimeWindow to a Schedule.
|
210
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
211
|
+
# @param [String] id Required parameter: Example:
|
212
|
+
# @param [CreateScheduleTimeWindowBody] create_schedule_time_window_body Optional parameter: the content of the request
|
213
|
+
# @return CreateScheduleTimeWindowResponse response from the API call
|
214
|
+
def create_schedule_time_window(authorization,
|
215
|
+
id,
|
216
|
+
create_schedule_time_window_body = nil)
|
217
|
+
|
218
|
+
# prepare query url
|
219
|
+
_query_builder = Configuration.get_base_uri()
|
220
|
+
_query_builder << '/schedules/{id}/time_windows/new'
|
221
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
222
|
+
'id' => id
|
223
|
+
}
|
224
|
+
_query_url = APIHelper.clean_url _query_builder
|
225
|
+
|
226
|
+
# prepare headers
|
227
|
+
_headers = {
|
228
|
+
'accept' => 'application/json',
|
229
|
+
'content-type' => 'application/json; charset=utf-8',
|
230
|
+
'Authorization' => Configuration.authorization,
|
231
|
+
'Authorization' => authorization
|
232
|
+
}
|
233
|
+
|
234
|
+
# prepare and execute HttpRequest
|
235
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: create_schedule_time_window_body.to_json
|
236
|
+
CustomAuth.apply(_request)
|
237
|
+
_context = execute_request(_request)
|
238
|
+
|
239
|
+
# validate response against endpoint and global error codes
|
240
|
+
if _context.response.status_code == 400
|
241
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
242
|
+
elsif _context.response.status_code == 401
|
243
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
244
|
+
elsif _context.response.status_code == 403
|
245
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
246
|
+
elsif _context.response.status_code == 404
|
247
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
248
|
+
elsif _context.response.status_code == 422
|
249
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
250
|
+
elsif !_context.response.status_code.between?(200, 208)
|
251
|
+
raise APIException.new 'Unexpected error', _context
|
252
|
+
end
|
253
|
+
validate_response(_context)
|
254
|
+
|
255
|
+
# return appropriate response type
|
256
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
257
|
+
return CreateScheduleTimeWindowResponse.from_hash(decoded)
|
258
|
+
end
|
259
|
+
|
260
|
+
# Update a TimeWindow for a Schedule.
|
261
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
262
|
+
# @param [String] id Required parameter: Example:
|
263
|
+
# @param [String] time_window_id Required parameter: Example:
|
264
|
+
# @param [UpdateScheduleTimeWindowByIdBody] update_schedule_time_window_by_id_body Optional parameter: the content of the request
|
265
|
+
# @return UpdateScheduleTimeWindowByIdResponse response from the API call
|
266
|
+
def update_schedule_time_window_by_id(authorization,
|
267
|
+
id,
|
268
|
+
time_window_id,
|
269
|
+
update_schedule_time_window_by_id_body = nil)
|
270
|
+
|
271
|
+
# prepare query url
|
272
|
+
_query_builder = Configuration.get_base_uri()
|
273
|
+
_query_builder << '/schedules/{id}/time_windows/{time_window_id}'
|
274
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
275
|
+
'id' => id,
|
276
|
+
'time_window_id' => time_window_id
|
277
|
+
}
|
278
|
+
_query_url = APIHelper.clean_url _query_builder
|
279
|
+
|
280
|
+
# prepare headers
|
281
|
+
_headers = {
|
282
|
+
'accept' => 'application/json',
|
283
|
+
'content-type' => 'application/json; charset=utf-8',
|
284
|
+
'Authorization' => Configuration.authorization,
|
285
|
+
'Authorization' => authorization
|
286
|
+
}
|
287
|
+
|
288
|
+
# prepare and execute HttpRequest
|
289
|
+
_request = @http_client.put _query_url, headers: _headers, parameters: update_schedule_time_window_by_id_body.to_json
|
290
|
+
CustomAuth.apply(_request)
|
291
|
+
_context = execute_request(_request)
|
292
|
+
|
293
|
+
# validate response against endpoint and global error codes
|
294
|
+
if _context.response.status_code == 400
|
295
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
296
|
+
elsif _context.response.status_code == 401
|
297
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
298
|
+
elsif _context.response.status_code == 403
|
299
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
300
|
+
elsif _context.response.status_code == 404
|
301
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
302
|
+
elsif _context.response.status_code == 422
|
303
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
304
|
+
elsif !_context.response.status_code.between?(200, 208)
|
305
|
+
raise APIException.new 'Unexpected error', _context
|
306
|
+
end
|
307
|
+
validate_response(_context)
|
308
|
+
|
309
|
+
# return appropriate response type
|
310
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
311
|
+
return UpdateScheduleTimeWindowByIdResponse.from_hash(decoded)
|
312
|
+
end
|
313
|
+
|
314
|
+
# Delete a TimeWindow from a Schedule
|
315
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
316
|
+
# @param [String] id Required parameter: Example:
|
317
|
+
# @param [String] time_window_id Required parameter: Example:
|
318
|
+
# @return DeleteScheduleTimeWindowByIdResponse response from the API call
|
319
|
+
def delete_schedule_time_window_by_id(authorization,
|
320
|
+
id,
|
321
|
+
time_window_id)
|
322
|
+
|
323
|
+
# prepare query url
|
324
|
+
_query_builder = Configuration.get_base_uri()
|
325
|
+
_query_builder << '/schedules/{id}/time_windows/{time_window_id}'
|
326
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
327
|
+
'id' => id,
|
328
|
+
'time_window_id' => time_window_id
|
329
|
+
}
|
330
|
+
_query_url = APIHelper.clean_url _query_builder
|
331
|
+
|
332
|
+
# prepare headers
|
333
|
+
_headers = {
|
334
|
+
'accept' => 'application/json',
|
335
|
+
'Authorization' => Configuration.authorization,
|
336
|
+
'Authorization' => authorization
|
337
|
+
}
|
338
|
+
|
339
|
+
# prepare and execute HttpRequest
|
340
|
+
_request = @http_client.delete _query_url, headers: _headers
|
341
|
+
CustomAuth.apply(_request)
|
342
|
+
_context = execute_request(_request)
|
343
|
+
|
344
|
+
# validate response against endpoint and global error codes
|
345
|
+
if _context.response.status_code == 400
|
346
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
347
|
+
elsif _context.response.status_code == 401
|
348
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
349
|
+
elsif _context.response.status_code == 403
|
350
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
351
|
+
elsif _context.response.status_code == 404
|
352
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
353
|
+
elsif !_context.response.status_code.between?(200, 208)
|
354
|
+
raise APIException.new 'Unexpected error', _context
|
355
|
+
end
|
356
|
+
validate_response(_context)
|
357
|
+
|
358
|
+
# return appropriate response type
|
359
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
360
|
+
return DeleteScheduleTimeWindowByIdResponse.from_hash(decoded)
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|