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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -68
  3. data/lib/gonebusy/api_helper.rb +181 -149
  4. data/lib/gonebusy/configuration.rb +51 -16
  5. data/lib/gonebusy/controllers/base_controller.rb +46 -45
  6. data/lib/gonebusy/controllers/bookings_controller.rb +257 -293
  7. data/lib/gonebusy/controllers/categories_controller.rb +151 -180
  8. data/lib/gonebusy/controllers/pricing_models_controller.rb +202 -241
  9. data/lib/gonebusy/controllers/resources_controller.rb +295 -355
  10. data/lib/gonebusy/controllers/schedules_controller.rb +361 -428
  11. data/lib/gonebusy/controllers/search_controller.rb +52 -63
  12. data/lib/gonebusy/controllers/services_controller.rb +310 -367
  13. data/lib/gonebusy/controllers/users_controller.rb +199 -239
  14. data/lib/gonebusy/exceptions/api_exception.rb +16 -16
  15. data/lib/gonebusy/exceptions/entities_error_error_exception.rb +27 -0
  16. data/lib/gonebusy/exceptions/entities_error_exception.rb +26 -26
  17. data/lib/gonebusy/gonebusy_client.rb +58 -58
  18. data/lib/gonebusy/http/auth/custom_auth.rb +15 -15
  19. data/lib/gonebusy/http/faraday_client.rb +43 -41
  20. data/lib/gonebusy/http/http_call_back.rb +17 -17
  21. data/lib/gonebusy/http/http_client.rb +84 -82
  22. data/lib/gonebusy/http/http_context.rb +15 -15
  23. data/lib/gonebusy/http/http_method_enum.rb +7 -7
  24. data/lib/gonebusy/http/http_request.rb +44 -44
  25. data/lib/gonebusy/http/http_response.rb +19 -19
  26. data/lib/gonebusy/models/base_model.rb +31 -31
  27. data/lib/gonebusy/models/cancel_booking_by_id_response.rb +35 -35
  28. data/lib/gonebusy/models/create_booking_body.rb +134 -80
  29. data/lib/gonebusy/models/create_booking_response.rb +35 -35
  30. data/lib/gonebusy/models/create_category_body.rb +71 -71
  31. data/lib/gonebusy/models/create_category_response.rb +35 -35
  32. data/lib/gonebusy/models/create_pricing_model_body.rb +80 -80
  33. data/lib/gonebusy/models/create_pricing_model_response.rb +35 -35
  34. data/lib/gonebusy/models/create_resource_body.rb +89 -89
  35. data/lib/gonebusy/models/create_resource_response.rb +35 -35
  36. data/lib/gonebusy/models/create_schedule_body.rb +143 -144
  37. data/lib/gonebusy/models/create_schedule_response.rb +35 -35
  38. data/lib/gonebusy/models/create_schedule_time_window_body.rb +116 -117
  39. data/lib/gonebusy/models/create_schedule_time_window_response.rb +35 -35
  40. data/lib/gonebusy/models/create_service_body.rb +107 -107
  41. data/lib/gonebusy/models/create_service_response.rb +35 -35
  42. data/lib/gonebusy/models/create_user_body.rb +89 -89
  43. data/lib/gonebusy/models/create_user_response.rb +35 -35
  44. data/lib/gonebusy/models/date_recurs_by_enum.rb +12 -12
  45. data/lib/gonebusy/models/delete_resource_by_id_response.rb +35 -35
  46. data/lib/gonebusy/models/delete_schedule_by_id_response.rb +35 -35
  47. data/lib/gonebusy/models/delete_schedule_time_window_by_id_response.rb +35 -35
  48. data/lib/gonebusy/models/delete_service_by_id_response.rb +35 -35
  49. data/lib/gonebusy/models/entities_address_entity.rb +116 -116
  50. data/lib/gonebusy/models/entities_availability_response.rb +58 -58
  51. data/lib/gonebusy/models/entities_booking_response.rb +71 -71
  52. data/lib/gonebusy/models/entities_category_response.rb +98 -98
  53. data/lib/gonebusy/models/entities_pricing_model_response.rb +89 -89
  54. data/lib/gonebusy/models/entities_resource_availabilities.rb +49 -49
  55. data/lib/gonebusy/models/entities_resource_response.rb +107 -107
  56. data/lib/gonebusy/models/entities_schedule_response.rb +76 -76
  57. data/lib/gonebusy/models/entities_search_response.rb +54 -54
  58. data/lib/gonebusy/models/entities_service_response.rb +134 -130
  59. data/lib/gonebusy/models/entities_slots.rb +44 -45
  60. data/lib/gonebusy/models/entities_thing_type_response.rb +44 -44
  61. data/lib/gonebusy/models/entities_time_window_response.rb +134 -135
  62. data/lib/gonebusy/models/entities_user_response.rb +152 -152
  63. data/lib/gonebusy/models/frequency_enum.rb +17 -17
  64. data/lib/gonebusy/models/gender_enum.rb +9 -9
  65. data/lib/gonebusy/models/get_booking_by_id_response.rb +35 -35
  66. data/lib/gonebusy/models/get_bookings_response.rb +40 -40
  67. data/lib/gonebusy/models/get_categories_response.rb +40 -40
  68. data/lib/gonebusy/models/get_category_by_id_response.rb +35 -35
  69. data/lib/gonebusy/models/get_pricing_model_by_id_response.rb +35 -35
  70. data/lib/gonebusy/models/get_pricing_models_response.rb +40 -40
  71. data/lib/gonebusy/models/get_resource_by_id_response.rb +35 -35
  72. data/lib/gonebusy/models/get_resource_things_response.rb +40 -40
  73. data/lib/gonebusy/models/get_resources_response.rb +40 -40
  74. data/lib/gonebusy/models/get_schedule_by_id_response.rb +35 -35
  75. data/lib/gonebusy/models/get_schedules_response.rb +40 -40
  76. data/lib/gonebusy/models/get_service_available_slots_by_id_response.rb +35 -35
  77. data/lib/gonebusy/models/get_service_by_id_response.rb +35 -35
  78. data/lib/gonebusy/models/get_services_response.rb +40 -40
  79. data/lib/gonebusy/models/get_user_by_id_response.rb +35 -35
  80. data/lib/gonebusy/models/get_users_response.rb +40 -40
  81. data/lib/gonebusy/models/occurrence_enum.rb +21 -21
  82. data/lib/gonebusy/models/recurs_by_enum.rb +15 -15
  83. data/lib/gonebusy/models/search_query_response.rb +35 -35
  84. data/lib/gonebusy/models/update_booking_by_id_body.rb +116 -0
  85. data/lib/gonebusy/models/update_booking_by_id_response.rb +35 -35
  86. data/lib/gonebusy/models/update_pricing_model_by_id_body.rb +62 -62
  87. data/lib/gonebusy/models/update_pricing_model_by_id_response.rb +35 -35
  88. data/lib/gonebusy/models/update_resource_by_id_body.rb +71 -71
  89. data/lib/gonebusy/models/update_resource_by_id_response.rb +35 -35
  90. data/lib/gonebusy/models/update_schedule_time_window_by_id_body.rb +116 -117
  91. data/lib/gonebusy/models/update_schedule_time_window_by_id_response.rb +35 -35
  92. data/lib/gonebusy/models/update_service_by_id_body.rb +98 -98
  93. data/lib/gonebusy/models/update_service_by_id_response.rb +35 -35
  94. data/lib/gonebusy/models/update_user_by_id_body.rb +89 -89
  95. data/lib/gonebusy/models/update_user_by_id_response.rb +35 -35
  96. data/lib/gonebusy.rb +108 -104
  97. metadata +53 -17
@@ -1,355 +1,295 @@
1
- # This file was automatically generated for GoneBusy Inc. 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
- # Delete a Resource by id
12
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
13
- # @param [String] id Required parameter: Example:
14
- # @return DeleteResourceByIdResponse response from the API call
15
- def delete_resource_by_id(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 << '/resources/{id}'
22
-
23
- # process optional query parameters
24
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
25
- 'id' => options['id']
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
- }
37
-
38
- # create the HttpRequest object for the call
39
- _request = @http_client.delete _query_url, headers: _headers
40
-
41
- # apply authentication
42
- CustomAuth.apply(_request)
43
-
44
- # execute the request
45
- _context = execute_request(_request)
46
-
47
- # endpoint error handling using HTTP status codes.
48
- if _context.response.status_code == 400
49
- raise EntitiesErrorException.new '400 - Bad Request', _context
50
- elsif _context.response.status_code == 401
51
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
52
- elsif _context.response.status_code == 403
53
- raise EntitiesErrorException.new '403 - Forbidden', _context
54
- elsif _context.response.status_code == 404
55
- raise EntitiesErrorException.new '404 - Not Found', _context
56
- elsif _context.response.status_code == 500
57
- raise APIException.new '500 - Unexpected error', _context
58
- end
59
-
60
- # global error handling using HTTP status codes.
61
- validate_response(_context)
62
-
63
- # return appropriate response type
64
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
65
- return DeleteResourceByIdResponse.from_hash(decoded)
66
- end
67
-
68
- # Update a Resource by id, with params
69
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
70
- # @param [String] id Required parameter: Example:
71
- # @param [UpdateResourceByIdBody] update_resource_by_id_body Required parameter: the content of the request
72
- # @return UpdateResourceByIdResponse response from the API call
73
- def update_resource_by_id(options = Hash.new)
74
-
75
- # the base uri for api requests
76
- _query_builder = Configuration.base_uri.dup
77
-
78
- # prepare query string for API call
79
- _query_builder << '/resources/{id}'
80
-
81
- # process optional query parameters
82
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
83
- 'id' => options['id']
84
- }
85
-
86
- # validate and preprocess url
87
- _query_url = APIHelper.clean_url _query_builder
88
-
89
- # prepare headers
90
- _headers = {
91
- 'accept' => 'application/json',
92
- 'content-type' => 'application/json; charset=utf-8',
93
- 'Authorization' => Configuration.authorization,
94
- 'Authorization' => options['authorization']
95
- }
96
-
97
- # create the HttpRequest object for the call
98
- _request = @http_client.put _query_url, headers: _headers, parameters: options['update_resource_by_id_body'].to_json
99
-
100
- # apply authentication
101
- CustomAuth.apply(_request)
102
-
103
- # execute the request
104
- _context = execute_request(_request)
105
-
106
- # endpoint error handling using HTTP status codes.
107
- if _context.response.status_code == 400
108
- raise EntitiesErrorException.new '400 - Bad Request', _context
109
- elsif _context.response.status_code == 401
110
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
111
- elsif _context.response.status_code == 403
112
- raise EntitiesErrorException.new '403 - Forbidden', _context
113
- elsif _context.response.status_code == 404
114
- raise EntitiesErrorException.new '404 - Not Found', _context
115
- elsif _context.response.status_code == 422
116
- raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
117
- elsif _context.response.status_code == 500
118
- raise APIException.new '500 - Unexpected error', _context
119
- end
120
-
121
- # global error handling using HTTP status codes.
122
- validate_response(_context)
123
-
124
- # return appropriate response type
125
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
126
- return UpdateResourceByIdResponse.from_hash(decoded)
127
- end
128
-
129
- # Return a Resource by id.
130
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
131
- # @param [String] id Required parameter: Example:
132
- # @return GetResourceByIdResponse response from the API call
133
- def get_resource_by_id(options = Hash.new)
134
-
135
- # the base uri for api requests
136
- _query_builder = Configuration.base_uri.dup
137
-
138
- # prepare query string for API call
139
- _query_builder << '/resources/{id}'
140
-
141
- # process optional query parameters
142
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
143
- 'id' => options['id']
144
- }
145
-
146
- # validate and preprocess url
147
- _query_url = APIHelper.clean_url _query_builder
148
-
149
- # prepare headers
150
- _headers = {
151
- 'accept' => 'application/json',
152
- 'Authorization' => Configuration.authorization,
153
- 'Authorization' => options['authorization']
154
- }
155
-
156
- # create the HttpRequest object for the call
157
- _request = @http_client.get _query_url, headers: _headers
158
-
159
- # apply authentication
160
- CustomAuth.apply(_request)
161
-
162
- # execute the request
163
- _context = execute_request(_request)
164
-
165
- # endpoint error handling using HTTP status codes.
166
- if _context.response.status_code == 400
167
- raise EntitiesErrorException.new '400 - Bad Request', _context
168
- elsif _context.response.status_code == 401
169
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
170
- elsif _context.response.status_code == 403
171
- raise EntitiesErrorException.new '403 - Forbidden', _context
172
- elsif _context.response.status_code == 404
173
- raise EntitiesErrorException.new '404 - Not Found', _context
174
- elsif _context.response.status_code == 500
175
- raise APIException.new '500 - Unexpected error', _context
176
- end
177
-
178
- # global error handling using HTTP status codes.
179
- validate_response(_context)
180
-
181
- # return appropriate response type
182
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
183
- return GetResourceByIdResponse.from_hash(decoded)
184
- end
185
-
186
- # Return all Resource Things.
187
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
188
- # @param [Integer] page Optional parameter: Page offset to fetch.
189
- # @param [Integer] per_page Optional parameter: Number of results to return per page.
190
- # @return GetResourceThingsResponse response from the API call
191
- def get_resource_things(options = Hash.new)
192
-
193
- # the base uri for api requests
194
- _query_builder = Configuration.base_uri.dup
195
-
196
- # prepare query string for API call
197
- _query_builder << '/resources/things'
198
-
199
- # process optional query parameters
200
- _query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
201
- 'page' => options['page'],
202
- 'per_page' => options['per_page']
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 == 500
232
- raise APIException.new '500 - Unexpected error', _context
233
- end
234
-
235
- # global error handling using HTTP status codes.
236
- validate_response(_context)
237
-
238
- # return appropriate response type
239
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
240
- return GetResourceThingsResponse.from_hash(decoded)
241
- end
242
-
243
- # Create a Resource with params
244
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
245
- # @param [CreateResourceBody] create_resource_body Required parameter: the content of the request
246
- # @return CreateResourceResponse response from the API call
247
- def create_resource(options = Hash.new)
248
-
249
- # the base uri for api requests
250
- _query_builder = Configuration.base_uri.dup
251
-
252
- # prepare query string for API call
253
- _query_builder << '/resources/new'
254
-
255
- # validate and preprocess url
256
- _query_url = APIHelper.clean_url _query_builder
257
-
258
- # prepare headers
259
- _headers = {
260
- 'accept' => 'application/json',
261
- 'content-type' => 'application/json; charset=utf-8',
262
- 'Authorization' => Configuration.authorization,
263
- 'Authorization' => options['authorization']
264
- }
265
-
266
- # create the HttpRequest object for the call
267
- _request = @http_client.post _query_url, headers: _headers, parameters: options['create_resource_body'].to_json
268
-
269
- # apply authentication
270
- CustomAuth.apply(_request)
271
-
272
- # execute the request
273
- _context = execute_request(_request)
274
-
275
- # endpoint error handling using HTTP status codes.
276
- if _context.response.status_code == 400
277
- raise EntitiesErrorException.new '400 - Bad Request', _context
278
- elsif _context.response.status_code == 401
279
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
280
- elsif _context.response.status_code == 403
281
- raise EntitiesErrorException.new '403 - Forbidden', _context
282
- elsif _context.response.status_code == 422
283
- raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
284
- elsif _context.response.status_code == 500
285
- raise APIException.new '500 - Unexpected error', _context
286
- end
287
-
288
- # global error handling using HTTP status codes.
289
- validate_response(_context)
290
-
291
- # return appropriate response type
292
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
293
- return CreateResourceResponse.from_hash(decoded)
294
- end
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