gonebusy-ruby-client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c62797dc25aa9288b06855875b09ed9a9f4ad612
|
4
|
+
data.tar.gz: 67900e0d872101c9dca554659bc939d1d7639928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30828290bb4650af1c282ccac9b978ea4a72db5586e15020546d3986371b6b0777d6956ed1748450e96f178721c50679c9767c56554e1e1c1119f2f04a27fad3
|
7
|
+
data.tar.gz: c34051538ef315e41336239b538ccc66418c68d47193b1cdc288bc7b99e913cab704533b862f4e295adb65c825158bc567c3adcf66bf0f9472e1a5bb533e9835
|
data/LICENSE
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
The MIT License (MIT)
|
4
4
|
http://opensource.org/licenses/MIT
|
5
5
|
|
6
|
-
Copyright (c) 2016 - GoneBusy Inc.
|
6
|
+
Copyright (c) 2016-2017 - GoneBusy Inc.
|
7
7
|
|
8
8
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
9
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -139,7 +139,8 @@ def get_bookings(options = Hash.new); end
|
|
139
139
|
| page | ``` Optional ``` ``` DefaultValue ``` | Page offset to fetch. |
|
140
140
|
| per_page | ``` Optional ``` ``` DefaultValue ``` | Number of results to return per page. |
|
141
141
|
| states | ``` Optional ``` | Comma-separated list of Booking states to retrieve only Bookings in those states. Leave blank to retrieve all Bookings. |
|
142
|
-
| user_id | ``` Optional ``` | Retrieve Bookings owned
|
142
|
+
| user_id | ``` Optional ``` | Retrieve Bookings for Resources/Services owned by this User Id. You must be authorized to manage this User Id. |
|
143
|
+
| booker_id | ``` Optional ``` | Retrieve Bookings make by Booker Id. |
|
143
144
|
|
144
145
|
|
145
146
|
#### Example Usage
|
@@ -8,27 +8,29 @@ module Gonebusy
|
|
8
8
|
@@instance
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
11
|
+
# Cancel a Booking by id
|
12
12
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
-
# @param [
|
14
|
-
# @param [
|
15
|
-
# @param [
|
16
|
-
# @param [
|
17
|
-
# @return
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
# @param [String] id Required parameter: Example:
|
14
|
+
# @param [Date] date Optional parameter: If a recurring booking, the date of an instance to cancel. Several formats are supported: '2014-10-31', 'October 31, 2014'
|
15
|
+
# @param [Date] end_date Optional parameter: If recurring, cancel up to :end_date or leave blank for infinite booking. Several formats are supported: '2014-10-31', 'October 31, 2014'.
|
16
|
+
# @param [String] cancel_recurring Optional parameter: When a recurring booking, one of: ['instance', 'all', 'infinite']
|
17
|
+
# @return CancelBookingByIdResponse response from the API call
|
18
|
+
def cancel_booking_by_id(authorization,
|
19
|
+
id,
|
20
|
+
date = nil,
|
21
|
+
end_date = nil,
|
22
|
+
cancel_recurring = nil)
|
23
23
|
|
24
24
|
# prepare query url
|
25
25
|
_query_builder = Configuration.get_base_uri()
|
26
|
-
_query_builder << '/bookings'
|
26
|
+
_query_builder << '/bookings/{id}'
|
27
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
28
|
+
'id' => id
|
29
|
+
}
|
27
30
|
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'user_id' => user_id
|
31
|
+
'date' => date,
|
32
|
+
'end_date' => end_date,
|
33
|
+
'cancel_recurring' => cancel_recurring
|
32
34
|
}, array_serialization: Configuration.array_serialization
|
33
35
|
_query_url = APIHelper.clean_url _query_builder
|
34
36
|
|
@@ -40,12 +42,14 @@ module Gonebusy
|
|
40
42
|
}
|
41
43
|
|
42
44
|
# prepare and execute HttpRequest
|
43
|
-
_request = @http_client.
|
45
|
+
_request = @http_client.delete _query_url, headers: _headers
|
44
46
|
CustomAuth.apply(_request)
|
45
47
|
_context = execute_request(_request)
|
46
48
|
|
47
49
|
# validate response against endpoint and global error codes
|
48
|
-
if _context.response.status_code ==
|
50
|
+
if _context.response.status_code == 400
|
51
|
+
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
52
|
+
elsif _context.response.status_code == 401
|
49
53
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
50
54
|
elsif _context.response.status_code == 403
|
51
55
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
@@ -58,43 +62,55 @@ module Gonebusy
|
|
58
62
|
|
59
63
|
# return appropriate response type
|
60
64
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
61
|
-
return
|
65
|
+
return CancelBookingByIdResponse.from_hash(decoded)
|
62
66
|
end
|
63
67
|
|
64
|
-
#
|
68
|
+
# Return list of Bookings.
|
65
69
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
66
|
-
# @param [
|
67
|
-
# @
|
68
|
-
|
69
|
-
|
70
|
+
# @param [Integer] user_id Optional parameter: Retrieve Bookings for Resources/Services owned by this User Id. You must be authorized to manage this User Id.
|
71
|
+
# @param [String] states Optional parameter: Comma-separated list of Booking states to retrieve only Bookings in those states. Leave blank to retrieve all Bookings.
|
72
|
+
# @param [Integer] booker_id Optional parameter: Retrieve Bookings made by Booker Id. Only Bookings for Services/Resources you are authorized to manage will be returned.
|
73
|
+
# @param [Integer] page Optional parameter: Page offset to fetch.
|
74
|
+
# @param [Integer] per_page Optional parameter: Number of results to return per page.
|
75
|
+
# @return GetBookingsResponse response from the API call
|
76
|
+
def get_bookings(authorization,
|
77
|
+
user_id = nil,
|
78
|
+
states = nil,
|
79
|
+
booker_id = nil,
|
80
|
+
page = 1,
|
81
|
+
per_page = 10)
|
70
82
|
|
71
83
|
# prepare query url
|
72
84
|
_query_builder = Configuration.get_base_uri()
|
73
|
-
_query_builder << '/bookings
|
85
|
+
_query_builder << '/bookings'
|
86
|
+
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
87
|
+
'user_id' => user_id,
|
88
|
+
'states' => states,
|
89
|
+
'booker_id' => booker_id,
|
90
|
+
'page' => page,
|
91
|
+
'per_page' => per_page
|
92
|
+
}, array_serialization: Configuration.array_serialization
|
74
93
|
_query_url = APIHelper.clean_url _query_builder
|
75
94
|
|
76
95
|
# prepare headers
|
77
96
|
_headers = {
|
78
97
|
'accept' => 'application/json',
|
79
|
-
'content-type' => 'application/json; charset=utf-8',
|
80
98
|
'Authorization' => Configuration.authorization,
|
81
99
|
'Authorization' => authorization
|
82
100
|
}
|
83
101
|
|
84
102
|
# prepare and execute HttpRequest
|
85
|
-
_request = @http_client.
|
103
|
+
_request = @http_client.get _query_url, headers: _headers
|
86
104
|
CustomAuth.apply(_request)
|
87
105
|
_context = execute_request(_request)
|
88
106
|
|
89
107
|
# validate response against endpoint and global error codes
|
90
|
-
if _context.response.status_code ==
|
91
|
-
raise EntitiesErrorErrorException.new 'Bad Request', _context
|
92
|
-
elsif _context.response.status_code == 401
|
108
|
+
if _context.response.status_code == 401
|
93
109
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
94
110
|
elsif _context.response.status_code == 403
|
95
111
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
96
|
-
elsif _context.response.status_code ==
|
97
|
-
raise EntitiesErrorErrorException.new '
|
112
|
+
elsif _context.response.status_code == 404
|
113
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
98
114
|
elsif !_context.response.status_code.between?(200, 208)
|
99
115
|
raise APIException.new 'Unexpected error', _context
|
100
116
|
end
|
@@ -102,15 +118,17 @@ module Gonebusy
|
|
102
118
|
|
103
119
|
# return appropriate response type
|
104
120
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
105
|
-
return
|
121
|
+
return GetBookingsResponse.from_hash(decoded)
|
106
122
|
end
|
107
123
|
|
108
|
-
#
|
124
|
+
# Update a Booking by id
|
109
125
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
110
126
|
# @param [String] id Required parameter: Example:
|
111
|
-
# @
|
112
|
-
|
113
|
-
|
127
|
+
# @param [UpdateBookingByIdBody] update_booking_by_id_body Optional parameter: the content of the request
|
128
|
+
# @return UpdateBookingByIdResponse response from the API call
|
129
|
+
def update_booking_by_id(authorization,
|
130
|
+
id,
|
131
|
+
update_booking_by_id_body = nil)
|
114
132
|
|
115
133
|
# prepare query url
|
116
134
|
_query_builder = Configuration.get_base_uri()
|
@@ -123,12 +141,13 @@ module Gonebusy
|
|
123
141
|
# prepare headers
|
124
142
|
_headers = {
|
125
143
|
'accept' => 'application/json',
|
144
|
+
'content-type' => 'application/json; charset=utf-8',
|
126
145
|
'Authorization' => Configuration.authorization,
|
127
146
|
'Authorization' => authorization
|
128
147
|
}
|
129
148
|
|
130
149
|
# prepare and execute HttpRequest
|
131
|
-
_request = @http_client.
|
150
|
+
_request = @http_client.put _query_url, headers: _headers, parameters: update_booking_by_id_body.to_json
|
132
151
|
CustomAuth.apply(_request)
|
133
152
|
_context = execute_request(_request)
|
134
153
|
|
@@ -141,6 +160,8 @@ module Gonebusy
|
|
141
160
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
142
161
|
elsif _context.response.status_code == 404
|
143
162
|
raise EntitiesErrorErrorException.new 'Not Found', _context
|
163
|
+
elsif _context.response.status_code == 422
|
164
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
144
165
|
elsif !_context.response.status_code.between?(200, 208)
|
145
166
|
raise APIException.new 'Unexpected error', _context
|
146
167
|
end
|
@@ -148,17 +169,15 @@ module Gonebusy
|
|
148
169
|
|
149
170
|
# return appropriate response type
|
150
171
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
151
|
-
return
|
172
|
+
return UpdateBookingByIdResponse.from_hash(decoded)
|
152
173
|
end
|
153
174
|
|
154
|
-
#
|
175
|
+
# Return a Booking by id.
|
155
176
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
156
177
|
# @param [String] id Required parameter: Example:
|
157
|
-
# @
|
158
|
-
|
159
|
-
|
160
|
-
id,
|
161
|
-
update_booking_by_id_body = nil)
|
178
|
+
# @return GetBookingByIdResponse response from the API call
|
179
|
+
def get_booking_by_id(authorization,
|
180
|
+
id)
|
162
181
|
|
163
182
|
# prepare query url
|
164
183
|
_query_builder = Configuration.get_base_uri()
|
@@ -171,13 +190,12 @@ module Gonebusy
|
|
171
190
|
# prepare headers
|
172
191
|
_headers = {
|
173
192
|
'accept' => 'application/json',
|
174
|
-
'content-type' => 'application/json; charset=utf-8',
|
175
193
|
'Authorization' => Configuration.authorization,
|
176
194
|
'Authorization' => authorization
|
177
195
|
}
|
178
196
|
|
179
197
|
# prepare and execute HttpRequest
|
180
|
-
_request = @http_client.
|
198
|
+
_request = @http_client.get _query_url, headers: _headers
|
181
199
|
CustomAuth.apply(_request)
|
182
200
|
_context = execute_request(_request)
|
183
201
|
|
@@ -190,8 +208,6 @@ module Gonebusy
|
|
190
208
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
191
209
|
elsif _context.response.status_code == 404
|
192
210
|
raise EntitiesErrorErrorException.new 'Not Found', _context
|
193
|
-
elsif _context.response.status_code == 422
|
194
|
-
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
195
211
|
elsif !_context.response.status_code.between?(200, 208)
|
196
212
|
raise APIException.new 'Unexpected error', _context
|
197
213
|
end
|
@@ -199,44 +215,31 @@ module Gonebusy
|
|
199
215
|
|
200
216
|
# return appropriate response type
|
201
217
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
202
|
-
return
|
218
|
+
return GetBookingByIdResponse.from_hash(decoded)
|
203
219
|
end
|
204
220
|
|
205
|
-
#
|
221
|
+
# Create a Booking with params
|
206
222
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
207
|
-
# @param [
|
208
|
-
# @
|
209
|
-
|
210
|
-
|
211
|
-
# @return CancelBookingByIdResponse response from the API call
|
212
|
-
def cancel_booking_by_id(authorization,
|
213
|
-
id,
|
214
|
-
cancel_recurring = nil,
|
215
|
-
date = nil,
|
216
|
-
end_date = nil)
|
223
|
+
# @param [CreateBookingBody] create_booking_body Optional parameter: the content of the request
|
224
|
+
# @return CreateBookingResponse response from the API call
|
225
|
+
def create_booking(authorization,
|
226
|
+
create_booking_body = nil)
|
217
227
|
|
218
228
|
# prepare query url
|
219
229
|
_query_builder = Configuration.get_base_uri()
|
220
|
-
_query_builder << '/bookings/
|
221
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
222
|
-
'id' => id
|
223
|
-
}
|
224
|
-
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
225
|
-
'cancel_recurring' => cancel_recurring,
|
226
|
-
'date' => date,
|
227
|
-
'end_date' => end_date
|
228
|
-
}, array_serialization: Configuration.array_serialization
|
230
|
+
_query_builder << '/bookings/new'
|
229
231
|
_query_url = APIHelper.clean_url _query_builder
|
230
232
|
|
231
233
|
# prepare headers
|
232
234
|
_headers = {
|
233
235
|
'accept' => 'application/json',
|
236
|
+
'content-type' => 'application/json; charset=utf-8',
|
234
237
|
'Authorization' => Configuration.authorization,
|
235
238
|
'Authorization' => authorization
|
236
239
|
}
|
237
240
|
|
238
241
|
# prepare and execute HttpRequest
|
239
|
-
_request = @http_client.
|
242
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: create_booking_body.to_json
|
240
243
|
CustomAuth.apply(_request)
|
241
244
|
_context = execute_request(_request)
|
242
245
|
|
@@ -247,8 +250,8 @@ module Gonebusy
|
|
247
250
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
248
251
|
elsif _context.response.status_code == 403
|
249
252
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
250
|
-
elsif _context.response.status_code ==
|
251
|
-
raise EntitiesErrorErrorException.new '
|
253
|
+
elsif _context.response.status_code == 422
|
254
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
252
255
|
elsif !_context.response.status_code.between?(200, 208)
|
253
256
|
raise APIException.new 'Unexpected error', _context
|
254
257
|
end
|
@@ -256,7 +259,7 @@ module Gonebusy
|
|
256
259
|
|
257
260
|
# return appropriate response type
|
258
261
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
259
|
-
return
|
262
|
+
return CreateBookingResponse.from_hash(decoded)
|
260
263
|
end
|
261
264
|
end
|
262
265
|
end
|
@@ -10,22 +10,22 @@ module Gonebusy
|
|
10
10
|
|
11
11
|
# Return list of Categories.
|
12
12
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
13
|
+
# @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.
|
13
14
|
# @param [Integer] page Optional parameter: Page offset to fetch.
|
14
15
|
# @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
16
|
# @return GetCategoriesResponse response from the API call
|
17
17
|
def get_categories(authorization,
|
18
|
+
user_id = nil,
|
18
19
|
page = 1,
|
19
|
-
per_page = 10
|
20
|
-
user_id = nil)
|
20
|
+
per_page = 10)
|
21
21
|
|
22
22
|
# prepare query url
|
23
23
|
_query_builder = Configuration.get_base_uri()
|
24
24
|
_query_builder << '/categories'
|
25
25
|
_query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
|
26
|
+
'user_id' => user_id,
|
26
27
|
'page' => page,
|
27
|
-
'per_page' => per_page
|
28
|
-
'user_id' => user_id
|
28
|
+
'per_page' => per_page
|
29
29
|
}, array_serialization: Configuration.array_serialization
|
30
30
|
_query_url = APIHelper.clean_url _query_builder
|
31
31
|
|
@@ -58,28 +58,30 @@ module Gonebusy
|
|
58
58
|
return GetCategoriesResponse.from_hash(decoded)
|
59
59
|
end
|
60
60
|
|
61
|
-
#
|
61
|
+
# Return a Category by id.
|
62
62
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
63
|
-
# @param [
|
64
|
-
# @return
|
65
|
-
def
|
66
|
-
|
63
|
+
# @param [String] id Required parameter: Example:
|
64
|
+
# @return GetCategoryByIdResponse response from the API call
|
65
|
+
def get_category_by_id(authorization,
|
66
|
+
id)
|
67
67
|
|
68
68
|
# prepare query url
|
69
69
|
_query_builder = Configuration.get_base_uri()
|
70
|
-
_query_builder << '/categories/
|
70
|
+
_query_builder << '/categories/{id}'
|
71
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
72
|
+
'id' => id
|
73
|
+
}
|
71
74
|
_query_url = APIHelper.clean_url _query_builder
|
72
75
|
|
73
76
|
# prepare headers
|
74
77
|
_headers = {
|
75
78
|
'accept' => 'application/json',
|
76
|
-
'content-type' => 'application/json; charset=utf-8',
|
77
79
|
'Authorization' => Configuration.authorization,
|
78
80
|
'Authorization' => authorization
|
79
81
|
}
|
80
82
|
|
81
83
|
# prepare and execute HttpRequest
|
82
|
-
_request = @http_client.
|
84
|
+
_request = @http_client.get _query_url, headers: _headers
|
83
85
|
CustomAuth.apply(_request)
|
84
86
|
_context = execute_request(_request)
|
85
87
|
|
@@ -90,8 +92,8 @@ module Gonebusy
|
|
90
92
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
91
93
|
elsif _context.response.status_code == 403
|
92
94
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
93
|
-
elsif _context.response.status_code ==
|
94
|
-
raise EntitiesErrorErrorException.new '
|
95
|
+
elsif _context.response.status_code == 404
|
96
|
+
raise EntitiesErrorErrorException.new 'Not Found', _context
|
95
97
|
elsif !_context.response.status_code.between?(200, 208)
|
96
98
|
raise APIException.new 'Unexpected error', _context
|
97
99
|
end
|
@@ -99,33 +101,31 @@ module Gonebusy
|
|
99
101
|
|
100
102
|
# return appropriate response type
|
101
103
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
102
|
-
return
|
104
|
+
return GetCategoryByIdResponse.from_hash(decoded)
|
103
105
|
end
|
104
106
|
|
105
|
-
#
|
107
|
+
# Create a Category
|
106
108
|
# @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
|
107
|
-
# @param [
|
108
|
-
# @return
|
109
|
-
def
|
110
|
-
|
109
|
+
# @param [CreateCategoryBody] create_category_body Optional parameter: the content of the request
|
110
|
+
# @return CreateCategoryResponse response from the API call
|
111
|
+
def create_category(authorization,
|
112
|
+
create_category_body = nil)
|
111
113
|
|
112
114
|
# prepare query url
|
113
115
|
_query_builder = Configuration.get_base_uri()
|
114
|
-
_query_builder << '/categories/
|
115
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
116
|
-
'id' => id
|
117
|
-
}
|
116
|
+
_query_builder << '/categories/new'
|
118
117
|
_query_url = APIHelper.clean_url _query_builder
|
119
118
|
|
120
119
|
# prepare headers
|
121
120
|
_headers = {
|
122
121
|
'accept' => 'application/json',
|
122
|
+
'content-type' => 'application/json; charset=utf-8',
|
123
123
|
'Authorization' => Configuration.authorization,
|
124
124
|
'Authorization' => authorization
|
125
125
|
}
|
126
126
|
|
127
127
|
# prepare and execute HttpRequest
|
128
|
-
_request = @http_client.
|
128
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: create_category_body.to_json
|
129
129
|
CustomAuth.apply(_request)
|
130
130
|
_context = execute_request(_request)
|
131
131
|
|
@@ -136,8 +136,8 @@ module Gonebusy
|
|
136
136
|
raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
|
137
137
|
elsif _context.response.status_code == 403
|
138
138
|
raise EntitiesErrorErrorException.new 'Forbidden', _context
|
139
|
-
elsif _context.response.status_code ==
|
140
|
-
raise EntitiesErrorErrorException.new '
|
139
|
+
elsif _context.response.status_code == 422
|
140
|
+
raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
|
141
141
|
elsif !_context.response.status_code.between?(200, 208)
|
142
142
|
raise APIException.new 'Unexpected error', _context
|
143
143
|
end
|
@@ -145,7 +145,7 @@ module Gonebusy
|
|
145
145
|
|
146
146
|
# return appropriate response type
|
147
147
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
148
|
-
return
|
148
|
+
return CreateCategoryResponse.from_hash(decoded)
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|