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.
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,16 +1,51 @@
1
- module Gonebusy
2
- class Configuration
3
- # The base Uri for API calls
4
- @base_uri = 'https://beta.gonebusy.com/api/v1'
5
-
6
- # Set Authorization to "Token <your API key>"
7
- @authorization = 'Token <your API key>'
8
-
9
- # The attribute accessors for public properties
10
- class << self
11
- attr_accessor :base_uri
12
- attr_accessor :authorization
13
- end
14
-
15
- end
16
- end
1
+ # This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module Gonebusy
4
+ class Configuration
5
+ # Set the array parameter serialization method
6
+ # (allowed: indexed, unindexed, plain, csv, tsv, psv)
7
+ @array_serialization = 'indexed'
8
+
9
+ # An enum for SDK environments
10
+ class Environment
11
+ #SANDBOX: https://sandbox.gonebusy.com/api/v1
12
+ ENVIRONMENT = [PRODUCTION = 0, SANDBOX = 1]
13
+ end
14
+
15
+ # An enum for API servers
16
+ class Server
17
+ SERVER = [DEFAULT = 0]
18
+ end
19
+
20
+ # The environment in which the SDK is running
21
+ @environment = Environment::PRODUCTION
22
+
23
+ # Set Authorization to "Token <your API key>"
24
+ @authorization = 'Token <your API key>'
25
+
26
+ # All the environments the SDK can run in
27
+ @environments = {
28
+ Environment::PRODUCTION => {
29
+ Server::DEFAULT => 'https://beta.gonebusy.com/api/v1',
30
+ },
31
+ Environment::SANDBOX => {
32
+ Server::DEFAULT => 'https://sandbox.gonebusy.com/api/v1',
33
+ },
34
+ }
35
+
36
+ # Generates the appropriate base URI for the environment and the server.
37
+ # @param [Configuration::Server] The server enum for which the base URI is required.
38
+ # @return [String] The base URI.
39
+ def self.get_base_uri(server = Server::DEFAULT)
40
+ environments[environment][server]
41
+ end
42
+
43
+ # The attribute accessors for public properties
44
+ class << self
45
+ attr_accessor :array_serialization
46
+ attr_accessor :environment
47
+ attr_accessor :environments
48
+ attr_accessor :authorization
49
+ end
50
+ end
51
+ end
@@ -1,45 +1,46 @@
1
- # This file was automatically generated for GoneBusy Inc. by APIMATIC v2.0 ( https://apimatic.io ).
2
-
3
- module Gonebusy
4
- class BaseController
5
- attr_accessor :http_client, :http_call_back
6
-
7
- @@http_client = FaradayClient.new(60)
8
-
9
- @@global_headers = {
10
- 'user-agent' => 'APIMATIC 2.0'
11
- }
12
-
13
- def initialize(http_client: nil, http_call_back: nil)
14
- @http_client = http_client ||= @@http_client
15
- @http_call_back = http_call_back
16
- end
17
-
18
- def validate_parameters(args)
19
- args.each do |name, value|
20
- if value == nil
21
- raise ArgumentError.new "Required parameter #{name} cannot be nil."
22
- end
23
- end
24
- end
25
-
26
- def execute_request(request, binary: false)
27
- @http_call_back.on_before_request(request) if @http_call_back
28
-
29
- request.headers = @@global_headers.clone.merge(request.headers)
30
-
31
- response = binary ? @http_client.execute_as_binary(request) : @http_client.execute_as_string(request)
32
- context = HttpContext.new(request, response)
33
-
34
- @http_call_back.on_after_response(context) if @http_call_back
35
-
36
- return context
37
- end
38
-
39
- def validate_response(context)
40
- if !context.response.status_code.between?(200, 208) #[200,208] = HTTP OK
41
- raise APIException.new 'HTTP Response Not OK', context
42
- end
43
- end
44
- end
45
- end
1
+ # This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module Gonebusy
4
+ class BaseController
5
+ attr_accessor :http_client, :http_call_back
6
+
7
+ @@http_client = FaradayClient.new
8
+
9
+ @@global_headers = {
10
+ 'user-agent' => 'APIMATIC 2.0'
11
+ }
12
+
13
+ def initialize(http_client: nil, http_call_back: nil)
14
+ @http_client = http_client ||= @@http_client
15
+ @http_call_back = http_call_back
16
+ end
17
+
18
+ def validate_parameters(args)
19
+ args.each do |_name, value|
20
+ if value.nil?
21
+ raise ArgumentError.new 'Required parameter #{name} cannot be nil.'
22
+ end
23
+ end
24
+ end
25
+
26
+ def execute_request(request, binary: false)
27
+ @http_call_back.on_before_request(request) if @http_call_back
28
+
29
+ APIHelper.clean_hash(request.headers)
30
+ request.headers = @@global_headers.clone.merge(request.headers)
31
+
32
+ response = binary ? @http_client.execute_as_binary(request) : @http_client.execute_as_string(request)
33
+ context = HttpContext.new(request, response)
34
+
35
+ @http_call_back.on_after_response(context) if @http_call_back
36
+
37
+ return context
38
+ end
39
+
40
+ def validate_response(context)
41
+ if !context.response.status_code.between?(200, 208) #[200,208] = HTTP OK
42
+ raise APIException.new 'HTTP Response Not OK', context
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,298 +1,262 @@
1
- # This file was automatically generated for GoneBusy Inc. by APIMATIC v2.0 ( https://apimatic.io ).
2
-
3
- module Gonebusy
4
- class BookingsController < BaseController
5
- @@instance = BookingsController.new
6
- # Singleton instance of the controller class
7
- def self.instance
8
- @@instance
9
- end
10
-
11
- # Create a Booking with params
12
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
13
- # @param [CreateBookingBody] create_booking_body Required parameter: the content of the request
14
- # @return CreateBookingResponse response from the API call
15
- def create_booking(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 << '/bookings/new'
22
-
23
- # validate and preprocess url
24
- _query_url = APIHelper.clean_url _query_builder
25
-
26
- # prepare headers
27
- _headers = {
28
- 'accept' => 'application/json',
29
- 'content-type' => 'application/json; charset=utf-8',
30
- 'Authorization' => Configuration.authorization,
31
- 'Authorization' => options['authorization']
32
- }
1
+ # This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
33
2
 
34
- # create the HttpRequest object for the call
35
- _request = @http_client.post _query_url, headers: _headers, parameters: options['create_booking_body'].to_json
36
-
37
- # apply authentication
38
- CustomAuth.apply(_request)
39
-
40
- # execute the request
41
- _context = execute_request(_request)
42
-
43
- # endpoint error handling using HTTP status codes.
44
- if _context.response.status_code == 400
45
- raise EntitiesErrorException.new '400 - Bad Request', _context
46
- elsif _context.response.status_code == 401
47
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
48
- elsif _context.response.status_code == 403
49
- raise EntitiesErrorException.new '403 - Forbidden', _context
50
- elsif _context.response.status_code == 422
51
- raise EntitiesErrorException.new '422 - Unprocessable Entity', _context
52
- elsif _context.response.status_code == 500
53
- raise APIException.new '500 - Unexpected error', _context
54
- end
55
-
56
- # global error handling using HTTP status codes.
57
- validate_response(_context)
58
-
59
- # return appropriate response type
60
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
61
- return CreateBookingResponse.from_hash(decoded)
62
- end
63
-
64
- # Return list of Bookings.
65
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
66
- # @param [Integer] page Optional parameter: Page offset to fetch.
67
- # @param [Integer] per_page Optional parameter: Number of results to return per page.
68
- # @param [String] states Optional parameter: Comma-separated list of Booking states to retrieve only Bookings in those states. Leave blank to retrieve all Bookings.
69
- # @param [Integer] user_id Optional parameter: Retrieve Bookings owned only by this User Id. You must be authorized to manage this User Id.
70
- # @return GetBookingsResponse response from the API call
71
- def get_bookings(options = Hash.new)
72
-
73
- # the base uri for api requests
74
- _query_builder = Configuration.base_uri.dup
75
-
76
- # prepare query string for API call
77
- _query_builder << '/bookings'
78
-
79
- # process optional query parameters
80
- _query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
81
- 'page' => options['page'],
82
- 'per_page' => options['per_page'],
83
- 'states' => options['states'],
84
- 'user_id' => options['user_id']
85
- }
86
-
87
- # validate and preprocess url
88
- _query_url = APIHelper.clean_url _query_builder
89
-
90
- # prepare headers
91
- _headers = {
92
- 'accept' => 'application/json',
93
- 'Authorization' => Configuration.authorization,
94
- 'Authorization' => options['authorization']
95
- }
3
+ module Gonebusy
4
+ class BookingsController < BaseController
5
+ @@instance = BookingsController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
96
10
 
97
- # create the HttpRequest object for the call
98
- _request = @http_client.get _query_url, headers: _headers
99
-
100
- # apply authentication
101
- CustomAuth.apply(_request)
102
-
103
- # execute the request
104
- _context = execute_request(_request)
105
-
106
- # endpoint error handling using HTTP status codes.
107
- if _context.response.status_code == 401
108
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
109
- elsif _context.response.status_code == 403
110
- raise EntitiesErrorException.new '403 - Forbidden', _context
111
- elsif _context.response.status_code == 404
112
- raise EntitiesErrorException.new '404 - Not Found', _context
113
- elsif _context.response.status_code == 500
114
- raise APIException.new '500 - Unexpected error', _context
115
- end
116
-
117
- # global error handling using HTTP status codes.
118
- validate_response(_context)
119
-
120
- # return appropriate response type
121
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
122
- return GetBookingsResponse.from_hash(decoded)
123
- end
124
-
125
- # Cancel a Booking by id
126
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
127
- # @param [String] id Required parameter: Example:
128
- # @return CancelBookingByIdResponse response from the API call
129
- def cancel_booking_by_id(options = Hash.new)
130
-
131
- # the base uri for api requests
132
- _query_builder = Configuration.base_uri.dup
133
-
134
- # prepare query string for API call
135
- _query_builder << '/bookings/{id}'
136
-
137
- # process optional query parameters
138
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
139
- 'id' => options['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
- }
11
+ # Return list of Bookings.
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 [String] states Optional parameter: Comma-separated list of Booking states to retrieve only Bookings in those states. Leave blank to retrieve all Bookings.
16
+ # @param [Integer] user_id Optional parameter: Retrieve Bookings owned only by this User Id. You must be authorized to manage this User Id.
17
+ # @return GetBookingsResponse response from the API call
18
+ def get_bookings(authorization,
19
+ page = 1,
20
+ per_page = 10,
21
+ states = nil,
22
+ user_id = nil)
151
23
 
152
- # create the HttpRequest object for the call
153
- _request = @http_client.delete _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 == 404
169
- raise EntitiesErrorException.new '404 - Not Found', _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 CancelBookingByIdResponse.from_hash(decoded)
180
- end
181
-
182
- # Update a Booking by id
183
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
184
- # @param [String] id Required parameter: Example:
185
- # @return UpdateBookingByIdResponse response from the API call
186
- def update_booking_by_id(options = Hash.new)
187
-
188
- # the base uri for api requests
189
- _query_builder = Configuration.base_uri.dup
190
-
191
- # prepare query string for API call
192
- _query_builder << '/bookings/{id}'
193
-
194
- # process optional query parameters
195
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
196
- 'id' => options['id']
197
- }
198
-
199
- # validate and preprocess url
200
- _query_url = APIHelper.clean_url _query_builder
201
-
202
- # prepare headers
203
- _headers = {
204
- 'accept' => 'application/json',
205
- 'Authorization' => Configuration.authorization,
206
- 'Authorization' => options['authorization']
207
- }
24
+ # prepare query url
25
+ _query_builder = Configuration.get_base_uri()
26
+ _query_builder << '/bookings'
27
+ _query_builder = APIHelper.append_url_with_query_parameters _query_builder, {
28
+ 'page' => page,
29
+ 'per_page' => per_page,
30
+ 'states' => states,
31
+ 'user_id' => user_id
32
+ }, array_serialization: Configuration.array_serialization
33
+ _query_url = APIHelper.clean_url _query_builder
208
34
 
209
- # create the HttpRequest object for the call
210
- _request = @http_client.put _query_url, headers: _headers
211
-
212
- # apply authentication
213
- CustomAuth.apply(_request)
214
-
215
- # execute the request
216
- _context = execute_request(_request)
217
-
218
- # endpoint error handling using HTTP status codes.
219
- if _context.response.status_code == 400
220
- raise EntitiesErrorException.new '400 - Bad Request', _context
221
- elsif _context.response.status_code == 401
222
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
223
- elsif _context.response.status_code == 403
224
- raise EntitiesErrorException.new '403 - Forbidden', _context
225
- elsif _context.response.status_code == 404
226
- raise EntitiesErrorException.new '404 - Not Found', _context
227
- elsif _context.response.status_code == 422
228
- raise EntitiesErrorException.new '422 - Unprocessable Entity', _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 UpdateBookingByIdResponse.from_hash(decoded)
239
- end
240
-
241
- # Return a Booking by id.
242
- # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
243
- # @param [String] id Required parameter: Example:
244
- # @return GetBookingByIdResponse response from the API call
245
- def get_booking_by_id(options = Hash.new)
246
-
247
- # the base uri for api requests
248
- _query_builder = Configuration.base_uri.dup
249
-
250
- # prepare query string for API call
251
- _query_builder << '/bookings/{id}'
252
-
253
- # process optional query parameters
254
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
255
- 'id' => options['id']
256
- }
257
-
258
- # validate and preprocess url
259
- _query_url = APIHelper.clean_url _query_builder
260
-
261
- # prepare headers
262
- _headers = {
263
- 'accept' => 'application/json',
264
- 'Authorization' => Configuration.authorization,
265
- 'Authorization' => options['authorization']
266
- }
35
+ # prepare headers
36
+ _headers = {
37
+ 'accept' => 'application/json',
38
+ 'Authorization' => Configuration.authorization,
39
+ 'Authorization' => authorization
40
+ }
267
41
 
268
- # create the HttpRequest object for the call
269
- _request = @http_client.get _query_url, headers: _headers
270
-
271
- # apply authentication
272
- CustomAuth.apply(_request)
273
-
274
- # execute the request
275
- _context = execute_request(_request)
276
-
277
- # endpoint error handling using HTTP status codes.
278
- if _context.response.status_code == 400
279
- raise EntitiesErrorException.new '400 - Bad Request', _context
280
- elsif _context.response.status_code == 401
281
- raise EntitiesErrorException.new '401 - Unauthorized/Missing Token', _context
282
- elsif _context.response.status_code == 403
283
- raise EntitiesErrorException.new '403 - Forbidden', _context
284
- elsif _context.response.status_code == 404
285
- raise EntitiesErrorException.new '404 - Not Found', _context
286
- elsif _context.response.status_code == 500
287
- raise APIException.new '500 - Unexpected error', _context
288
- end
289
-
290
- # global error handling using HTTP status codes.
291
- validate_response(_context)
292
-
293
- # return appropriate response type
294
- decoded = APIHelper.json_deserialize(_context.response.raw_body)
295
- return GetBookingByIdResponse.from_hash(decoded)
296
- end
297
- end
298
- end
42
+ # prepare and execute HttpRequest
43
+ _request = @http_client.get _query_url, headers: _headers
44
+ CustomAuth.apply(_request)
45
+ _context = execute_request(_request)
46
+
47
+ # validate response against endpoint and global error codes
48
+ if _context.response.status_code == 401
49
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
50
+ elsif _context.response.status_code == 403
51
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
52
+ elsif _context.response.status_code == 404
53
+ raise EntitiesErrorErrorException.new 'Not Found', _context
54
+ elsif !_context.response.status_code.between?(200, 208)
55
+ raise APIException.new 'Unexpected error', _context
56
+ end
57
+ validate_response(_context)
58
+
59
+ # return appropriate response type
60
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
61
+ return GetBookingsResponse.from_hash(decoded)
62
+ end
63
+
64
+ # Create a Booking with params
65
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
66
+ # @param [CreateBookingBody] create_booking_body Optional parameter: the content of the request
67
+ # @return CreateBookingResponse response from the API call
68
+ def create_booking(authorization,
69
+ create_booking_body = nil)
70
+
71
+ # prepare query url
72
+ _query_builder = Configuration.get_base_uri()
73
+ _query_builder << '/bookings/new'
74
+ _query_url = APIHelper.clean_url _query_builder
75
+
76
+ # prepare headers
77
+ _headers = {
78
+ 'accept' => 'application/json',
79
+ 'content-type' => 'application/json; charset=utf-8',
80
+ 'Authorization' => Configuration.authorization,
81
+ 'Authorization' => authorization
82
+ }
83
+
84
+ # prepare and execute HttpRequest
85
+ _request = @http_client.post _query_url, headers: _headers, parameters: create_booking_body.to_json
86
+ CustomAuth.apply(_request)
87
+ _context = execute_request(_request)
88
+
89
+ # validate response against endpoint and global error codes
90
+ if _context.response.status_code == 400
91
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
92
+ elsif _context.response.status_code == 401
93
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
94
+ elsif _context.response.status_code == 403
95
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
96
+ elsif _context.response.status_code == 422
97
+ raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
98
+ elsif !_context.response.status_code.between?(200, 208)
99
+ raise APIException.new 'Unexpected error', _context
100
+ end
101
+ validate_response(_context)
102
+
103
+ # return appropriate response type
104
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
105
+ return CreateBookingResponse.from_hash(decoded)
106
+ end
107
+
108
+ # Return a Booking by id.
109
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
110
+ # @param [String] id Required parameter: Example:
111
+ # @return GetBookingByIdResponse response from the API call
112
+ def get_booking_by_id(authorization,
113
+ id)
114
+
115
+ # prepare query url
116
+ _query_builder = Configuration.get_base_uri()
117
+ _query_builder << '/bookings/{id}'
118
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
119
+ 'id' => id
120
+ }
121
+ _query_url = APIHelper.clean_url _query_builder
122
+
123
+ # prepare headers
124
+ _headers = {
125
+ 'accept' => 'application/json',
126
+ 'Authorization' => Configuration.authorization,
127
+ 'Authorization' => authorization
128
+ }
129
+
130
+ # prepare and execute HttpRequest
131
+ _request = @http_client.get _query_url, headers: _headers
132
+ CustomAuth.apply(_request)
133
+ _context = execute_request(_request)
134
+
135
+ # validate response against endpoint and global error codes
136
+ if _context.response.status_code == 400
137
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
138
+ elsif _context.response.status_code == 401
139
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
140
+ elsif _context.response.status_code == 403
141
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
142
+ elsif _context.response.status_code == 404
143
+ raise EntitiesErrorErrorException.new 'Not Found', _context
144
+ elsif !_context.response.status_code.between?(200, 208)
145
+ raise APIException.new 'Unexpected error', _context
146
+ end
147
+ validate_response(_context)
148
+
149
+ # return appropriate response type
150
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
151
+ return GetBookingByIdResponse.from_hash(decoded)
152
+ end
153
+
154
+ # Update a Booking by id
155
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
156
+ # @param [String] id Required parameter: Example:
157
+ # @param [UpdateBookingByIdBody] update_booking_by_id_body Optional parameter: the content of the request
158
+ # @return UpdateBookingByIdResponse response from the API call
159
+ def update_booking_by_id(authorization,
160
+ id,
161
+ update_booking_by_id_body = nil)
162
+
163
+ # prepare query url
164
+ _query_builder = Configuration.get_base_uri()
165
+ _query_builder << '/bookings/{id}'
166
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
167
+ 'id' => id
168
+ }
169
+ _query_url = APIHelper.clean_url _query_builder
170
+
171
+ # prepare headers
172
+ _headers = {
173
+ 'accept' => 'application/json',
174
+ 'content-type' => 'application/json; charset=utf-8',
175
+ 'Authorization' => Configuration.authorization,
176
+ 'Authorization' => authorization
177
+ }
178
+
179
+ # prepare and execute HttpRequest
180
+ _request = @http_client.put _query_url, headers: _headers, parameters: update_booking_by_id_body.to_json
181
+ CustomAuth.apply(_request)
182
+ _context = execute_request(_request)
183
+
184
+ # validate response against endpoint and global error codes
185
+ if _context.response.status_code == 400
186
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
187
+ elsif _context.response.status_code == 401
188
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
189
+ elsif _context.response.status_code == 403
190
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
191
+ elsif _context.response.status_code == 404
192
+ raise EntitiesErrorErrorException.new 'Not Found', _context
193
+ elsif _context.response.status_code == 422
194
+ raise EntitiesErrorErrorException.new 'Unprocessable Entity', _context
195
+ elsif !_context.response.status_code.between?(200, 208)
196
+ raise APIException.new 'Unexpected error', _context
197
+ end
198
+ validate_response(_context)
199
+
200
+ # return appropriate response type
201
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
202
+ return UpdateBookingByIdResponse.from_hash(decoded)
203
+ end
204
+
205
+ # Cancel a Booking by id
206
+ # @param [String] authorization Required parameter: A valid API key, in the format 'Token API_KEY'
207
+ # @param [String] id Required parameter: Example:
208
+ # @param [String] cancel_recurring Optional parameter: When a recurring booking, one of: ['instance', 'all', 'infinite']
209
+ # @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'
210
+ # @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'.
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)
217
+
218
+ # prepare query url
219
+ _query_builder = Configuration.get_base_uri()
220
+ _query_builder << '/bookings/{id}'
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
229
+ _query_url = APIHelper.clean_url _query_builder
230
+
231
+ # prepare headers
232
+ _headers = {
233
+ 'accept' => 'application/json',
234
+ 'Authorization' => Configuration.authorization,
235
+ 'Authorization' => authorization
236
+ }
237
+
238
+ # prepare and execute HttpRequest
239
+ _request = @http_client.delete _query_url, headers: _headers
240
+ CustomAuth.apply(_request)
241
+ _context = execute_request(_request)
242
+
243
+ # validate response against endpoint and global error codes
244
+ if _context.response.status_code == 400
245
+ raise EntitiesErrorErrorException.new 'Bad Request', _context
246
+ elsif _context.response.status_code == 401
247
+ raise EntitiesErrorErrorException.new 'Unauthorized/Missing Token', _context
248
+ elsif _context.response.status_code == 403
249
+ raise EntitiesErrorErrorException.new 'Forbidden', _context
250
+ elsif _context.response.status_code == 404
251
+ raise EntitiesErrorErrorException.new 'Not Found', _context
252
+ elsif !_context.response.status_code.between?(200, 208)
253
+ raise APIException.new 'Unexpected error', _context
254
+ end
255
+ validate_response(_context)
256
+
257
+ # return appropriate response type
258
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
259
+ return CancelBookingByIdResponse.from_hash(decoded)
260
+ end
261
+ end
262
+ end