gonebusy-ruby-client 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -68
- data/lib/gonebusy/api_helper.rb +181 -149
- data/lib/gonebusy/configuration.rb +51 -16
- data/lib/gonebusy/controllers/base_controller.rb +46 -45
- data/lib/gonebusy/controllers/bookings_controller.rb +257 -293
- data/lib/gonebusy/controllers/categories_controller.rb +151 -180
- data/lib/gonebusy/controllers/pricing_models_controller.rb +202 -241
- data/lib/gonebusy/controllers/resources_controller.rb +295 -355
- data/lib/gonebusy/controllers/schedules_controller.rb +361 -428
- data/lib/gonebusy/controllers/search_controller.rb +52 -63
- data/lib/gonebusy/controllers/services_controller.rb +310 -367
- data/lib/gonebusy/controllers/users_controller.rb +199 -239
- data/lib/gonebusy/exceptions/api_exception.rb +16 -16
- data/lib/gonebusy/exceptions/entities_error_error_exception.rb +27 -0
- data/lib/gonebusy/exceptions/entities_error_exception.rb +26 -26
- data/lib/gonebusy/gonebusy_client.rb +58 -58
- data/lib/gonebusy/http/auth/custom_auth.rb +15 -15
- data/lib/gonebusy/http/faraday_client.rb +43 -41
- data/lib/gonebusy/http/http_call_back.rb +17 -17
- data/lib/gonebusy/http/http_client.rb +84 -82
- data/lib/gonebusy/http/http_context.rb +15 -15
- data/lib/gonebusy/http/http_method_enum.rb +7 -7
- data/lib/gonebusy/http/http_request.rb +44 -44
- data/lib/gonebusy/http/http_response.rb +19 -19
- data/lib/gonebusy/models/base_model.rb +31 -31
- data/lib/gonebusy/models/cancel_booking_by_id_response.rb +35 -35
- data/lib/gonebusy/models/create_booking_body.rb +134 -80
- data/lib/gonebusy/models/create_booking_response.rb +35 -35
- data/lib/gonebusy/models/create_category_body.rb +71 -71
- data/lib/gonebusy/models/create_category_response.rb +35 -35
- data/lib/gonebusy/models/create_pricing_model_body.rb +80 -80
- data/lib/gonebusy/models/create_pricing_model_response.rb +35 -35
- data/lib/gonebusy/models/create_resource_body.rb +89 -89
- data/lib/gonebusy/models/create_resource_response.rb +35 -35
- data/lib/gonebusy/models/create_schedule_body.rb +143 -144
- data/lib/gonebusy/models/create_schedule_response.rb +35 -35
- data/lib/gonebusy/models/create_schedule_time_window_body.rb +116 -117
- data/lib/gonebusy/models/create_schedule_time_window_response.rb +35 -35
- data/lib/gonebusy/models/create_service_body.rb +107 -107
- data/lib/gonebusy/models/create_service_response.rb +35 -35
- data/lib/gonebusy/models/create_user_body.rb +89 -89
- data/lib/gonebusy/models/create_user_response.rb +35 -35
- data/lib/gonebusy/models/date_recurs_by_enum.rb +12 -12
- data/lib/gonebusy/models/delete_resource_by_id_response.rb +35 -35
- data/lib/gonebusy/models/delete_schedule_by_id_response.rb +35 -35
- data/lib/gonebusy/models/delete_schedule_time_window_by_id_response.rb +35 -35
- data/lib/gonebusy/models/delete_service_by_id_response.rb +35 -35
- data/lib/gonebusy/models/entities_address_entity.rb +116 -116
- data/lib/gonebusy/models/entities_availability_response.rb +58 -58
- data/lib/gonebusy/models/entities_booking_response.rb +71 -71
- data/lib/gonebusy/models/entities_category_response.rb +98 -98
- data/lib/gonebusy/models/entities_pricing_model_response.rb +89 -89
- data/lib/gonebusy/models/entities_resource_availabilities.rb +49 -49
- data/lib/gonebusy/models/entities_resource_response.rb +107 -107
- data/lib/gonebusy/models/entities_schedule_response.rb +76 -76
- data/lib/gonebusy/models/entities_search_response.rb +54 -54
- data/lib/gonebusy/models/entities_service_response.rb +134 -130
- data/lib/gonebusy/models/entities_slots.rb +44 -45
- data/lib/gonebusy/models/entities_thing_type_response.rb +44 -44
- data/lib/gonebusy/models/entities_time_window_response.rb +134 -135
- data/lib/gonebusy/models/entities_user_response.rb +152 -152
- data/lib/gonebusy/models/frequency_enum.rb +17 -17
- data/lib/gonebusy/models/gender_enum.rb +9 -9
- data/lib/gonebusy/models/get_booking_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_bookings_response.rb +40 -40
- data/lib/gonebusy/models/get_categories_response.rb +40 -40
- data/lib/gonebusy/models/get_category_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_pricing_model_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_pricing_models_response.rb +40 -40
- data/lib/gonebusy/models/get_resource_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_resource_things_response.rb +40 -40
- data/lib/gonebusy/models/get_resources_response.rb +40 -40
- data/lib/gonebusy/models/get_schedule_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_schedules_response.rb +40 -40
- data/lib/gonebusy/models/get_service_available_slots_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_service_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_services_response.rb +40 -40
- data/lib/gonebusy/models/get_user_by_id_response.rb +35 -35
- data/lib/gonebusy/models/get_users_response.rb +40 -40
- data/lib/gonebusy/models/occurrence_enum.rb +21 -21
- data/lib/gonebusy/models/recurs_by_enum.rb +15 -15
- data/lib/gonebusy/models/search_query_response.rb +35 -35
- data/lib/gonebusy/models/update_booking_by_id_body.rb +116 -0
- data/lib/gonebusy/models/update_booking_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_pricing_model_by_id_body.rb +62 -62
- data/lib/gonebusy/models/update_pricing_model_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_resource_by_id_body.rb +71 -71
- data/lib/gonebusy/models/update_resource_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_schedule_time_window_by_id_body.rb +116 -117
- data/lib/gonebusy/models/update_schedule_time_window_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_service_by_id_body.rb +98 -98
- data/lib/gonebusy/models/update_service_by_id_response.rb +35 -35
- data/lib/gonebusy/models/update_user_by_id_body.rb +89 -89
- data/lib/gonebusy/models/update_user_by_id_response.rb +35 -35
- data/lib/gonebusy.rb +108 -104
- metadata +53 -17
@@ -1,180 +1,151 @@
|
|
1
|
-
# This file was automatically generated
|
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
|
12
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
-
# @param [
|
14
|
-
# @
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
_query_builder
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
'
|
35
|
-
'Authorization' =>
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
#
|
45
|
-
_context
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
_context
|
99
|
-
|
100
|
-
#
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
#
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
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
|
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
|
-
#
|
12
|
-
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
-
# @param [
|
14
|
-
# @param [
|
15
|
-
# @
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
_query_builder = APIHelper.
|
26
|
-
'
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
_query_url = APIHelper.clean_url _query_builder
|
31
|
-
|
32
|
-
# prepare headers
|
33
|
-
_headers = {
|
34
|
-
'accept' => 'application/json',
|
35
|
-
'
|
36
|
-
'Authorization' =>
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
_request
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
_context
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
# prepare
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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
|