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,64 +1,53 @@
|
|
1
|
-
# This file was automatically generated
|
2
|
-
|
3
|
-
module Gonebusy
|
4
|
-
class SearchController < BaseController
|
5
|
-
@@instance = SearchController.new
|
6
|
-
# Singleton instance of the controller class
|
7
|
-
def self.instance
|
8
|
-
@@instance
|
9
|
-
end
|
10
|
-
|
11
|
-
# Search for Providers and Provided Services.
|
12
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
-
# @param [String] query Required parameter: Example:
|
14
|
-
# @return SearchQueryResponse response from the API call
|
15
|
-
def search_query(options = Hash.new)
|
16
|
-
|
17
|
-
# the base uri for api requests
|
18
|
-
_query_builder = Configuration.base_uri.dup
|
19
|
-
|
20
|
-
# prepare query string for API call
|
21
|
-
_query_builder << '/search/{query}'
|
22
|
-
|
23
|
-
# process optional query parameters
|
24
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
25
|
-
'query' => options['query']
|
26
|
-
}
|
27
|
-
|
28
|
-
# validate and preprocess url
|
29
|
-
_query_url = APIHelper.clean_url _query_builder
|
30
|
-
|
31
|
-
# prepare headers
|
32
|
-
_headers = {
|
33
|
-
'accept' => 'application/json',
|
34
|
-
'Authorization' => Configuration.authorization,
|
35
|
-
'Authorization' => options['authorization']
|
36
|
-
}
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
37
2
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
3
|
+
module Gonebusy
|
4
|
+
class SearchController < BaseController
|
5
|
+
@@instance = SearchController.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# Search for Providers and Provided Services.
|
12
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
+
# @param [String] query Required parameter: Example:
|
14
|
+
# @return SearchQueryResponse response from the API call
|
15
|
+
def search_query(authorization,
|
16
|
+
query)
|
17
|
+
|
18
|
+
# prepare query url
|
19
|
+
_query_builder = Configuration.get_base_uri()
|
20
|
+
_query_builder << '/search/{query}'
|
21
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
22
|
+
'query' => query
|
23
|
+
}
|
24
|
+
_query_url = APIHelper.clean_url _query_builder
|
25
|
+
|
26
|
+
# prepare headers
|
27
|
+
_headers = {
|
28
|
+
'accept' => 'application/json',
|
29
|
+
'Authorization' => Configuration.authorization,
|
30
|
+
'Authorization' => authorization
|
31
|
+
}
|
32
|
+
|
33
|
+
# prepare and execute HttpRequest
|
34
|
+
_request = @http_client.get _query_url, headers: _headers
|
35
|
+
CustomAuth.apply(_request)
|
36
|
+
_context = execute_request(_request)
|
37
|
+
|
38
|
+
# validate response against endpoint and global error codes
|
39
|
+
if _context.response.status_code == 400
|
40
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
41
|
+
elsif _context.response.status_code == 401
|
42
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
43
|
+
elsif !_context.response.status_code.between?(200, 208)
|
44
|
+
raise APIException.new 'Unexpected error', _context
|
45
|
+
end
|
46
|
+
validate_response(_context)
|
47
|
+
|
48
|
+
# return appropriate response type
|
49
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
50
|
+
return SearchQueryResponse.from_hash(decoded)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,367 +1,310 @@
|
|
1
|
-
# This file was automatically generated
|
2
|
-
|
3
|
-
module Gonebusy
|
4
|
-
class ServicesController < BaseController
|
5
|
-
@@instance = ServicesController.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
|
-
# @
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
_query_builder
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
'
|
35
|
-
'Authorization' =>
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
#
|
45
|
-
_context
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
#
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
# validate and
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
'
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
#
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
# prepare query string for API call
|
313
|
-
_query_builder << '/services/{id}/available_slots'
|
314
|
-
|
315
|
-
# process optional query parameters
|
316
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
317
|
-
'id' => options['id']
|
318
|
-
}
|
319
|
-
|
320
|
-
# process optional query parameters
|
321
|
-
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
322
|
-
'date' => options['date'],
|
323
|
-
'end_date' => options['end_date'],
|
324
|
-
'start_date' => options['start_date']
|
325
|
-
}
|
326
|
-
|
327
|
-
# validate and preprocess url
|
328
|
-
_query_url = APIHelper.clean_url _query_builder
|
329
|
-
|
330
|
-
# prepare headers
|
331
|
-
_headers = {
|
332
|
-
'accept' => 'application/json',
|
333
|
-
'Authorization' => Configuration.authorization,
|
334
|
-
'Authorization' => options['authorization']
|
335
|
-
}
|
336
|
-
|
337
|
-
# create the HttpRequest object for the call
|
338
|
-
_request = @http_client.get _query_url, headers: _headers
|
339
|
-
|
340
|
-
# apply authentication
|
341
|
-
CustomAuth.apply(_request)
|
342
|
-
|
343
|
-
# execute the request
|
344
|
-
_context = execute_request(_request)
|
345
|
-
|
346
|
-
# endpoint error handling using HTTP status codes.
|
347
|
-
if _context.response.status_code == 400
|
348
|
-
raise EntitiesErrorException.new '400 - Bad Request', _context
|
349
|
-
elsif _context.response.status_code == 401
|
350
|
-
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
351
|
-
elsif _context.response.status_code == 403
|
352
|
-
raise EntitiesErrorException.new '403 - Forbidden', _context
|
353
|
-
elsif _context.response.status_code == 404
|
354
|
-
raise EntitiesErrorException.new '404 - Not Found', _context
|
355
|
-
elsif _context.response.status_code == 500
|
356
|
-
raise APIException.new '500 - Unexpected error', _context
|
357
|
-
end
|
358
|
-
|
359
|
-
# global error handling using HTTP status codes.
|
360
|
-
validate_response(_context)
|
361
|
-
|
362
|
-
# return appropriate response type
|
363
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
364
|
-
return GetServiceAvailableSlotsByIdResponse.from_hash(decoded)
|
365
|
-
end
|
366
|
-
end
|
367
|
-
end
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Gonebusy
|
4
|
+
class ServicesController < BaseController
|
5
|
+
@@instance = ServicesController.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# Return list of Services.
|
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.
|
15
|
+
# @param [Integer] user_id Optional parameter: Retrieve Services provided by the User specified by Id. You must be authorized to manage this User Id.
|
16
|
+
# @return GetServicesResponse response from the API call
|
17
|
+
def get_services(authorization,
|
18
|
+
page = 1,
|
19
|
+
per_page = 10,
|
20
|
+
user_id = nil)
|
21
|
+
|
22
|
+
# prepare query url
|
23
|
+
_query_builder = Configuration.get_base_uri()
|
24
|
+
_query_builder << '/services'
|
25
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
26
|
+
'page' => page,
|
27
|
+
'per_page' => per_page,
|
28
|
+
'user_id' => user_id
|
29
|
+
}, array_serialization: Configuration.array_serialization
|
30
|
+
_query_url = APIHelper.clean_url _query_builder
|
31
|
+
|
32
|
+
# prepare headers
|
33
|
+
_headers = {
|
34
|
+
'accept' => 'application/json',
|
35
|
+
'Authorization' => Configuration.authorization,
|
36
|
+
'Authorization' => authorization
|
37
|
+
}
|
38
|
+
|
39
|
+
# prepare and execute HttpRequest
|
40
|
+
_request = @http_client.get _query_url, headers: _headers
|
41
|
+
CustomAuth.apply(_request)
|
42
|
+
_context = execute_request(_request)
|
43
|
+
|
44
|
+
# validate response against endpoint and global error codes
|
45
|
+
if _context.response.status_code == 401
|
46
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
47
|
+
elsif _context.response.status_code == 403
|
48
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
49
|
+
elsif _context.response.status_code == 404
|
50
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
51
|
+
elsif !_context.response.status_code.between?(200, 208)
|
52
|
+
raise APIException.new 'Unexpected error', _context
|
53
|
+
end
|
54
|
+
validate_response(_context)
|
55
|
+
|
56
|
+
# return appropriate response type
|
57
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
58
|
+
return GetServicesResponse.from_hash(decoded)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Create a Service with params.
|
62
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
63
|
+
# @param [CreateServiceBody] create_service_body Optional parameter: the content of the request
|
64
|
+
# @return CreateServiceResponse response from the API call
|
65
|
+
def create_service(authorization,
|
66
|
+
create_service_body = nil)
|
67
|
+
|
68
|
+
# prepare query url
|
69
|
+
_query_builder = Configuration.get_base_uri()
|
70
|
+
_query_builder << '/services/new'
|
71
|
+
_query_url = APIHelper.clean_url _query_builder
|
72
|
+
|
73
|
+
# prepare headers
|
74
|
+
_headers = {
|
75
|
+
'accept' => 'application/json',
|
76
|
+
'content-type' => 'application/json; charset=utf-8',
|
77
|
+
'Authorization' => Configuration.authorization,
|
78
|
+
'Authorization' => authorization
|
79
|
+
}
|
80
|
+
|
81
|
+
# prepare and execute HttpRequest
|
82
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: create_service_body.to_json
|
83
|
+
CustomAuth.apply(_request)
|
84
|
+
_context = execute_request(_request)
|
85
|
+
|
86
|
+
# validate response against endpoint and global error codes
|
87
|
+
if _context.response.status_code == 400
|
88
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
89
|
+
elsif _context.response.status_code == 401
|
90
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
91
|
+
elsif _context.response.status_code == 403
|
92
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
93
|
+
elsif _context.response.status_code == 404
|
94
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
95
|
+
elsif _context.response.status_code == 422
|
96
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
97
|
+
elsif !_context.response.status_code.between?(200, 208)
|
98
|
+
raise APIException.new 'Unexpected error', _context
|
99
|
+
end
|
100
|
+
validate_response(_context)
|
101
|
+
|
102
|
+
# return appropriate response type
|
103
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
104
|
+
return CreateServiceResponse.from_hash(decoded)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Return available times for a Service.
|
108
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
109
|
+
# @param [String] id Required parameter: Example:
|
110
|
+
# @param [Date] date Optional parameter: Date to check for availability. Either this field or a date range employing start_date and end_date must be supplied. If date is provided, start_date/end_date are ignored. Several formats are supported: '2014-10-31', 'October 31, 2014'.
|
111
|
+
# @param [Date] end_date Optional parameter: End Date of a range to check for availability. If supplied, date must not be supplied and start_date must be supplied. Several formats are supported: '2014-10-31', 'October 31, 2014'.
|
112
|
+
# @param [Integer] resource_id Optional parameter: Retrieve available slots only for this Resource. You must be authorized to manage this Resource.
|
113
|
+
# @param [Date] start_date Optional parameter: Start Date of a range to check for availability. If supplied, date must not be supplied and end_date must be supplied. Several formats are supported: '2014-10-31', 'October 31, 2014'.
|
114
|
+
# @return GetServiceAvailableSlotsByIdResponse response from the API call
|
115
|
+
def get_service_available_slots_by_id(authorization,
|
116
|
+
id,
|
117
|
+
date = nil,
|
118
|
+
end_date = nil,
|
119
|
+
resource_id = nil,
|
120
|
+
start_date = nil)
|
121
|
+
|
122
|
+
# prepare query url
|
123
|
+
_query_builder = Configuration.get_base_uri()
|
124
|
+
_query_builder << '/services/{id}/available_slots'
|
125
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
126
|
+
'id' => id
|
127
|
+
}
|
128
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
129
|
+
'date' => date,
|
130
|
+
'end_date' => end_date,
|
131
|
+
'resource_id' => resource_id,
|
132
|
+
'start_date' => start_date
|
133
|
+
}, array_serialization: Configuration.array_serialization
|
134
|
+
_query_url = APIHelper.clean_url _query_builder
|
135
|
+
|
136
|
+
# prepare headers
|
137
|
+
_headers = {
|
138
|
+
'accept' => 'application/json',
|
139
|
+
'Authorization' => Configuration.authorization,
|
140
|
+
'Authorization' => authorization
|
141
|
+
}
|
142
|
+
|
143
|
+
# prepare and execute HttpRequest
|
144
|
+
_request = @http_client.get _query_url, headers: _headers
|
145
|
+
CustomAuth.apply(_request)
|
146
|
+
_context = execute_request(_request)
|
147
|
+
|
148
|
+
# validate response against endpoint and global error codes
|
149
|
+
if _context.response.status_code == 400
|
150
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
151
|
+
elsif _context.response.status_code == 401
|
152
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
153
|
+
elsif _context.response.status_code == 403
|
154
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
155
|
+
elsif _context.response.status_code == 404
|
156
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
157
|
+
elsif !_context.response.status_code.between?(200, 208)
|
158
|
+
raise APIException.new 'Unexpected error', _context
|
159
|
+
end
|
160
|
+
validate_response(_context)
|
161
|
+
|
162
|
+
# return appropriate response type
|
163
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
164
|
+
return GetServiceAvailableSlotsByIdResponse.from_hash(decoded)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Return a Service by id.
|
168
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
169
|
+
# @param [String] id Required parameter: Example:
|
170
|
+
# @return GetServiceByIdResponse response from the API call
|
171
|
+
def get_service_by_id(authorization,
|
172
|
+
id)
|
173
|
+
|
174
|
+
# prepare query url
|
175
|
+
_query_builder = Configuration.get_base_uri()
|
176
|
+
_query_builder << '/services/{id}'
|
177
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
178
|
+
'id' => id
|
179
|
+
}
|
180
|
+
_query_url = APIHelper.clean_url _query_builder
|
181
|
+
|
182
|
+
# prepare headers
|
183
|
+
_headers = {
|
184
|
+
'accept' => 'application/json',
|
185
|
+
'Authorization' => Configuration.authorization,
|
186
|
+
'Authorization' => authorization
|
187
|
+
}
|
188
|
+
|
189
|
+
# prepare and execute HttpRequest
|
190
|
+
_request = @http_client.get _query_url, headers: _headers
|
191
|
+
CustomAuth.apply(_request)
|
192
|
+
_context = execute_request(_request)
|
193
|
+
|
194
|
+
# validate response against endpoint and global error codes
|
195
|
+
if _context.response.status_code == 400
|
196
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
197
|
+
elsif _context.response.status_code == 401
|
198
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
199
|
+
elsif _context.response.status_code == 403
|
200
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
201
|
+
elsif _context.response.status_code == 404
|
202
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
203
|
+
elsif !_context.response.status_code.between?(200, 208)
|
204
|
+
raise APIException.new 'Unexpected error', _context
|
205
|
+
end
|
206
|
+
validate_response(_context)
|
207
|
+
|
208
|
+
# return appropriate response type
|
209
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
210
|
+
return GetServiceByIdResponse.from_hash(decoded)
|
211
|
+
end
|
212
|
+
|
213
|
+
# Update a Service with params.
|
214
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
215
|
+
# @param [String] id Required parameter: Example:
|
216
|
+
# @param [UpdateServiceByIdBody] update_service_by_id_body Optional parameter: the content of the request
|
217
|
+
# @return UpdateServiceByIdResponse response from the API call
|
218
|
+
def update_service_by_id(authorization,
|
219
|
+
id,
|
220
|
+
update_service_by_id_body = nil)
|
221
|
+
|
222
|
+
# prepare query url
|
223
|
+
_query_builder = Configuration.get_base_uri()
|
224
|
+
_query_builder << '/services/{id}'
|
225
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
226
|
+
'id' => id
|
227
|
+
}
|
228
|
+
_query_url = APIHelper.clean_url _query_builder
|
229
|
+
|
230
|
+
# prepare headers
|
231
|
+
_headers = {
|
232
|
+
'accept' => 'application/json',
|
233
|
+
'content-type' => 'application/json; charset=utf-8',
|
234
|
+
'Authorization' => Configuration.authorization,
|
235
|
+
'Authorization' => authorization
|
236
|
+
}
|
237
|
+
|
238
|
+
# prepare and execute HttpRequest
|
239
|
+
_request = @http_client.put _query_url, headers: _headers, parameters: update_service_by_id_body.to_json
|
240
|
+
CustomAuth.apply(_request)
|
241
|
+
_context = execute_request(_request)
|
242
|
+
|
243
|
+
# validate response against endpoint and global error codes
|
244
|
+
if _context.response.status_code == 400
|
245
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
246
|
+
elsif _context.response.status_code == 401
|
247
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
248
|
+
elsif _context.response.status_code == 403
|
249
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
250
|
+
elsif _context.response.status_code == 404
|
251
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
252
|
+
elsif _context.response.status_code == 422
|
253
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
254
|
+
elsif !_context.response.status_code.between?(200, 208)
|
255
|
+
raise APIException.new 'Unexpected error', _context
|
256
|
+
end
|
257
|
+
validate_response(_context)
|
258
|
+
|
259
|
+
# return appropriate response type
|
260
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
261
|
+
return UpdateServiceByIdResponse.from_hash(decoded)
|
262
|
+
end
|
263
|
+
|
264
|
+
# Delete a Service by id
|
265
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
266
|
+
# @param [String] id Required parameter: Example:
|
267
|
+
# @return DeleteServiceByIdResponse response from the API call
|
268
|
+
def delete_service_by_id(authorization,
|
269
|
+
id)
|
270
|
+
|
271
|
+
# prepare query url
|
272
|
+
_query_builder = Configuration.get_base_uri()
|
273
|
+
_query_builder << '/services/{id}'
|
274
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
275
|
+
'id' => id
|
276
|
+
}
|
277
|
+
_query_url = APIHelper.clean_url _query_builder
|
278
|
+
|
279
|
+
# prepare headers
|
280
|
+
_headers = {
|
281
|
+
'accept' => 'application/json',
|
282
|
+
'Authorization' => Configuration.authorization,
|
283
|
+
'Authorization' => authorization
|
284
|
+
}
|
285
|
+
|
286
|
+
# prepare and execute HttpRequest
|
287
|
+
_request = @http_client.delete _query_url, headers: _headers
|
288
|
+
CustomAuth.apply(_request)
|
289
|
+
_context = execute_request(_request)
|
290
|
+
|
291
|
+
# validate response against endpoint and global error codes
|
292
|
+
if _context.response.status_code == 400
|
293
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
294
|
+
elsif _context.response.status_code == 401
|
295
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
296
|
+
elsif _context.response.status_code == 403
|
297
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
298
|
+
elsif _context.response.status_code == 404
|
299
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
300
|
+
elsif !_context.response.status_code.between?(200, 208)
|
301
|
+
raise APIException.new 'Unexpected error', _context
|
302
|
+
end
|
303
|
+
validate_response(_context)
|
304
|
+
|
305
|
+
# return appropriate response type
|
306
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
307
|
+
return DeleteServiceByIdResponse.from_hash(decoded)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|