gonebusy-ruby-client 0.0.2

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 +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +1963 -0
  4. data/lib/gonebusy/api_helper.rb +149 -0
  5. data/lib/gonebusy/configuration.rb +16 -0
  6. data/lib/gonebusy/controllers/base_controller.rb +45 -0
  7. data/lib/gonebusy/controllers/bookings_controller.rb +298 -0
  8. data/lib/gonebusy/controllers/categories_controller.rb +180 -0
  9. data/lib/gonebusy/controllers/pricing_models_controller.rb +241 -0
  10. data/lib/gonebusy/controllers/resources_controller.rb +355 -0
  11. data/lib/gonebusy/controllers/schedules_controller.rb +426 -0
  12. data/lib/gonebusy/controllers/search_controller.rb +64 -0
  13. data/lib/gonebusy/controllers/services_controller.rb +367 -0
  14. data/lib/gonebusy/controllers/users_controller.rb +288 -0
  15. data/lib/gonebusy/exceptions/api_exception.rb +16 -0
  16. data/lib/gonebusy/exceptions/entities_error_exception.rb +27 -0
  17. data/lib/gonebusy/gonebusy_client.rb +58 -0
  18. data/lib/gonebusy/http/auth/custom_auth.rb +16 -0
  19. data/lib/gonebusy/http/faraday_client.rb +41 -0
  20. data/lib/gonebusy/http/http_call_back.rb +17 -0
  21. data/lib/gonebusy/http/http_client.rb +82 -0
  22. data/lib/gonebusy/http/http_context.rb +15 -0
  23. data/lib/gonebusy/http/http_method_enum.rb +7 -0
  24. data/lib/gonebusy/http/http_request.rb +44 -0
  25. data/lib/gonebusy/http/http_response.rb +19 -0
  26. data/lib/gonebusy/models/base_model.rb +32 -0
  27. data/lib/gonebusy/models/cancel_booking_by_id_response.rb +35 -0
  28. data/lib/gonebusy/models/create_booking_body.rb +80 -0
  29. data/lib/gonebusy/models/create_booking_response.rb +35 -0
  30. data/lib/gonebusy/models/create_category_body.rb +71 -0
  31. data/lib/gonebusy/models/create_category_response.rb +35 -0
  32. data/lib/gonebusy/models/create_pricing_model_body.rb +80 -0
  33. data/lib/gonebusy/models/create_pricing_model_response.rb +35 -0
  34. data/lib/gonebusy/models/create_resource_body.rb +89 -0
  35. data/lib/gonebusy/models/create_resource_response.rb +35 -0
  36. data/lib/gonebusy/models/create_schedule_body.rb +144 -0
  37. data/lib/gonebusy/models/create_schedule_response.rb +35 -0
  38. data/lib/gonebusy/models/create_schedule_time_window_body.rb +117 -0
  39. data/lib/gonebusy/models/create_schedule_time_window_response.rb +35 -0
  40. data/lib/gonebusy/models/create_service_body.rb +98 -0
  41. data/lib/gonebusy/models/create_service_response.rb +35 -0
  42. data/lib/gonebusy/models/create_user_body.rb +89 -0
  43. data/lib/gonebusy/models/create_user_response.rb +35 -0
  44. data/lib/gonebusy/models/date_recurs_by_enum.rb +13 -0
  45. data/lib/gonebusy/models/delete_resource_by_id_response.rb +35 -0
  46. data/lib/gonebusy/models/delete_schedule_by_id_response.rb +35 -0
  47. data/lib/gonebusy/models/delete_schedule_time_window_by_id_response.rb +35 -0
  48. data/lib/gonebusy/models/delete_service_by_id_response.rb +35 -0
  49. data/lib/gonebusy/models/entities_address_entity.rb +116 -0
  50. data/lib/gonebusy/models/entities_availability_response.rb +58 -0
  51. data/lib/gonebusy/models/entities_booking_response.rb +71 -0
  52. data/lib/gonebusy/models/entities_category_response.rb +98 -0
  53. data/lib/gonebusy/models/entities_pricing_model_response.rb +89 -0
  54. data/lib/gonebusy/models/entities_resource_availabilities.rb +49 -0
  55. data/lib/gonebusy/models/entities_resource_response.rb +98 -0
  56. data/lib/gonebusy/models/entities_schedule_response.rb +76 -0
  57. data/lib/gonebusy/models/entities_search_response.rb +54 -0
  58. data/lib/gonebusy/models/entities_service_response.rb +116 -0
  59. data/lib/gonebusy/models/entities_slots.rb +45 -0
  60. data/lib/gonebusy/models/entities_thing_type_response.rb +44 -0
  61. data/lib/gonebusy/models/entities_time_window_response.rb +135 -0
  62. data/lib/gonebusy/models/entities_user_response.rb +152 -0
  63. data/lib/gonebusy/models/frequency_enum.rb +18 -0
  64. data/lib/gonebusy/models/gender_enum.rb +10 -0
  65. data/lib/gonebusy/models/get_booking_by_id_response.rb +35 -0
  66. data/lib/gonebusy/models/get_bookings_response.rb +40 -0
  67. data/lib/gonebusy/models/get_categories_response.rb +40 -0
  68. data/lib/gonebusy/models/get_category_by_id_response.rb +35 -0
  69. data/lib/gonebusy/models/get_pricing_model_by_id_response.rb +35 -0
  70. data/lib/gonebusy/models/get_pricing_models_response.rb +40 -0
  71. data/lib/gonebusy/models/get_resource_by_id_response.rb +35 -0
  72. data/lib/gonebusy/models/get_resource_things_response.rb +40 -0
  73. data/lib/gonebusy/models/get_resources_response.rb +40 -0
  74. data/lib/gonebusy/models/get_schedule_by_id_response.rb +35 -0
  75. data/lib/gonebusy/models/get_schedules_response.rb +40 -0
  76. data/lib/gonebusy/models/get_service_available_slots_by_id_response.rb +35 -0
  77. data/lib/gonebusy/models/get_service_by_id_response.rb +35 -0
  78. data/lib/gonebusy/models/get_services_response.rb +40 -0
  79. data/lib/gonebusy/models/get_user_by_id_response.rb +35 -0
  80. data/lib/gonebusy/models/get_users_pros_response.rb +40 -0
  81. data/lib/gonebusy/models/get_users_response.rb +40 -0
  82. data/lib/gonebusy/models/occurrence_enum.rb +22 -0
  83. data/lib/gonebusy/models/recurs_by_enum.rb +16 -0
  84. data/lib/gonebusy/models/search_query_response.rb +35 -0
  85. data/lib/gonebusy/models/update_booking_by_id_response.rb +35 -0
  86. data/lib/gonebusy/models/update_pricing_model_by_id_body.rb +62 -0
  87. data/lib/gonebusy/models/update_pricing_model_by_id_response.rb +35 -0
  88. data/lib/gonebusy/models/update_resource_by_id_body.rb +71 -0
  89. data/lib/gonebusy/models/update_resource_by_id_response.rb +35 -0
  90. data/lib/gonebusy/models/update_schedule_time_window_by_id_body.rb +117 -0
  91. data/lib/gonebusy/models/update_schedule_time_window_by_id_response.rb +35 -0
  92. data/lib/gonebusy/models/update_service_by_id_body.rb +89 -0
  93. data/lib/gonebusy/models/update_service_by_id_response.rb +35 -0
  94. data/lib/gonebusy/models/update_user_by_id_body.rb +89 -0
  95. data/lib/gonebusy/models/update_user_by_id_response.rb +35 -0
  96. data/lib/gonebusy.rb +105 -0
  97. metadata +186 -0
@@ -0,0 +1,180 @@
1
+ # This file was automatically generated for GoneBusy Inc. by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module Gonebusy
4
+ class CategoriesController < BaseController
5
+ @@instance = CategoriesController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # Return a Category 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 GetCategoryByIdResponse response from the API call
15
+ def get_category_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 << '/categories/{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.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 == 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 GetCategoryByIdResponse.from_hash(decoded)
66
+ end
67
+
68
+ # Create a Category
69
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
70
+ # @param [CreateCategoryBody] create_category_body Required parameter: the content of the request
71
+ # @return CreateCategoryResponse response from the API call
72
+ def create_category(options = Hash.new)
73
+
74
+ # the base uri for api requests
75
+ _query_builder = Configuration.base_uri.dup
76
+
77
+ # prepare query string for API call
78
+ _query_builder << '/categories/new'
79
+
80
+ # validate and preprocess url
81
+ _query_url = APIHelper.clean_url _query_builder
82
+
83
+ # prepare headers
84
+ _headers = {
85
+ 'accept' => 'application/json',
86
+ 'content-type' => 'application/json; charset=utf-8',
87
+ 'Authorization' => Configuration.authorization,
88
+ 'Authorization' => options['authorization']
89
+ }
90
+
91
+ # create the HttpRequest object for the call
92
+ _request = @http_client.post _query_url, headers: _headers, parameters: options['create_category_body'].to_json
93
+
94
+ # apply authentication
95
+ CustomAuth.apply(_request)
96
+
97
+ # execute the request
98
+ _context = execute_request(_request)
99
+
100
+ # endpoint error handling using HTTP status codes.
101
+ if _context.response.status_code == 400
102
+ raise EntitiesErrorException.new '400 - Bad Request', _context
103
+ elsif _context.response.status_code == 401
104
+ raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
105
+ elsif _context.response.status_code == 403
106
+ raise EntitiesErrorException.new '403 - Forbidden', _context
107
+ elsif _context.response.status_code == 422
108
+ raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
109
+ elsif _context.response.status_code == 500
110
+ raise APIException.new '500 - Unexpected error', _context
111
+ end
112
+
113
+ # global error handling using HTTP status codes.
114
+ validate_response(_context)
115
+
116
+ # return appropriate response type
117
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
118
+ return CreateCategoryResponse.from_hash(decoded)
119
+ end
120
+
121
+ # Return list of Categories.
122
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
123
+ # @param [Integer] page Optional parameter: Page offset to fetch.
124
+ # @param [Integer] per_page Optional parameter: Number of results to return per page.
125
+ # @param [Integer] user_id Optional parameter: Retrieve Categories of all services provided by this User Id. You must be authorized to manage this User Id.
126
+ # @return GetCategoriesResponse response from the API call
127
+ def get_categories(options = Hash.new)
128
+
129
+ # the base uri for api requests
130
+ _query_builder = Configuration.base_uri.dup
131
+
132
+ # prepare query string for API call
133
+ _query_builder << '/categories'
134
+
135
+ # process optional query parameters
136
+ _query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
137
+ 'page' => options['page'],
138
+ 'per_page' => options['per_page'],
139
+ 'user_id' => options['user_id']
140
+ }
141
+
142
+ # validate and preprocess url
143
+ _query_url = APIHelper.clean_url _query_builder
144
+
145
+ # prepare headers
146
+ _headers = {
147
+ 'accept' => 'application/json',
148
+ 'Authorization' => Configuration.authorization,
149
+ 'Authorization' => options['authorization']
150
+ }
151
+
152
+ # create the HttpRequest object for the call
153
+ _request = @http_client.get _query_url, headers: _headers
154
+
155
+ # apply authentication
156
+ CustomAuth.apply(_request)
157
+
158
+ # execute the request
159
+ _context = execute_request(_request)
160
+
161
+ # endpoint error handling using HTTP status codes.
162
+ if _context.response.status_code == 400
163
+ raise EntitiesErrorException.new '400 - Bad Request', _context
164
+ elsif _context.response.status_code == 401
165
+ raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
166
+ elsif _context.response.status_code == 403
167
+ raise EntitiesErrorException.new '403 - Forbidden', _context
168
+ elsif _context.response.status_code == 500
169
+ raise APIException.new '500 - Unexpected error', _context
170
+ end
171
+
172
+ # global error handling using HTTP status codes.
173
+ validate_response(_context)
174
+
175
+ # return appropriate response type
176
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
177
+ return GetCategoriesResponse.from_hash(decoded)
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,241 @@
1
+ # This file was automatically generated for GoneBusy Inc. by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module Gonebusy
4
+ class PricingModelsController < BaseController
5
+ @@instance = PricingModelsController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # Update a PricingModel 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 [UpdatePricingModelByIdBody] update_pricing_model_by_id_body Required parameter: the content of the request
15
+ # @return UpdatePricingModelByIdResponse response from the API call
16
+ def update_pricing_model_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 << '/pricing_models/{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_pricing_model_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 UpdatePricingModelByIdResponse.from_hash(decoded)
70
+ end
71
+
72
+ # Return a PricingModel 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 GetPricingModelByIdResponse response from the API call
76
+ def get_pricing_model_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 << '/pricing_models/{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 GetPricingModelByIdResponse.from_hash(decoded)
127
+ end
128
+
129
+ # Create a PricingModel with params
130
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
131
+ # @param [CreatePricingModelBody] create_pricing_model_body Required parameter: the content of the request
132
+ # @return CreatePricingModelResponse response from the API call
133
+ def create_pricing_model(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 << '/pricing_models/new'
140
+
141
+ # validate and preprocess url
142
+ _query_url = APIHelper.clean_url _query_builder
143
+
144
+ # prepare headers
145
+ _headers = {
146
+ 'accept' => 'application/json',
147
+ 'content-type' => 'application/json; charset=utf-8',
148
+ 'Authorization' => Configuration.authorization,
149
+ 'Authorization' => options['authorization']
150
+ }
151
+
152
+ # create the HttpRequest object for the call
153
+ _request = @http_client.post _query_url, headers: _headers, parameters: options['create_pricing_model_body'].to_json
154
+
155
+ # apply authentication
156
+ CustomAuth.apply(_request)
157
+
158
+ # execute the request
159
+ _context = execute_request(_request)
160
+
161
+ # endpoint error handling using HTTP status codes.
162
+ if _context.response.status_code == 400
163
+ raise EntitiesErrorException.new '400 - Bad Request', _context
164
+ elsif _context.response.status_code == 401
165
+ raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
166
+ elsif _context.response.status_code == 403
167
+ raise EntitiesErrorException.new '403 - Forbidden', _context
168
+ elsif _context.response.status_code == 422
169
+ raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
170
+ elsif _context.response.status_code == 500
171
+ raise APIException.new '500 - Unexpected error', _context
172
+ end
173
+
174
+ # global error handling using HTTP status codes.
175
+ validate_response(_context)
176
+
177
+ # return appropriate response type
178
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
179
+ return CreatePricingModelResponse.from_hash(decoded)
180
+ end
181
+
182
+ # Return list of PricingModels.
183
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
184
+ # @param [Integer] page Optional parameter: Page offset to fetch.
185
+ # @param [Integer] per_page Optional parameter: Number of results to return per page.
186
+ # @param [Integer] user_id Optional parameter: Retrieve PricingModels owned only by this User Id. You must be authorized to manage this User Id.
187
+ # @return GetPricingModelsResponse response from the API call
188
+ def get_pricing_models(options = Hash.new)
189
+
190
+ # the base uri for api requests
191
+ _query_builder = Configuration.base_uri.dup
192
+
193
+ # prepare query string for API call
194
+ _query_builder << '/pricing_models'
195
+
196
+ # process optional query parameters
197
+ _query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
198
+ 'page' => options['page'],
199
+ 'per_page' => options['per_page'],
200
+ 'user_id' => options['user_id']
201
+ }
202
+
203
+ # validate and preprocess url
204
+ _query_url = APIHelper.clean_url _query_builder
205
+
206
+ # prepare headers
207
+ _headers = {
208
+ 'accept' => 'application/json',
209
+ 'Authorization' => Configuration.authorization,
210
+ 'Authorization' => options['authorization']
211
+ }
212
+
213
+ # create the HttpRequest object for the call
214
+ _request = @http_client.get _query_url, headers: _headers
215
+
216
+ # apply authentication
217
+ CustomAuth.apply(_request)
218
+
219
+ # execute the request
220
+ _context = execute_request(_request)
221
+
222
+ # endpoint error handling using HTTP status codes.
223
+ if _context.response.status_code == 401
224
+ raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
225
+ elsif _context.response.status_code == 403
226
+ raise EntitiesErrorException.new '403 - Forbidden', _context
227
+ elsif _context.response.status_code == 404
228
+ raise EntitiesErrorException.new '404 - Not Found', _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 GetPricingModelsResponse.from_hash(decoded)
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,355 @@
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