gonebusy-ruby-client 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +2 -1
- data/lib/gonebusy/controllers/bookings_controller.rb +77 -74
- data/lib/gonebusy/controllers/categories_controller.rb +29 -29
- data/lib/gonebusy/controllers/pricing_models_controller.rb +47 -47
- data/lib/gonebusy/controllers/resources_controller.rb +77 -77
- data/lib/gonebusy/controllers/schedules_controller.rb +92 -92
- data/lib/gonebusy/controllers/services_controller.rb +86 -86
- data/lib/gonebusy/controllers/users_controller.rb +56 -56
- data/lib/gonebusy/models/cancel_booking_by_id_response.rb +10 -12
- data/lib/gonebusy/models/create_booking_body.rb +78 -80
- data/lib/gonebusy/models/create_booking_response.rb +10 -12
- data/lib/gonebusy/models/create_category_body.rb +34 -36
- data/lib/gonebusy/models/create_category_response.rb +10 -12
- data/lib/gonebusy/models/create_pricing_model_body.rb +35 -37
- data/lib/gonebusy/models/create_pricing_model_response.rb +10 -12
- data/lib/gonebusy/models/create_resource_body.rb +39 -41
- data/lib/gonebusy/models/create_resource_response.rb +10 -12
- data/lib/gonebusy/models/create_schedule_body.rb +92 -94
- data/lib/gonebusy/models/create_schedule_response.rb +10 -12
- data/lib/gonebusy/models/create_schedule_time_window_body.rb +64 -66
- data/lib/gonebusy/models/create_schedule_time_window_response.rb +10 -12
- data/lib/gonebusy/models/create_service_body.rb +57 -59
- data/lib/gonebusy/models/create_service_response.rb +10 -12
- data/lib/gonebusy/models/create_user_body.rb +40 -42
- data/lib/gonebusy/models/create_user_response.rb +10 -12
- data/lib/gonebusy/models/delete_resource_by_id_response.rb +10 -12
- data/lib/gonebusy/models/delete_schedule_by_id_response.rb +10 -12
- data/lib/gonebusy/models/delete_schedule_time_window_by_id_response.rb +10 -12
- data/lib/gonebusy/models/delete_service_by_id_response.rb +10 -12
- data/lib/gonebusy/models/entities_address_entity.rb +69 -71
- data/lib/gonebusy/models/entities_availability_response.rb +21 -23
- data/lib/gonebusy/models/entities_booking_response.rb +32 -34
- data/lib/gonebusy/models/entities_category_response.rb +52 -54
- data/lib/gonebusy/models/entities_pricing_model_response.rb +44 -46
- data/lib/gonebusy/models/entities_resource_availabilities.rb +24 -26
- data/lib/gonebusy/models/entities_resource_response.rb +60 -62
- data/lib/gonebusy/models/entities_schedule_response.rb +26 -28
- data/lib/gonebusy/models/entities_search_response.rb +29 -31
- data/lib/gonebusy/models/entities_service_response.rb +82 -84
- data/lib/gonebusy/models/entities_slots.rb +13 -15
- data/lib/gonebusy/models/entities_thing_type_response.rb +13 -15
- data/lib/gonebusy/models/entities_time_window_response.rb +81 -83
- data/lib/gonebusy/models/entities_user_response.rb +95 -97
- data/lib/gonebusy/models/get_booking_by_id_response.rb +10 -12
- data/lib/gonebusy/models/get_bookings_response.rb +14 -16
- data/lib/gonebusy/models/get_categories_response.rb +14 -16
- data/lib/gonebusy/models/get_category_by_id_response.rb +10 -12
- data/lib/gonebusy/models/get_pricing_model_by_id_response.rb +10 -12
- data/lib/gonebusy/models/get_pricing_models_response.rb +14 -16
- data/lib/gonebusy/models/get_resource_by_id_response.rb +10 -12
- data/lib/gonebusy/models/get_resource_things_response.rb +14 -16
- data/lib/gonebusy/models/get_resources_response.rb +14 -16
- data/lib/gonebusy/models/get_schedule_by_id_response.rb +10 -12
- data/lib/gonebusy/models/get_schedules_response.rb +14 -16
- data/lib/gonebusy/models/get_service_available_slots_by_id_response.rb +10 -12
- data/lib/gonebusy/models/get_service_by_id_response.rb +10 -12
- data/lib/gonebusy/models/get_services_response.rb +14 -16
- data/lib/gonebusy/models/get_user_by_id_response.rb +10 -12
- data/lib/gonebusy/models/get_users_response.rb +14 -16
- data/lib/gonebusy/models/search_query_response.rb +10 -12
- data/lib/gonebusy/models/update_booking_by_id_body.rb +58 -60
- data/lib/gonebusy/models/update_booking_by_id_response.rb +10 -12
- data/lib/gonebusy/models/update_pricing_model_by_id_body.rb +28 -30
- data/lib/gonebusy/models/update_pricing_model_by_id_response.rb +10 -12
- data/lib/gonebusy/models/update_resource_by_id_body.rb +33 -35
- data/lib/gonebusy/models/update_resource_by_id_response.rb +10 -12
- data/lib/gonebusy/models/update_schedule_time_window_by_id_body.rb +71 -73
- data/lib/gonebusy/models/update_schedule_time_window_by_id_response.rb +10 -12
- data/lib/gonebusy/models/update_service_by_id_body.rb +43 -45
- data/lib/gonebusy/models/update_service_by_id_response.rb +10 -12
- data/lib/gonebusy/models/update_user_by_id_body.rb +41 -43
- data/lib/gonebusy/models/update_user_by_id_response.rb +10 -12
- data/lib/gonebusy.rb +67 -67
- metadata +2 -3
- data/lib/gonebusy/exceptions/entities_error_exception.rb +0 -27
@@ -8,46 +8,47 @@ module Gonebusy
|
|
8
8
|
@@instance
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
11
|
+
# Update a PricingModel by id, with params
|
12
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
|
-
per_page = 10,
|
20
|
-
user_id = nil)
|
13
|
+
# @param [String] id Required parameter: Example:
|
14
|
+
# @param [UpdatePricingModelByIdBody] update_pricing_model_by_id_body Optional parameter: the content of the request
|
15
|
+
# @return UpdatePricingModelByIdResponse response from the API call
|
16
|
+
def update_pricing_model_by_id(authorization,
|
17
|
+
id,
|
18
|
+
update_pricing_model_by_id_body = nil)
|
21
19
|
|
22
20
|
# prepare query url
|
23
21
|
_query_builder = Configuration.get_base_uri()
|
24
|
-
_query_builder << '/pricing_models'
|
25
|
-
_query_builder = APIHelper.
|
26
|
-
'
|
27
|
-
|
28
|
-
'user_id' => user_id
|
29
|
-
}, array_serialization: Configuration.array_serialization
|
22
|
+
_query_builder << '/pricing_models/{id}'
|
23
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
24
|
+
'id' => id
|
25
|
+
}
|
30
26
|
_query_url = APIHelper.clean_url _query_builder
|
31
27
|
|
32
28
|
# prepare headers
|
33
29
|
_headers = {
|
34
30
|
'accept' => 'application/json',
|
31
|
+
'content-type' => 'application/json; charset=utf-8',
|
35
32
|
'Authorization' => Configuration.authorization,
|
36
33
|
'Authorization' => authorization
|
37
34
|
}
|
38
35
|
|
39
36
|
# prepare and execute HttpRequest
|
40
|
-
_request = @http_client.
|
37
|
+
_request = @http_client.put _query_url, headers: _headers, parameters: update_pricing_model_by_id_body.to_json
|
41
38
|
CustomAuth.apply(_request)
|
42
39
|
_context = execute_request(_request)
|
43
40
|
|
44
41
|
# validate response against endpoint and global error codes
|
45
|
-
if _context.response.status_code ==
|
42
|
+
if _context.response.status_code == 400
|
43
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
44
|
+
elsif _context.response.status_code == 401
|
46
45
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
47
46
|
elsif _context.response.status_code == 403
|
48
47
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
49
48
|
elsif _context.response.status_code == 404
|
50
49
|
raise EntitiesErrorErrorException.new 'Not Found', _context
|
50
|
+
elsif _context.response.status_code == 422
|
51
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
51
52
|
elsif !_context.response.status_code.between?(200, 208)
|
52
53
|
raise APIException.new 'Unexpected error', _context
|
53
54
|
end
|
@@ -55,43 +56,49 @@ module Gonebusy
|
|
55
56
|
|
56
57
|
# return appropriate response type
|
57
58
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
58
|
-
return
|
59
|
+
return UpdatePricingModelByIdResponse.from_hash(decoded)
|
59
60
|
end
|
60
61
|
|
61
|
-
#
|
62
|
+
# Return list of PricingModels.
|
62
63
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
63
|
-
# @param [
|
64
|
-
# @
|
65
|
-
|
66
|
-
|
64
|
+
# @param [Integer] user_id Optional parameter: Retrieve PricingModels owned only by this User Id. You must be authorized to manage this User Id.
|
65
|
+
# @param [Integer] page Optional parameter: Page offset to fetch.
|
66
|
+
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
67
|
+
# @return GetPricingModelsResponse response from the API call
|
68
|
+
def get_pricing_models(authorization,
|
69
|
+
user_id = nil,
|
70
|
+
page = 1,
|
71
|
+
per_page = 10)
|
67
72
|
|
68
73
|
# prepare query url
|
69
74
|
_query_builder = Configuration.get_base_uri()
|
70
|
-
_query_builder << '/pricing_models
|
75
|
+
_query_builder << '/pricing_models'
|
76
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
77
|
+
'user_id' => user_id,
|
78
|
+
'page' => page,
|
79
|
+
'per_page' => per_page
|
80
|
+
}, array_serialization: Configuration.array_serialization
|
71
81
|
_query_url = APIHelper.clean_url _query_builder
|
72
82
|
|
73
83
|
# prepare headers
|
74
84
|
_headers = {
|
75
85
|
'accept' => 'application/json',
|
76
|
-
'content-type' => 'application/json; charset=utf-8',
|
77
86
|
'Authorization' => Configuration.authorization,
|
78
87
|
'Authorization' => authorization
|
79
88
|
}
|
80
89
|
|
81
90
|
# prepare and execute HttpRequest
|
82
|
-
_request = @http_client.
|
91
|
+
_request = @http_client.get _query_url, headers: _headers
|
83
92
|
CustomAuth.apply(_request)
|
84
93
|
_context = execute_request(_request)
|
85
94
|
|
86
95
|
# validate response against endpoint and global error codes
|
87
|
-
if _context.response.status_code ==
|
88
|
-
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
89
|
-
elsif _context.response.status_code == 401
|
96
|
+
if _context.response.status_code == 401
|
90
97
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
91
98
|
elsif _context.response.status_code == 403
|
92
99
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
93
|
-
elsif _context.response.status_code ==
|
94
|
-
raise EntitiesErrorErrorException.new '
|
100
|
+
elsif _context.response.status_code == 404
|
101
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
95
102
|
elsif !_context.response.status_code.between?(200, 208)
|
96
103
|
raise APIException.new 'Unexpected error', _context
|
97
104
|
end
|
@@ -99,7 +106,7 @@ module Gonebusy
|
|
99
106
|
|
100
107
|
# return appropriate response type
|
101
108
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
102
|
-
return
|
109
|
+
return GetPricingModelsResponse.from_hash(decoded)
|
103
110
|
end
|
104
111
|
|
105
112
|
# Return a PricingModel by id.
|
@@ -148,21 +155,16 @@ module Gonebusy
|
|
148
155
|
return GetPricingModelByIdResponse.from_hash(decoded)
|
149
156
|
end
|
150
157
|
|
151
|
-
#
|
158
|
+
# Create a PricingModel with params
|
152
159
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
153
|
-
# @param [
|
154
|
-
# @
|
155
|
-
|
156
|
-
|
157
|
-
id,
|
158
|
-
update_pricing_model_by_id_body = nil)
|
160
|
+
# @param [CreatePricingModelBody] create_pricing_model_body Optional parameter: the content of the request
|
161
|
+
# @return CreatePricingModelResponse response from the API call
|
162
|
+
def create_pricing_model(authorization,
|
163
|
+
create_pricing_model_body = nil)
|
159
164
|
|
160
165
|
# prepare query url
|
161
166
|
_query_builder = Configuration.get_base_uri()
|
162
|
-
_query_builder << '/pricing_models/
|
163
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
164
|
-
'id' => id
|
165
|
-
}
|
167
|
+
_query_builder << '/pricing_models/new'
|
166
168
|
_query_url = APIHelper.clean_url _query_builder
|
167
169
|
|
168
170
|
# prepare headers
|
@@ -174,7 +176,7 @@ module Gonebusy
|
|
174
176
|
}
|
175
177
|
|
176
178
|
# prepare and execute HttpRequest
|
177
|
-
_request = @http_client.
|
179
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: create_pricing_model_body.to_json
|
178
180
|
CustomAuth.apply(_request)
|
179
181
|
_context = execute_request(_request)
|
180
182
|
|
@@ -185,8 +187,6 @@ module Gonebusy
|
|
185
187
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
186
188
|
elsif _context.response.status_code == 403
|
187
189
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
188
|
-
elsif _context.response.status_code == 404
|
189
|
-
raise EntitiesErrorErrorException.new 'Not Found', _context
|
190
190
|
elsif _context.response.status_code == 422
|
191
191
|
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
192
192
|
elsif !_context.response.status_code.between?(200, 208)
|
@@ -196,7 +196,7 @@ module Gonebusy
|
|
196
196
|
|
197
197
|
# return appropriate response type
|
198
198
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
199
|
-
return
|
199
|
+
return CreatePricingModelResponse.from_hash(decoded)
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end
|
@@ -8,46 +8,47 @@ module Gonebusy
|
|
8
8
|
@@instance
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
11
|
+
# Update a Resource by id, with params
|
12
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
|
-
per_page = 10,
|
20
|
-
user_id = nil)
|
13
|
+
# @param [String] id Required parameter: Example:
|
14
|
+
# @param [UpdateResourceByIdBody] update_resource_by_id_body Optional parameter: the content of the request
|
15
|
+
# @return UpdateResourceByIdResponse response from the API call
|
16
|
+
def update_resource_by_id(authorization,
|
17
|
+
id,
|
18
|
+
update_resource_by_id_body = nil)
|
21
19
|
|
22
20
|
# prepare query url
|
23
21
|
_query_builder = Configuration.get_base_uri()
|
24
|
-
_query_builder << '/resources'
|
25
|
-
_query_builder = APIHelper.
|
26
|
-
'
|
27
|
-
|
28
|
-
'user_id' => user_id
|
29
|
-
}, array_serialization: Configuration.array_serialization
|
22
|
+
_query_builder << '/resources/{id}'
|
23
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
24
|
+
'id' => id
|
25
|
+
}
|
30
26
|
_query_url = APIHelper.clean_url _query_builder
|
31
27
|
|
32
28
|
# prepare headers
|
33
29
|
_headers = {
|
34
30
|
'accept' => 'application/json',
|
31
|
+
'content-type' => 'application/json; charset=utf-8',
|
35
32
|
'Authorization' => Configuration.authorization,
|
36
33
|
'Authorization' => authorization
|
37
34
|
}
|
38
35
|
|
39
36
|
# prepare and execute HttpRequest
|
40
|
-
_request = @http_client.
|
37
|
+
_request = @http_client.put _query_url, headers: _headers, parameters: update_resource_by_id_body.to_json
|
41
38
|
CustomAuth.apply(_request)
|
42
39
|
_context = execute_request(_request)
|
43
40
|
|
44
41
|
# validate response against endpoint and global error codes
|
45
|
-
if _context.response.status_code ==
|
42
|
+
if _context.response.status_code == 400
|
43
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
44
|
+
elsif _context.response.status_code == 401
|
46
45
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
47
46
|
elsif _context.response.status_code == 403
|
48
47
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
49
48
|
elsif _context.response.status_code == 404
|
50
49
|
raise EntitiesErrorErrorException.new 'Not Found', _context
|
50
|
+
elsif _context.response.status_code == 422
|
51
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
51
52
|
elsif !_context.response.status_code.between?(200, 208)
|
52
53
|
raise APIException.new 'Unexpected error', _context
|
53
54
|
end
|
@@ -55,43 +56,49 @@ module Gonebusy
|
|
55
56
|
|
56
57
|
# return appropriate response type
|
57
58
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
58
|
-
return
|
59
|
+
return UpdateResourceByIdResponse.from_hash(decoded)
|
59
60
|
end
|
60
61
|
|
61
|
-
#
|
62
|
+
# Return list of Resources.
|
62
63
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
63
|
-
# @param [
|
64
|
-
# @
|
65
|
-
|
66
|
-
|
64
|
+
# @param [Integer] user_id Optional parameter: Retrieve Resources owned only by this User Id. You must be authorized to manage this User Id.
|
65
|
+
# @param [Integer] page Optional parameter: Page offset to fetch.
|
66
|
+
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
67
|
+
# @return GetResourcesResponse response from the API call
|
68
|
+
def get_resources(authorization,
|
69
|
+
user_id = nil,
|
70
|
+
page = 1,
|
71
|
+
per_page = 10)
|
67
72
|
|
68
73
|
# prepare query url
|
69
74
|
_query_builder = Configuration.get_base_uri()
|
70
|
-
_query_builder << '/resources
|
75
|
+
_query_builder << '/resources'
|
76
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
77
|
+
'user_id' => user_id,
|
78
|
+
'page' => page,
|
79
|
+
'per_page' => per_page
|
80
|
+
}, array_serialization: Configuration.array_serialization
|
71
81
|
_query_url = APIHelper.clean_url _query_builder
|
72
82
|
|
73
83
|
# prepare headers
|
74
84
|
_headers = {
|
75
85
|
'accept' => 'application/json',
|
76
|
-
'content-type' => 'application/json; charset=utf-8',
|
77
86
|
'Authorization' => Configuration.authorization,
|
78
87
|
'Authorization' => authorization
|
79
88
|
}
|
80
89
|
|
81
90
|
# prepare and execute HttpRequest
|
82
|
-
_request = @http_client.
|
91
|
+
_request = @http_client.get _query_url, headers: _headers
|
83
92
|
CustomAuth.apply(_request)
|
84
93
|
_context = execute_request(_request)
|
85
94
|
|
86
95
|
# validate response against endpoint and global error codes
|
87
|
-
if _context.response.status_code ==
|
88
|
-
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
89
|
-
elsif _context.response.status_code == 401
|
96
|
+
if _context.response.status_code == 401
|
90
97
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
91
98
|
elsif _context.response.status_code == 403
|
92
99
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
93
|
-
elsif _context.response.status_code ==
|
94
|
-
raise EntitiesErrorErrorException.new '
|
100
|
+
elsif _context.response.status_code == 404
|
101
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
95
102
|
elsif !_context.response.status_code.between?(200, 208)
|
96
103
|
raise APIException.new 'Unexpected error', _context
|
97
104
|
end
|
@@ -99,25 +106,22 @@ module Gonebusy
|
|
99
106
|
|
100
107
|
# return appropriate response type
|
101
108
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
102
|
-
return
|
109
|
+
return GetResourcesResponse.from_hash(decoded)
|
103
110
|
end
|
104
111
|
|
105
|
-
#
|
112
|
+
# Delete a Resource by id
|
106
113
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
107
|
-
# @param [
|
108
|
-
# @
|
109
|
-
|
110
|
-
|
111
|
-
page = 1,
|
112
|
-
per_page = 10)
|
114
|
+
# @param [String] id Required parameter: Example:
|
115
|
+
# @return DeleteResourceByIdResponse response from the API call
|
116
|
+
def delete_resource_by_id(authorization,
|
117
|
+
id)
|
113
118
|
|
114
119
|
# prepare query url
|
115
120
|
_query_builder = Configuration.get_base_uri()
|
116
|
-
_query_builder << '/resources/
|
117
|
-
_query_builder = APIHelper.
|
118
|
-
'
|
119
|
-
|
120
|
-
}, array_serialization: Configuration.array_serialization
|
121
|
+
_query_builder << '/resources/{id}'
|
122
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
123
|
+
'id' => id
|
124
|
+
}
|
121
125
|
_query_url = APIHelper.clean_url _query_builder
|
122
126
|
|
123
127
|
# prepare headers
|
@@ -128,7 +132,7 @@ module Gonebusy
|
|
128
132
|
}
|
129
133
|
|
130
134
|
# prepare and execute HttpRequest
|
131
|
-
_request = @http_client.
|
135
|
+
_request = @http_client.delete _query_url, headers: _headers
|
132
136
|
CustomAuth.apply(_request)
|
133
137
|
_context = execute_request(_request)
|
134
138
|
|
@@ -139,6 +143,8 @@ module Gonebusy
|
|
139
143
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
140
144
|
elsif _context.response.status_code == 403
|
141
145
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
146
|
+
elsif _context.response.status_code == 404
|
147
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
142
148
|
elsif !_context.response.status_code.between?(200, 208)
|
143
149
|
raise APIException.new 'Unexpected error', _context
|
144
150
|
end
|
@@ -146,7 +152,7 @@ module Gonebusy
|
|
146
152
|
|
147
153
|
# return appropriate response type
|
148
154
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
149
|
-
return
|
155
|
+
return DeleteResourceByIdResponse.from_hash(decoded)
|
150
156
|
end
|
151
157
|
|
152
158
|
# Return a Resource by id.
|
@@ -195,33 +201,33 @@ module Gonebusy
|
|
195
201
|
return GetResourceByIdResponse.from_hash(decoded)
|
196
202
|
end
|
197
203
|
|
198
|
-
#
|
204
|
+
# Return all Resource Things.
|
199
205
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
200
|
-
# @param [
|
201
|
-
# @param [
|
202
|
-
# @return
|
203
|
-
def
|
204
|
-
|
205
|
-
|
206
|
+
# @param [Integer] page Optional parameter: Page offset to fetch.
|
207
|
+
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
208
|
+
# @return GetResourceThingsResponse response from the API call
|
209
|
+
def get_resource_things(authorization,
|
210
|
+
page = 1,
|
211
|
+
per_page = 10)
|
206
212
|
|
207
213
|
# prepare query url
|
208
214
|
_query_builder = Configuration.get_base_uri()
|
209
|
-
_query_builder << '/resources/
|
210
|
-
_query_builder = APIHelper.
|
211
|
-
'
|
212
|
-
|
215
|
+
_query_builder << '/resources/things'
|
216
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
217
|
+
'page' => page,
|
218
|
+
'per_page' => per_page
|
219
|
+
}, array_serialization: Configuration.array_serialization
|
213
220
|
_query_url = APIHelper.clean_url _query_builder
|
214
221
|
|
215
222
|
# prepare headers
|
216
223
|
_headers = {
|
217
224
|
'accept' => 'application/json',
|
218
|
-
'content-type' => 'application/json; charset=utf-8',
|
219
225
|
'Authorization' => Configuration.authorization,
|
220
226
|
'Authorization' => authorization
|
221
227
|
}
|
222
228
|
|
223
229
|
# prepare and execute HttpRequest
|
224
|
-
_request = @http_client.
|
230
|
+
_request = @http_client.get _query_url, headers: _headers
|
225
231
|
CustomAuth.apply(_request)
|
226
232
|
_context = execute_request(_request)
|
227
233
|
|
@@ -232,10 +238,6 @@ module Gonebusy
|
|
232
238
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
233
239
|
elsif _context.response.status_code == 403
|
234
240
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
235
|
-
elsif _context.response.status_code == 404
|
236
|
-
raise EntitiesErrorErrorException.new 'Not Found', _context
|
237
|
-
elsif _context.response.status_code == 422
|
238
|
-
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
239
241
|
elsif !_context.response.status_code.between?(200, 208)
|
240
242
|
raise APIException.new 'Unexpected error', _context
|
241
243
|
end
|
@@ -243,33 +245,31 @@ module Gonebusy
|
|
243
245
|
|
244
246
|
# return appropriate response type
|
245
247
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
246
|
-
return
|
248
|
+
return GetResourceThingsResponse.from_hash(decoded)
|
247
249
|
end
|
248
250
|
|
249
|
-
#
|
251
|
+
# Create a Resource with params
|
250
252
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
251
|
-
# @param [
|
252
|
-
# @return
|
253
|
-
def
|
254
|
-
|
253
|
+
# @param [CreateResourceBody] create_resource_body Optional parameter: the content of the request
|
254
|
+
# @return CreateResourceResponse response from the API call
|
255
|
+
def create_resource(authorization,
|
256
|
+
create_resource_body = nil)
|
255
257
|
|
256
258
|
# prepare query url
|
257
259
|
_query_builder = Configuration.get_base_uri()
|
258
|
-
_query_builder << '/resources/
|
259
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
260
|
-
'id' => id
|
261
|
-
}
|
260
|
+
_query_builder << '/resources/new'
|
262
261
|
_query_url = APIHelper.clean_url _query_builder
|
263
262
|
|
264
263
|
# prepare headers
|
265
264
|
_headers = {
|
266
265
|
'accept' => 'application/json',
|
266
|
+
'content-type' => 'application/json; charset=utf-8',
|
267
267
|
'Authorization' => Configuration.authorization,
|
268
268
|
'Authorization' => authorization
|
269
269
|
}
|
270
270
|
|
271
271
|
# prepare and execute HttpRequest
|
272
|
-
_request = @http_client.
|
272
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: create_resource_body.to_json
|
273
273
|
CustomAuth.apply(_request)
|
274
274
|
_context = execute_request(_request)
|
275
275
|
|
@@ -280,8 +280,8 @@ module Gonebusy
|
|
280
280
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
281
281
|
elsif _context.response.status_code == 403
|
282
282
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
283
|
-
elsif _context.response.status_code ==
|
284
|
-
raise EntitiesErrorErrorException.new '
|
283
|
+
elsif _context.response.status_code == 422
|
284
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
285
285
|
elsif !_context.response.status_code.between?(200, 208)
|
286
286
|
raise APIException.new 'Unexpected error', _context
|
287
287
|
end
|
@@ -289,7 +289,7 @@ module Gonebusy
|
|
289
289
|
|
290
290
|
# return appropriate response type
|
291
291
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
292
|
-
return
|
292
|
+
return CreateResourceResponse.from_hash(decoded)
|
293
293
|
end
|
294
294
|
end
|
295
295
|
end
|