gonebusy-ruby-client 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,355 +1,295 @@
|
|
1
|
-
# This file was automatically generated
|
2
|
-
|
3
|
-
module Gonebusy
|
4
|
-
class ResourcesController < BaseController
|
5
|
-
@@instance = ResourcesController.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
|
-
raise
|
231
|
-
elsif _context.response.status_code ==
|
232
|
-
raise
|
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
|
-
# Return list of Resources.
|
297
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
298
|
-
# @param [Integer] page Optional parameter: Page offset to fetch.
|
299
|
-
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
300
|
-
# @param [Integer] user_id Optional parameter: Retrieve Resources owned only by this User Id. You must be authorized to manage this User Id.
|
301
|
-
# @return GetResourcesResponse response from the API call
|
302
|
-
def get_resources(options = Hash.new)
|
303
|
-
|
304
|
-
# the base uri for api requests
|
305
|
-
_query_builder = Configuration.base_uri.dup
|
306
|
-
|
307
|
-
# prepare query string for API call
|
308
|
-
_query_builder << '/resources'
|
309
|
-
|
310
|
-
# process optional query parameters
|
311
|
-
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
312
|
-
'page' => options['page'],
|
313
|
-
'per_page' => options['per_page'],
|
314
|
-
'user_id' => options['user_id']
|
315
|
-
}
|
316
|
-
|
317
|
-
# validate and preprocess url
|
318
|
-
_query_url = APIHelper.clean_url _query_builder
|
319
|
-
|
320
|
-
# prepare headers
|
321
|
-
_headers = {
|
322
|
-
'accept' => 'application/json',
|
323
|
-
'Authorization' => Configuration.authorization,
|
324
|
-
'Authorization' => options['authorization']
|
325
|
-
}
|
326
|
-
|
327
|
-
# create the HttpRequest object for the call
|
328
|
-
_request = @http_client.get _query_url, headers: _headers
|
329
|
-
|
330
|
-
# apply authentication
|
331
|
-
CustomAuth.apply(_request)
|
332
|
-
|
333
|
-
# execute the request
|
334
|
-
_context = execute_request(_request)
|
335
|
-
|
336
|
-
# endpoint error handling using HTTP status codes.
|
337
|
-
if _context.response.status_code == 401
|
338
|
-
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
339
|
-
elsif _context.response.status_code == 403
|
340
|
-
raise EntitiesErrorException.new '403 - Forbidden', _context
|
341
|
-
elsif _context.response.status_code == 404
|
342
|
-
raise EntitiesErrorException.new '404 - Not Found', _context
|
343
|
-
elsif _context.response.status_code == 500
|
344
|
-
raise APIException.new '500 - Unexpected error', _context
|
345
|
-
end
|
346
|
-
|
347
|
-
# global error handling using HTTP status codes.
|
348
|
-
validate_response(_context)
|
349
|
-
|
350
|
-
# return appropriate response type
|
351
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
352
|
-
return GetResourcesResponse.from_hash(decoded)
|
353
|
-
end
|
354
|
-
end
|
355
|
-
end
|
1
|
+
# This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Gonebusy
|
4
|
+
class ResourcesController < BaseController
|
5
|
+
@@instance = ResourcesController.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# Return list of Resources.
|
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 Resources owned only by this User Id. You must be authorized to manage this User Id.
|
16
|
+
# @return GetResourcesResponse response from the API call
|
17
|
+
def get_resources(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 << '/resources'
|
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 GetResourcesResponse.from_hash(decoded)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Create a Resource with params
|
62
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
63
|
+
# @param [CreateResourceBody] create_resource_body Optional parameter: the content of the request
|
64
|
+
# @return CreateResourceResponse response from the API call
|
65
|
+
def create_resource(authorization,
|
66
|
+
create_resource_body = nil)
|
67
|
+
|
68
|
+
# prepare query url
|
69
|
+
_query_builder = Configuration.get_base_uri()
|
70
|
+
_query_builder << '/resources/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_resource_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 == 422
|
94
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
95
|
+
elsif !_context.response.status_code.between?(200, 208)
|
96
|
+
raise APIException.new 'Unexpected error', _context
|
97
|
+
end
|
98
|
+
validate_response(_context)
|
99
|
+
|
100
|
+
# return appropriate response type
|
101
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
102
|
+
return CreateResourceResponse.from_hash(decoded)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Return all Resource Things.
|
106
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
107
|
+
# @param [Integer] page Optional parameter: Page offset to fetch.
|
108
|
+
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
109
|
+
# @return GetResourceThingsResponse response from the API call
|
110
|
+
def get_resource_things(authorization,
|
111
|
+
page = 1,
|
112
|
+
per_page = 10)
|
113
|
+
|
114
|
+
# prepare query url
|
115
|
+
_query_builder = Configuration.get_base_uri()
|
116
|
+
_query_builder << '/resources/things'
|
117
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
118
|
+
'page' => page,
|
119
|
+
'per_page' => per_page
|
120
|
+
}, array_serialization: Configuration.array_serialization
|
121
|
+
_query_url = APIHelper.clean_url _query_builder
|
122
|
+
|
123
|
+
# prepare headers
|
124
|
+
_headers = {
|
125
|
+
'accept' => 'application/json',
|
126
|
+
'Authorization' => Configuration.authorization,
|
127
|
+
'Authorization' => authorization
|
128
|
+
}
|
129
|
+
|
130
|
+
# prepare and execute HttpRequest
|
131
|
+
_request = @http_client.get _query_url, headers: _headers
|
132
|
+
CustomAuth.apply(_request)
|
133
|
+
_context = execute_request(_request)
|
134
|
+
|
135
|
+
# validate response against endpoint and global error codes
|
136
|
+
if _context.response.status_code == 400
|
137
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
138
|
+
elsif _context.response.status_code == 401
|
139
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
140
|
+
elsif _context.response.status_code == 403
|
141
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
142
|
+
elsif !_context.response.status_code.between?(200, 208)
|
143
|
+
raise APIException.new 'Unexpected error', _context
|
144
|
+
end
|
145
|
+
validate_response(_context)
|
146
|
+
|
147
|
+
# return appropriate response type
|
148
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
149
|
+
return GetResourceThingsResponse.from_hash(decoded)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Return a Resource by id.
|
153
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
154
|
+
# @param [String] id Required parameter: Example:
|
155
|
+
# @return GetResourceByIdResponse response from the API call
|
156
|
+
def get_resource_by_id(authorization,
|
157
|
+
id)
|
158
|
+
|
159
|
+
# prepare query url
|
160
|
+
_query_builder = Configuration.get_base_uri()
|
161
|
+
_query_builder << '/resources/{id}'
|
162
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
163
|
+
'id' => id
|
164
|
+
}
|
165
|
+
_query_url = APIHelper.clean_url _query_builder
|
166
|
+
|
167
|
+
# prepare headers
|
168
|
+
_headers = {
|
169
|
+
'accept' => 'application/json',
|
170
|
+
'Authorization' => Configuration.authorization,
|
171
|
+
'Authorization' => authorization
|
172
|
+
}
|
173
|
+
|
174
|
+
# prepare and execute HttpRequest
|
175
|
+
_request = @http_client.get _query_url, headers: _headers
|
176
|
+
CustomAuth.apply(_request)
|
177
|
+
_context = execute_request(_request)
|
178
|
+
|
179
|
+
# validate response against endpoint and global error codes
|
180
|
+
if _context.response.status_code == 400
|
181
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
182
|
+
elsif _context.response.status_code == 401
|
183
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
184
|
+
elsif _context.response.status_code == 403
|
185
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
186
|
+
elsif _context.response.status_code == 404
|
187
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
188
|
+
elsif !_context.response.status_code.between?(200, 208)
|
189
|
+
raise APIException.new 'Unexpected error', _context
|
190
|
+
end
|
191
|
+
validate_response(_context)
|
192
|
+
|
193
|
+
# return appropriate response type
|
194
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
195
|
+
return GetResourceByIdResponse.from_hash(decoded)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Update a Resource by id, with params
|
199
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
200
|
+
# @param [String] id Required parameter: Example:
|
201
|
+
# @param [UpdateResourceByIdBody] update_resource_by_id_body Optional parameter: the content of the request
|
202
|
+
# @return UpdateResourceByIdResponse response from the API call
|
203
|
+
def update_resource_by_id(authorization,
|
204
|
+
id,
|
205
|
+
update_resource_by_id_body = nil)
|
206
|
+
|
207
|
+
# prepare query url
|
208
|
+
_query_builder = Configuration.get_base_uri()
|
209
|
+
_query_builder << '/resources/{id}'
|
210
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
211
|
+
'id' => id
|
212
|
+
}
|
213
|
+
_query_url = APIHelper.clean_url _query_builder
|
214
|
+
|
215
|
+
# prepare headers
|
216
|
+
_headers = {
|
217
|
+
'accept' => 'application/json',
|
218
|
+
'content-type' => 'application/json; charset=utf-8',
|
219
|
+
'Authorization' => Configuration.authorization,
|
220
|
+
'Authorization' => authorization
|
221
|
+
}
|
222
|
+
|
223
|
+
# prepare and execute HttpRequest
|
224
|
+
_request = @http_client.put _query_url, headers: _headers, parameters: update_resource_by_id_body.to_json
|
225
|
+
CustomAuth.apply(_request)
|
226
|
+
_context = execute_request(_request)
|
227
|
+
|
228
|
+
# validate response against endpoint and global error codes
|
229
|
+
if _context.response.status_code == 400
|
230
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
231
|
+
elsif _context.response.status_code == 401
|
232
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
233
|
+
elsif _context.response.status_code == 403
|
234
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
235
|
+
elsif _context.response.status_code == 404
|
236
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
237
|
+
elsif _context.response.status_code == 422
|
238
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
239
|
+
elsif !_context.response.status_code.between?(200, 208)
|
240
|
+
raise APIException.new 'Unexpected error', _context
|
241
|
+
end
|
242
|
+
validate_response(_context)
|
243
|
+
|
244
|
+
# return appropriate response type
|
245
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
246
|
+
return UpdateResourceByIdResponse.from_hash(decoded)
|
247
|
+
end
|
248
|
+
|
249
|
+
# Delete a Resource by id
|
250
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
251
|
+
# @param [String] id Required parameter: Example:
|
252
|
+
# @return DeleteResourceByIdResponse response from the API call
|
253
|
+
def delete_resource_by_id(authorization,
|
254
|
+
id)
|
255
|
+
|
256
|
+
# prepare query url
|
257
|
+
_query_builder = Configuration.get_base_uri()
|
258
|
+
_query_builder << '/resources/{id}'
|
259
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
260
|
+
'id' => id
|
261
|
+
}
|
262
|
+
_query_url = APIHelper.clean_url _query_builder
|
263
|
+
|
264
|
+
# prepare headers
|
265
|
+
_headers = {
|
266
|
+
'accept' => 'application/json',
|
267
|
+
'Authorization' => Configuration.authorization,
|
268
|
+
'Authorization' => authorization
|
269
|
+
}
|
270
|
+
|
271
|
+
# prepare and execute HttpRequest
|
272
|
+
_request = @http_client.delete _query_url, headers: _headers
|
273
|
+
CustomAuth.apply(_request)
|
274
|
+
_context = execute_request(_request)
|
275
|
+
|
276
|
+
# validate response against endpoint and global error codes
|
277
|
+
if _context.response.status_code == 400
|
278
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
279
|
+
elsif _context.response.status_code == 401
|
280
|
+
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
281
|
+
elsif _context.response.status_code == 403
|
282
|
+
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
283
|
+
elsif _context.response.status_code == 404
|
284
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
285
|
+
elsif !_context.response.status_code.between?(200, 208)
|
286
|
+
raise APIException.new 'Unexpected error', _context
|
287
|
+
end
|
288
|
+
validate_response(_context)
|
289
|
+
|
290
|
+
# return appropriate response type
|
291
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
292
|
+
return DeleteResourceByIdResponse.from_hash(decoded)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|