gonebusy-ruby-client 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +1963 -0
- data/lib/gonebusy/api_helper.rb +149 -0
- data/lib/gonebusy/configuration.rb +16 -0
- data/lib/gonebusy/controllers/base_controller.rb +45 -0
- data/lib/gonebusy/controllers/bookings_controller.rb +298 -0
- data/lib/gonebusy/controllers/categories_controller.rb +180 -0
- data/lib/gonebusy/controllers/pricing_models_controller.rb +241 -0
- data/lib/gonebusy/controllers/resources_controller.rb +355 -0
- data/lib/gonebusy/controllers/schedules_controller.rb +426 -0
- data/lib/gonebusy/controllers/search_controller.rb +64 -0
- data/lib/gonebusy/controllers/services_controller.rb +367 -0
- data/lib/gonebusy/controllers/users_controller.rb +288 -0
- data/lib/gonebusy/exceptions/api_exception.rb +16 -0
- data/lib/gonebusy/exceptions/entities_error_exception.rb +27 -0
- data/lib/gonebusy/gonebusy_client.rb +58 -0
- data/lib/gonebusy/http/auth/custom_auth.rb +16 -0
- data/lib/gonebusy/http/faraday_client.rb +41 -0
- data/lib/gonebusy/http/http_call_back.rb +17 -0
- data/lib/gonebusy/http/http_client.rb +82 -0
- data/lib/gonebusy/http/http_context.rb +15 -0
- data/lib/gonebusy/http/http_method_enum.rb +7 -0
- data/lib/gonebusy/http/http_request.rb +44 -0
- data/lib/gonebusy/http/http_response.rb +19 -0
- data/lib/gonebusy/models/base_model.rb +32 -0
- data/lib/gonebusy/models/cancel_booking_by_id_response.rb +35 -0
- data/lib/gonebusy/models/create_booking_body.rb +80 -0
- data/lib/gonebusy/models/create_booking_response.rb +35 -0
- data/lib/gonebusy/models/create_category_body.rb +71 -0
- data/lib/gonebusy/models/create_category_response.rb +35 -0
- data/lib/gonebusy/models/create_pricing_model_body.rb +80 -0
- data/lib/gonebusy/models/create_pricing_model_response.rb +35 -0
- data/lib/gonebusy/models/create_resource_body.rb +89 -0
- data/lib/gonebusy/models/create_resource_response.rb +35 -0
- data/lib/gonebusy/models/create_schedule_body.rb +144 -0
- data/lib/gonebusy/models/create_schedule_response.rb +35 -0
- data/lib/gonebusy/models/create_schedule_time_window_body.rb +117 -0
- data/lib/gonebusy/models/create_schedule_time_window_response.rb +35 -0
- data/lib/gonebusy/models/create_service_body.rb +98 -0
- data/lib/gonebusy/models/create_service_response.rb +35 -0
- data/lib/gonebusy/models/create_user_body.rb +89 -0
- data/lib/gonebusy/models/create_user_response.rb +35 -0
- data/lib/gonebusy/models/date_recurs_by_enum.rb +13 -0
- data/lib/gonebusy/models/delete_resource_by_id_response.rb +35 -0
- data/lib/gonebusy/models/delete_schedule_by_id_response.rb +35 -0
- data/lib/gonebusy/models/delete_schedule_time_window_by_id_response.rb +35 -0
- data/lib/gonebusy/models/delete_service_by_id_response.rb +35 -0
- data/lib/gonebusy/models/entities_address_entity.rb +116 -0
- data/lib/gonebusy/models/entities_availability_response.rb +58 -0
- data/lib/gonebusy/models/entities_booking_response.rb +71 -0
- data/lib/gonebusy/models/entities_category_response.rb +98 -0
- data/lib/gonebusy/models/entities_pricing_model_response.rb +89 -0
- data/lib/gonebusy/models/entities_resource_availabilities.rb +49 -0
- data/lib/gonebusy/models/entities_resource_response.rb +98 -0
- data/lib/gonebusy/models/entities_schedule_response.rb +76 -0
- data/lib/gonebusy/models/entities_search_response.rb +54 -0
- data/lib/gonebusy/models/entities_service_response.rb +116 -0
- data/lib/gonebusy/models/entities_slots.rb +45 -0
- data/lib/gonebusy/models/entities_thing_type_response.rb +44 -0
- data/lib/gonebusy/models/entities_time_window_response.rb +135 -0
- data/lib/gonebusy/models/entities_user_response.rb +152 -0
- data/lib/gonebusy/models/frequency_enum.rb +18 -0
- data/lib/gonebusy/models/gender_enum.rb +10 -0
- data/lib/gonebusy/models/get_booking_by_id_response.rb +35 -0
- data/lib/gonebusy/models/get_bookings_response.rb +40 -0
- data/lib/gonebusy/models/get_categories_response.rb +40 -0
- data/lib/gonebusy/models/get_category_by_id_response.rb +35 -0
- data/lib/gonebusy/models/get_pricing_model_by_id_response.rb +35 -0
- data/lib/gonebusy/models/get_pricing_models_response.rb +40 -0
- data/lib/gonebusy/models/get_resource_by_id_response.rb +35 -0
- data/lib/gonebusy/models/get_resource_things_response.rb +40 -0
- data/lib/gonebusy/models/get_resources_response.rb +40 -0
- data/lib/gonebusy/models/get_schedule_by_id_response.rb +35 -0
- data/lib/gonebusy/models/get_schedules_response.rb +40 -0
- data/lib/gonebusy/models/get_service_available_slots_by_id_response.rb +35 -0
- data/lib/gonebusy/models/get_service_by_id_response.rb +35 -0
- data/lib/gonebusy/models/get_services_response.rb +40 -0
- data/lib/gonebusy/models/get_user_by_id_response.rb +35 -0
- data/lib/gonebusy/models/get_users_pros_response.rb +40 -0
- data/lib/gonebusy/models/get_users_response.rb +40 -0
- data/lib/gonebusy/models/occurrence_enum.rb +22 -0
- data/lib/gonebusy/models/recurs_by_enum.rb +16 -0
- data/lib/gonebusy/models/search_query_response.rb +35 -0
- data/lib/gonebusy/models/update_booking_by_id_response.rb +35 -0
- data/lib/gonebusy/models/update_pricing_model_by_id_body.rb +62 -0
- data/lib/gonebusy/models/update_pricing_model_by_id_response.rb +35 -0
- data/lib/gonebusy/models/update_resource_by_id_body.rb +71 -0
- data/lib/gonebusy/models/update_resource_by_id_response.rb +35 -0
- data/lib/gonebusy/models/update_schedule_time_window_by_id_body.rb +117 -0
- data/lib/gonebusy/models/update_schedule_time_window_by_id_response.rb +35 -0
- data/lib/gonebusy/models/update_service_by_id_body.rb +89 -0
- data/lib/gonebusy/models/update_service_by_id_response.rb +35 -0
- data/lib/gonebusy/models/update_user_by_id_body.rb +89 -0
- data/lib/gonebusy/models/update_user_by_id_response.rb +35 -0
- data/lib/gonebusy.rb +105 -0
- metadata +186 -0
@@ -0,0 +1,367 @@
|
|
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
|
@@ -0,0 +1,288 @@
|
|
1
|
+
# This file was automatically generated for GoneBusy Inc. by APIMATIC v2.0 ( https://apimatic.io ).
|
2
|
+
|
3
|
+
module Gonebusy
|
4
|
+
class UsersController < BaseController
|
5
|
+
@@instance = UsersController.new
|
6
|
+
# Singleton instance of the controller class
|
7
|
+
def self.instance
|
8
|
+
@@instance
|
9
|
+
end
|
10
|
+
|
11
|
+
# Update a User by id, with params.
|
12
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
+
# @param [String] id Required parameter: Example:
|
14
|
+
# @param [UpdateUserByIdBody] update_user_by_id_body Required parameter: the content of the request
|
15
|
+
# @return UpdateUserByIdResponse response from the API call
|
16
|
+
def update_user_by_id(options = Hash.new)
|
17
|
+
|
18
|
+
# the base uri for api requests
|
19
|
+
_query_builder = Configuration.base_uri.dup
|
20
|
+
|
21
|
+
# prepare query string for API call
|
22
|
+
_query_builder << '/users/{id}'
|
23
|
+
|
24
|
+
# process optional query parameters
|
25
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
26
|
+
'id' => options['id']
|
27
|
+
}
|
28
|
+
|
29
|
+
# validate and preprocess url
|
30
|
+
_query_url = APIHelper.clean_url _query_builder
|
31
|
+
|
32
|
+
# prepare headers
|
33
|
+
_headers = {
|
34
|
+
'accept' => 'application/json',
|
35
|
+
'content-type' => 'application/json; charset=utf-8',
|
36
|
+
'Authorization' => Configuration.authorization,
|
37
|
+
'Authorization' => options['authorization']
|
38
|
+
}
|
39
|
+
|
40
|
+
# create the HttpRequest object for the call
|
41
|
+
_request = @http_client.put _query_url, headers: _headers, parameters: options['update_user_by_id_body'].to_json
|
42
|
+
|
43
|
+
# apply authentication
|
44
|
+
CustomAuth.apply(_request)
|
45
|
+
|
46
|
+
# execute the request
|
47
|
+
_context = execute_request(_request)
|
48
|
+
|
49
|
+
# endpoint error handling using HTTP status codes.
|
50
|
+
if _context.response.status_code == 400
|
51
|
+
raise EntitiesErrorException.new '400 - Bad Request', _context
|
52
|
+
elsif _context.response.status_code == 401
|
53
|
+
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
54
|
+
elsif _context.response.status_code == 403
|
55
|
+
raise EntitiesErrorException.new '403 - Forbidden', _context
|
56
|
+
elsif _context.response.status_code == 404
|
57
|
+
raise EntitiesErrorException.new '404 - Not Found', _context
|
58
|
+
elsif _context.response.status_code == 422
|
59
|
+
raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
|
60
|
+
elsif _context.response.status_code == 500
|
61
|
+
raise APIException.new '500 - Unexpected error', _context
|
62
|
+
end
|
63
|
+
|
64
|
+
# global error handling using HTTP status codes.
|
65
|
+
validate_response(_context)
|
66
|
+
|
67
|
+
# return appropriate response type
|
68
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
69
|
+
return UpdateUserByIdResponse.from_hash(decoded)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Return a User by id.
|
73
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
74
|
+
# @param [String] id Required parameter: Example:
|
75
|
+
# @return GetUserByIdResponse response from the API call
|
76
|
+
def get_user_by_id(options = Hash.new)
|
77
|
+
|
78
|
+
# the base uri for api requests
|
79
|
+
_query_builder = Configuration.base_uri.dup
|
80
|
+
|
81
|
+
# prepare query string for API call
|
82
|
+
_query_builder << '/users/{id}'
|
83
|
+
|
84
|
+
# process optional query parameters
|
85
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
86
|
+
'id' => options['id']
|
87
|
+
}
|
88
|
+
|
89
|
+
# validate and preprocess url
|
90
|
+
_query_url = APIHelper.clean_url _query_builder
|
91
|
+
|
92
|
+
# prepare headers
|
93
|
+
_headers = {
|
94
|
+
'accept' => 'application/json',
|
95
|
+
'Authorization' => Configuration.authorization,
|
96
|
+
'Authorization' => options['authorization']
|
97
|
+
}
|
98
|
+
|
99
|
+
# create the HttpRequest object for the call
|
100
|
+
_request = @http_client.get _query_url, headers: _headers
|
101
|
+
|
102
|
+
# apply authentication
|
103
|
+
CustomAuth.apply(_request)
|
104
|
+
|
105
|
+
# execute the request
|
106
|
+
_context = execute_request(_request)
|
107
|
+
|
108
|
+
# endpoint error handling using HTTP status codes.
|
109
|
+
if _context.response.status_code == 400
|
110
|
+
raise EntitiesErrorException.new '400 - Bad Request', _context
|
111
|
+
elsif _context.response.status_code == 401
|
112
|
+
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
113
|
+
elsif _context.response.status_code == 403
|
114
|
+
raise EntitiesErrorException.new '403 - Forbidden', _context
|
115
|
+
elsif _context.response.status_code == 404
|
116
|
+
raise EntitiesErrorException.new '404 - Not Found', _context
|
117
|
+
elsif _context.response.status_code == 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 GetUserByIdResponse.from_hash(decoded)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Return list of active Pro Users.
|
130
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
131
|
+
# @return GetUsersProsResponse response from the API call
|
132
|
+
def get_users_pros(authorization)
|
133
|
+
|
134
|
+
# the base uri for api requests
|
135
|
+
_query_builder = Configuration.base_uri.dup
|
136
|
+
|
137
|
+
# prepare query string for API call
|
138
|
+
_query_builder << '/users/pros'
|
139
|
+
|
140
|
+
# validate and preprocess url
|
141
|
+
_query_url = APIHelper.clean_url _query_builder
|
142
|
+
|
143
|
+
# prepare headers
|
144
|
+
_headers = {
|
145
|
+
'accept' => 'application/json',
|
146
|
+
'Authorization' => Configuration.authorization,
|
147
|
+
'Authorization' => authorization
|
148
|
+
}
|
149
|
+
|
150
|
+
# create the HttpRequest object for the call
|
151
|
+
_request = @http_client.get _query_url, headers: _headers
|
152
|
+
|
153
|
+
# apply authentication
|
154
|
+
CustomAuth.apply(_request)
|
155
|
+
|
156
|
+
# execute the request
|
157
|
+
_context = execute_request(_request)
|
158
|
+
|
159
|
+
# endpoint error handling using HTTP status codes.
|
160
|
+
if _context.response.status_code == 400
|
161
|
+
raise EntitiesErrorException.new '400 - Bad Request', _context
|
162
|
+
elsif _context.response.status_code == 401
|
163
|
+
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
164
|
+
elsif _context.response.status_code == 403
|
165
|
+
raise EntitiesErrorException.new '403 - Forbidden', _context
|
166
|
+
elsif _context.response.status_code == 500
|
167
|
+
raise APIException.new '500 - Unexpected error', _context
|
168
|
+
end
|
169
|
+
|
170
|
+
# global error handling using HTTP status codes.
|
171
|
+
validate_response(_context)
|
172
|
+
|
173
|
+
# return appropriate response type
|
174
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
175
|
+
return GetUsersProsResponse.from_hash(decoded)
|
176
|
+
end
|
177
|
+
|
178
|
+
# Create a User
|
179
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
180
|
+
# @param [CreateUserBody] create_user_body Required parameter: the content of the request
|
181
|
+
# @return CreateUserResponse response from the API call
|
182
|
+
def create_user(options = Hash.new)
|
183
|
+
|
184
|
+
# the base uri for api requests
|
185
|
+
_query_builder = Configuration.base_uri.dup
|
186
|
+
|
187
|
+
# prepare query string for API call
|
188
|
+
_query_builder << '/users/new'
|
189
|
+
|
190
|
+
# validate and preprocess url
|
191
|
+
_query_url = APIHelper.clean_url _query_builder
|
192
|
+
|
193
|
+
# prepare headers
|
194
|
+
_headers = {
|
195
|
+
'accept' => 'application/json',
|
196
|
+
'content-type' => 'application/json; charset=utf-8',
|
197
|
+
'Authorization' => Configuration.authorization,
|
198
|
+
'Authorization' => options['authorization']
|
199
|
+
}
|
200
|
+
|
201
|
+
# create the HttpRequest object for the call
|
202
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: options['create_user_body'].to_json
|
203
|
+
|
204
|
+
# apply authentication
|
205
|
+
CustomAuth.apply(_request)
|
206
|
+
|
207
|
+
# execute the request
|
208
|
+
_context = execute_request(_request)
|
209
|
+
|
210
|
+
# endpoint error handling using HTTP status codes.
|
211
|
+
if _context.response.status_code == 400
|
212
|
+
raise EntitiesErrorException.new '400 - Bad Request', _context
|
213
|
+
elsif _context.response.status_code == 401
|
214
|
+
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
215
|
+
elsif _context.response.status_code == 403
|
216
|
+
raise EntitiesErrorException.new '403 - Forbidden', _context
|
217
|
+
elsif _context.response.status_code == 422
|
218
|
+
raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
|
219
|
+
elsif _context.response.status_code == 500
|
220
|
+
raise APIException.new '500 - Unexpected error', _context
|
221
|
+
end
|
222
|
+
|
223
|
+
# global error handling using HTTP status codes.
|
224
|
+
validate_response(_context)
|
225
|
+
|
226
|
+
# return appropriate response type
|
227
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
228
|
+
return CreateUserResponse.from_hash(decoded)
|
229
|
+
end
|
230
|
+
|
231
|
+
# Return all Users that your account has access to. Includes your own User as well as any Users for which you are the Account Manager.
|
232
|
+
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
233
|
+
# @param [Integer] page Optional parameter: Page offset to fetch.
|
234
|
+
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
235
|
+
# @return GetUsersResponse response from the API call
|
236
|
+
def get_users(options = Hash.new)
|
237
|
+
|
238
|
+
# the base uri for api requests
|
239
|
+
_query_builder = Configuration.base_uri.dup
|
240
|
+
|
241
|
+
# prepare query string for API call
|
242
|
+
_query_builder << '/users'
|
243
|
+
|
244
|
+
# process optional query parameters
|
245
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
246
|
+
'page' => options['page'],
|
247
|
+
'per_page' => options['per_page']
|
248
|
+
}
|
249
|
+
|
250
|
+
# validate and preprocess url
|
251
|
+
_query_url = APIHelper.clean_url _query_builder
|
252
|
+
|
253
|
+
# prepare headers
|
254
|
+
_headers = {
|
255
|
+
'accept' => 'application/json',
|
256
|
+
'Authorization' => Configuration.authorization,
|
257
|
+
'Authorization' => options['authorization']
|
258
|
+
}
|
259
|
+
|
260
|
+
# create the HttpRequest object for the call
|
261
|
+
_request = @http_client.get _query_url, headers: _headers
|
262
|
+
|
263
|
+
# apply authentication
|
264
|
+
CustomAuth.apply(_request)
|
265
|
+
|
266
|
+
# execute the request
|
267
|
+
_context = execute_request(_request)
|
268
|
+
|
269
|
+
# endpoint error handling using HTTP status codes.
|
270
|
+
if _context.response.status_code == 400
|
271
|
+
raise EntitiesErrorException.new '400 - Bad Request', _context
|
272
|
+
elsif _context.response.status_code == 401
|
273
|
+
raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
|
274
|
+
elsif _context.response.status_code == 403
|
275
|
+
raise EntitiesErrorException.new '403 - Forbidden', _context
|
276
|
+
elsif _context.response.status_code == 500
|
277
|
+
raise APIException.new '500 - Unexpected error', _context
|
278
|
+
end
|
279
|
+
|
280
|
+
# global error handling using HTTP status codes.
|
281
|
+
validate_response(_context)
|
282
|
+
|
283
|
+
# return appropriate response type
|
284
|
+
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
285
|
+
return GetUsersResponse.from_hash(decoded)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|