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,64 +1,53 @@
1
- # This file was automatically generated for GoneBusy Inc. by APIMATIC v2.0 ( https://apimatic.io ).
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
- # create the HttpRequest object for the call
39
- _request = @http_client.get _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 == 500
53
- raise APIException.new '500 - Unexpected error', _context
54
- end
55
-
56
- # global error handling using HTTP status codes.
57
- validate_response(_context)
58
-
59
- # return appropriate response type
60
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
61
- return SearchQueryResponse.from_hash(decoded)
62
- end
63
- end
64
- end
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 for GoneBusy Inc. 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
- # Delete a Service 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 DeleteServiceByIdResponse response from the API call
15
- def delete_service_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 << '/services/{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 DeleteServiceByIdResponse.from_hash(decoded)
66
- end
67
-
68
- # Update a Service 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 [UpdateServiceByIdBody] update_service_by_id_body Required parameter: the content of the request
72
- # @return UpdateServiceByIdResponse response from the API call
73
- def update_service_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 << '/services/{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_service_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 UpdateServiceByIdResponse.from_hash(decoded)
127
- end
128
-
129
- # Return a Service 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 GetServiceByIdResponse response from the API call
133
- def get_service_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 << '/services/{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 GetServiceByIdResponse.from_hash(decoded)
184
- end
185
-
186
- # Create a Service with params.
187
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
188
- # @param [CreateServiceBody] create_service_body Required parameter: the content of the request
189
- # @return CreateServiceResponse response from the API call
190
- def create_service(options = Hash.new)
191
-
192
- # the base uri for api requests
193
- _query_builder = Configuration.base_uri.dup
194
-
195
- # prepare query string for API call
196
- _query_builder << '/services/new'
197
-
198
- # validate and preprocess url
199
- _query_url = APIHelper.clean_url _query_builder
200
-
201
- # prepare headers
202
- _headers = {
203
- 'accept' => 'application/json',
204
- 'content-type' => 'application/json; charset=utf-8',
205
- 'Authorization' => Configuration.authorization,
206
- 'Authorization' => options['authorization']
207
- }
208
-
209
- # create the HttpRequest object for the call
210
- _request = @http_client.post _query_url, headers: _headers, parameters: options['create_service_body'].to_json
211
-
212
- # apply authentication
213
- CustomAuth.apply(_request)
214
-
215
- # execute the request
216
- _context = execute_request(_request)
217
-
218
- # endpoint error handling using HTTP status codes.
219
- if _context.response.status_code == 400
220
- raise EntitiesErrorException.new '400 - Bad Request', _context
221
- elsif _context.response.status_code == 401
222
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
223
- elsif _context.response.status_code == 403
224
- raise EntitiesErrorException.new '403 - Forbidden', _context
225
- elsif _context.response.status_code == 404
226
- raise EntitiesErrorException.new '404 - Not Found', _context
227
- elsif _context.response.status_code == 422
228
- raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
229
- elsif _context.response.status_code == 500
230
- raise APIException.new '500 - Unexpected error', _context
231
- end
232
-
233
- # global error handling using HTTP status codes.
234
- validate_response(_context)
235
-
236
- # return appropriate response type
237
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
238
- return CreateServiceResponse.from_hash(decoded)
239
- end
240
-
241
- # Return list of Services.
242
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
243
- # @param [Integer] page Optional parameter: Page offset to fetch.
244
- # @param [Integer] per_page Optional parameter: Number of results to return per page.
245
- # @param [Integer] user_id Optional parameter: Retrieve Services provided by the User specified by Id. You must be authorized to manage this User Id.
246
- # @return GetServicesResponse response from the API call
247
- def get_services(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 << '/services'
254
-
255
- # process optional query parameters
256
- _query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
257
- 'page' => options['page'],
258
- 'per_page' => options['per_page'],
259
- 'user_id' => options['user_id']
260
- }
261
-
262
- # validate and preprocess url
263
- _query_url = APIHelper.clean_url _query_builder
264
-
265
- # prepare headers
266
- _headers = {
267
- 'accept' => 'application/json',
268
- 'Authorization' => Configuration.authorization,
269
- 'Authorization' => options['authorization']
270
- }
271
-
272
- # create the HttpRequest object for the call
273
- _request = @http_client.get _query_url, headers: _headers
274
-
275
- # apply authentication
276
- CustomAuth.apply(_request)
277
-
278
- # execute the request
279
- _context = execute_request(_request)
280
-
281
- # endpoint error handling using HTTP status codes.
282
- if _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 == 500
289
- raise APIException.new '500 - Unexpected error', _context
290
- end
291
-
292
- # global error handling using HTTP status codes.
293
- validate_response(_context)
294
-
295
- # return appropriate response type
296
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
297
- return GetServicesResponse.from_hash(decoded)
298
- end
299
-
300
- # Return available times for a Service.
301
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
302
- # @param [String] id Required parameter: Example:
303
- # @param [DateTime] 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'.
304
- # @param [DateTime] 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'.
305
- # @param [DateTime] 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'.
306
- # @return GetServiceAvailableSlotsByIdResponse response from the API call
307
- def get_service_available_slots_by_id(options = Hash.new)
308
-
309
- # the base uri for api requests
310
- _query_builder = Configuration.base_uri.dup
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