gonebusy-ruby-client 0.0.9 → 0.1.0

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.
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,180 +1,151 @@
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
1
+ # This file was automatically generated 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 list of Categories.
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 Categories of all services provided by this User Id. You must be authorized to manage this User Id.
16
+ # @return GetCategoriesResponse response from the API call
17
+ def get_categories(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 << '/categories'
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 == 400
46
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
47
+ elsif _context.response.status_code == 401
48
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
49
+ elsif _context.response.status_code == 403
50
+ raise EntitiesErrorErrorException.new 'Forbidden', _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 GetCategoriesResponse.from_hash(decoded)
59
+ end
60
+
61
+ # Create a Category
62
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
63
+ # @param [CreateCategoryBody] create_category_body Optional parameter: the content of the request
64
+ # @return CreateCategoryResponse response from the API call
65
+ def create_category(authorization,
66
+ create_category_body = nil)
67
+
68
+ # prepare query url
69
+ _query_builder = Configuration.get_base_uri()
70
+ _query_builder << '/categories/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_category_body.to_json
83
+ CustomAuth.apply(_request)
84
+ _context = execute_request(_request)
85
+
86
+ # validate response against endpoint and global error codes
87
+ if _context.response.status_code == 400
88
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
89
+ elsif _context.response.status_code == 401
90
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
91
+ elsif _context.response.status_code == 403
92
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
93
+ elsif _context.response.status_code == 422
94
+ raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
95
+ elsif !_context.response.status_code.between?(200, 208)
96
+ raise APIException.new 'Unexpected error', _context
97
+ end
98
+ validate_response(_context)
99
+
100
+ # return appropriate response type
101
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
102
+ return CreateCategoryResponse.from_hash(decoded)
103
+ end
104
+
105
+ # Return a Category by id.
106
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
107
+ # @param [String] id Required parameter: Example:
108
+ # @return GetCategoryByIdResponse response from the API call
109
+ def get_category_by_id(authorization,
110
+ id)
111
+
112
+ # prepare query url
113
+ _query_builder = Configuration.get_base_uri()
114
+ _query_builder << '/categories/{id}'
115
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
116
+ 'id' => id
117
+ }
118
+ _query_url = APIHelper.clean_url _query_builder
119
+
120
+ # prepare headers
121
+ _headers = {
122
+ 'accept' => 'application/json',
123
+ 'Authorization' => Configuration.authorization,
124
+ 'Authorization' => authorization
125
+ }
126
+
127
+ # prepare and execute HttpRequest
128
+ _request = @http_client.get _query_url, headers: _headers
129
+ CustomAuth.apply(_request)
130
+ _context = execute_request(_request)
131
+
132
+ # validate response against endpoint and global error codes
133
+ if _context.response.status_code == 400
134
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
135
+ elsif _context.response.status_code == 401
136
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
137
+ elsif _context.response.status_code == 403
138
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
139
+ elsif _context.response.status_code == 404
140
+ raise EntitiesErrorErrorException.new 'Not Found', _context
141
+ elsif !_context.response.status_code.between?(200, 208)
142
+ raise APIException.new 'Unexpected error', _context
143
+ end
144
+ validate_response(_context)
145
+
146
+ # return appropriate response type
147
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
148
+ return GetCategoryByIdResponse.from_hash(decoded)
149
+ end
150
+ end
151
+ end
@@ -1,241 +1,202 @@
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
1
+ # This file was automatically generated 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
+ # Return list of PricingModels.
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 PricingModels owned only by this User Id. You must be authorized to manage this User Id.
16
+ # @return GetPricingModelsResponse response from the API call
17
+ def get_pricing_models(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 << '/pricing_models'
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 GetPricingModelsResponse.from_hash(decoded)
59
+ end
60
+
61
+ # Create a PricingModel with params
62
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
63
+ # @param [CreatePricingModelBody] create_pricing_model_body Optional parameter: the content of the request
64
+ # @return CreatePricingModelResponse response from the API call
65
+ def create_pricing_model(authorization,
66
+ create_pricing_model_body = nil)
67
+
68
+ # prepare query url
69
+ _query_builder = Configuration.get_base_uri()
70
+ _query_builder << '/pricing_models/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_pricing_model_body.to_json
83
+ CustomAuth.apply(_request)
84
+ _context = execute_request(_request)
85
+
86
+ # validate response against endpoint and global error codes
87
+ if _context.response.status_code == 400
88
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
89
+ elsif _context.response.status_code == 401
90
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
91
+ elsif _context.response.status_code == 403
92
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
93
+ elsif _context.response.status_code == 422
94
+ raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
95
+ elsif !_context.response.status_code.between?(200, 208)
96
+ raise APIException.new 'Unexpected error', _context
97
+ end
98
+ validate_response(_context)
99
+
100
+ # return appropriate response type
101
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
102
+ return CreatePricingModelResponse.from_hash(decoded)
103
+ end
104
+
105
+ # Return a PricingModel by id.
106
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
107
+ # @param [String] id Required parameter: Example:
108
+ # @return GetPricingModelByIdResponse response from the API call
109
+ def get_pricing_model_by_id(authorization,
110
+ id)
111
+
112
+ # prepare query url
113
+ _query_builder = Configuration.get_base_uri()
114
+ _query_builder << '/pricing_models/{id}'
115
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
116
+ 'id' => id
117
+ }
118
+ _query_url = APIHelper.clean_url _query_builder
119
+
120
+ # prepare headers
121
+ _headers = {
122
+ 'accept' => 'application/json',
123
+ 'Authorization' => Configuration.authorization,
124
+ 'Authorization' => authorization
125
+ }
126
+
127
+ # prepare and execute HttpRequest
128
+ _request = @http_client.get _query_url, headers: _headers
129
+ CustomAuth.apply(_request)
130
+ _context = execute_request(_request)
131
+
132
+ # validate response against endpoint and global error codes
133
+ if _context.response.status_code == 400
134
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
135
+ elsif _context.response.status_code == 401
136
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
137
+ elsif _context.response.status_code == 403
138
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
139
+ elsif _context.response.status_code == 404
140
+ raise EntitiesErrorErrorException.new 'Not Found', _context
141
+ elsif !_context.response.status_code.between?(200, 208)
142
+ raise APIException.new 'Unexpected error', _context
143
+ end
144
+ validate_response(_context)
145
+
146
+ # return appropriate response type
147
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
148
+ return GetPricingModelByIdResponse.from_hash(decoded)
149
+ end
150
+
151
+ # Update a PricingModel by id, with params
152
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
153
+ # @param [String] id Required parameter: Example:
154
+ # @param [UpdatePricingModelByIdBody] update_pricing_model_by_id_body Optional parameter: the content of the request
155
+ # @return UpdatePricingModelByIdResponse response from the API call
156
+ def update_pricing_model_by_id(authorization,
157
+ id,
158
+ update_pricing_model_by_id_body = nil)
159
+
160
+ # prepare query url
161
+ _query_builder = Configuration.get_base_uri()
162
+ _query_builder << '/pricing_models/{id}'
163
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
164
+ 'id' => id
165
+ }
166
+ _query_url = APIHelper.clean_url _query_builder
167
+
168
+ # prepare headers
169
+ _headers = {
170
+ 'accept' => 'application/json',
171
+ 'content-type' => 'application/json; charset=utf-8',
172
+ 'Authorization' => Configuration.authorization,
173
+ 'Authorization' => authorization
174
+ }
175
+
176
+ # prepare and execute HttpRequest
177
+ _request = @http_client.put _query_url, headers: _headers, parameters: update_pricing_model_by_id_body.to_json
178
+ CustomAuth.apply(_request)
179
+ _context = execute_request(_request)
180
+
181
+ # validate response against endpoint and global error codes
182
+ if _context.response.status_code == 400
183
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
184
+ elsif _context.response.status_code == 401
185
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
186
+ elsif _context.response.status_code == 403
187
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
188
+ elsif _context.response.status_code == 404
189
+ raise EntitiesErrorErrorException.new 'Not Found', _context
190
+ elsif _context.response.status_code == 422
191
+ raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
192
+ elsif !_context.response.status_code.between?(200, 208)
193
+ raise APIException.new 'Unexpected error', _context
194
+ end
195
+ validate_response(_context)
196
+
197
+ # return appropriate response type
198
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
199
+ return UpdatePricingModelByIdResponse.from_hash(decoded)
200
+ end
201
+ end
202
+ end