suggestgrid 0.1.15.pre.SNAPSHOT

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +104 -0
  4. data/lib/suggest_grid/api_helper.rb +151 -0
  5. data/lib/suggest_grid/configuration.rb +21 -0
  6. data/lib/suggest_grid/controllers/action_controller.rb +257 -0
  7. data/lib/suggest_grid/controllers/base_controller.rb +20 -0
  8. data/lib/suggest_grid/controllers/metadata_controller.rb +527 -0
  9. data/lib/suggest_grid/controllers/recommendation_controller.rb +119 -0
  10. data/lib/suggest_grid/controllers/similarity_controller.rb +119 -0
  11. data/lib/suggest_grid/controllers/type_controller.rb +280 -0
  12. data/lib/suggest_grid/exceptions/api_exception.rb +16 -0
  13. data/lib/suggest_grid/http/http_call_back.rb +17 -0
  14. data/lib/suggest_grid/http/http_client.rb +112 -0
  15. data/lib/suggest_grid/http/http_context.rb +15 -0
  16. data/lib/suggest_grid/http/http_method_enum.rb +7 -0
  17. data/lib/suggest_grid/http/http_request.rb +28 -0
  18. data/lib/suggest_grid/http/http_response.rb +19 -0
  19. data/lib/suggest_grid/http/unirest_client.rb +41 -0
  20. data/lib/suggest_grid/models/action.rb +66 -0
  21. data/lib/suggest_grid/models/bulk_schema_error_response.rb +53 -0
  22. data/lib/suggest_grid/models/count_response.rb +39 -0
  23. data/lib/suggest_grid/models/error_response.rb +48 -0
  24. data/lib/suggest_grid/models/get_recommended_items_body.rb +111 -0
  25. data/lib/suggest_grid/models/get_recommended_users_body.rb +111 -0
  26. data/lib/suggest_grid/models/get_similar_items_body.rb +102 -0
  27. data/lib/suggest_grid/models/get_similar_users_body.rb +102 -0
  28. data/lib/suggest_grid/models/get_type_response.rb +39 -0
  29. data/lib/suggest_grid/models/get_types_response.rb +48 -0
  30. data/lib/suggest_grid/models/items_response.rb +53 -0
  31. data/lib/suggest_grid/models/message_response.rb +39 -0
  32. data/lib/suggest_grid/models/metadata.rb +39 -0
  33. data/lib/suggest_grid/models/metadata_information_response.rb +39 -0
  34. data/lib/suggest_grid/models/schema_error_response.rb +57 -0
  35. data/lib/suggest_grid/models/type_request_body.rb +40 -0
  36. data/lib/suggest_grid/models/users_response.rb +53 -0
  37. data/lib/suggest_grid/suggest_grid_client.rb +47 -0
  38. data/lib/suggest_grid.rb +48 -0
  39. data/spec/swagger.yaml +1169 -0
  40. metadata +123 -0
@@ -0,0 +1,527 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class MetadataController < BaseController
5
+ @@instance = MetadataController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # Delete a User
12
+ # @param [String] user_id Required parameter: The user_id to delete its metadata.
13
+ # @return MessageResponse response from the API call
14
+ def delete_user(user_id)
15
+ # the base uri for api requests
16
+ _query_builder = Configuration.base_uri.dup
17
+
18
+ # prepare query string for API call
19
+ _query_builder << '/v1/users/{user_id}'
20
+
21
+ # process optional query parameters
22
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
23
+ 'user_id' => user_id
24
+ }
25
+
26
+ # validate and preprocess url
27
+ _query_url = APIHelper.clean_url _query_builder
28
+
29
+ # prepare headers
30
+ _headers = {
31
+ 'user-agent' => 'SUGGESTGRID',
32
+ 'accept' => 'application/json'
33
+ }
34
+
35
+ # Create the HttpRequest object for the call
36
+ _request = @http_client.delete _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
37
+
38
+ # Call the on_before_request callback
39
+ @http_call_back.on_before_request(_request) if @http_call_back
40
+
41
+ # Invoke the API call and get the response
42
+ _response = @http_client.execute_as_string(_request)
43
+
44
+ # Wrap the request and response in an HttpContext object
45
+ _context = HttpContext.new(_request, _response)
46
+
47
+ # Call the on_after_response callback
48
+ @http_call_back.on_after_response(_context) if @http_call_back
49
+
50
+ # Endpoint error handling using HTTP status codes.
51
+ if _response.status_code == 429
52
+ raise APIException.new '429 - Too many requests.', _context
53
+ elsif _response.status_code == 500
54
+ raise APIException.new '500 - Unexpected internal error.', _context
55
+ end
56
+
57
+ # Global error handling using HTTP status codes.
58
+ validate_response(_context)
59
+
60
+ # Return appropriate response type
61
+ decoded = APIHelper.json_deserialize(_response.raw_body)
62
+ return MessageResponse.from_hash(decoded)
63
+ end
64
+
65
+ # Get Users
66
+ # @return MetadataInformationResponse response from the API call
67
+ def get_users
68
+ # the base uri for api requests
69
+ _query_builder = Configuration.base_uri.dup
70
+
71
+ # prepare query string for API call
72
+ _query_builder << '/v1/users'
73
+
74
+ # validate and preprocess url
75
+ _query_url = APIHelper.clean_url _query_builder
76
+
77
+ # prepare headers
78
+ _headers = {
79
+ 'user-agent' => 'SUGGESTGRID',
80
+ 'accept' => 'application/json'
81
+ }
82
+
83
+ # Create the HttpRequest object for the call
84
+ _request = @http_client.get _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
85
+
86
+ # Call the on_before_request callback
87
+ @http_call_back.on_before_request(_request) if @http_call_back
88
+
89
+ # Invoke the API call and get the response
90
+ _response = @http_client.execute_as_string(_request)
91
+
92
+ # Wrap the request and response in an HttpContext object
93
+ _context = HttpContext.new(_request, _response)
94
+
95
+ # Call the on_after_response callback
96
+ @http_call_back.on_after_response(_context) if @http_call_back
97
+
98
+ # Endpoint error handling using HTTP status codes.
99
+ if _response.status_code == 429
100
+ raise APIException.new '429 - Too many requests.', _context
101
+ elsif _response.status_code == 500
102
+ raise APIException.new '500 - Unexpected internal error.', _context
103
+ end
104
+
105
+ # Global error handling using HTTP status codes.
106
+ validate_response(_context)
107
+
108
+ # Return appropriate response type
109
+ decoded = APIHelper.json_deserialize(_response.raw_body)
110
+ return MetadataInformationResponse.from_hash(decoded)
111
+ end
112
+
113
+ # Post a User
114
+ # @param [Metadata] metadata Required parameter: The metadata to be saved. Metadata format has its restrictions.
115
+ # @return MessageResponse response from the API call
116
+ def post_user(metadata)
117
+ # the base uri for api requests
118
+ _query_builder = Configuration.base_uri.dup
119
+
120
+ # prepare query string for API call
121
+ _query_builder << '/v1/users'
122
+
123
+ # validate and preprocess url
124
+ _query_url = APIHelper.clean_url _query_builder
125
+
126
+ # prepare headers
127
+ _headers = {
128
+ 'user-agent' => 'SUGGESTGRID',
129
+ 'accept' => 'application/json',
130
+ 'content-type' => 'application/json; charset=utf-8'
131
+ }
132
+
133
+ # Create the HttpRequest object for the call
134
+ _request = @http_client.post _query_url, headers: _headers, parameters: metadata.to_json, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
135
+
136
+ # Call the on_before_request callback
137
+ @http_call_back.on_before_request(_request) if @http_call_back
138
+
139
+ # Invoke the API call and get the response
140
+ _response = @http_client.execute_as_string(_request)
141
+
142
+ # Wrap the request and response in an HttpContext object
143
+ _context = HttpContext.new(_request, _response)
144
+
145
+ # Call the on_after_response callback
146
+ @http_call_back.on_after_response(_context) if @http_call_back
147
+
148
+ # Endpoint error handling using HTTP status codes.
149
+ if _response.status_code == 400
150
+ raise APIException.new '400 - Metadata is invalid.', _context
151
+ elsif _response.status_code == 429
152
+ raise APIException.new '429 - Too many requests.', _context
153
+ elsif _response.status_code == 500
154
+ raise APIException.new '500 - Unexpected internal error.', _context
155
+ end
156
+
157
+ # Global error handling using HTTP status codes.
158
+ validate_response(_context)
159
+
160
+ # Return appropriate response type
161
+ decoded = APIHelper.json_deserialize(_response.raw_body)
162
+ return MessageResponse.from_hash(decoded)
163
+ end
164
+
165
+ # Delete All Users
166
+ # @return MessageResponse response from the API call
167
+ def delete_all_users
168
+ # the base uri for api requests
169
+ _query_builder = Configuration.base_uri.dup
170
+
171
+ # prepare query string for API call
172
+ _query_builder << '/v1/users'
173
+
174
+ # validate and preprocess url
175
+ _query_url = APIHelper.clean_url _query_builder
176
+
177
+ # prepare headers
178
+ _headers = {
179
+ 'user-agent' => 'SUGGESTGRID',
180
+ 'accept' => 'application/json'
181
+ }
182
+
183
+ # Create the HttpRequest object for the call
184
+ _request = @http_client.delete _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
185
+
186
+ # Call the on_before_request callback
187
+ @http_call_back.on_before_request(_request) if @http_call_back
188
+
189
+ # Invoke the API call and get the response
190
+ _response = @http_client.execute_as_string(_request)
191
+
192
+ # Wrap the request and response in an HttpContext object
193
+ _context = HttpContext.new(_request, _response)
194
+
195
+ # Call the on_after_response callback
196
+ @http_call_back.on_after_response(_context) if @http_call_back
197
+
198
+ # Endpoint error handling using HTTP status codes.
199
+ if _response.status_code == 429
200
+ raise APIException.new '429 - Too many requests.', _context
201
+ elsif _response.status_code == 500
202
+ raise APIException.new '500 - Unexpected internal error.', _context
203
+ end
204
+
205
+ # Global error handling using HTTP status codes.
206
+ validate_response(_context)
207
+
208
+ # Return appropriate response type
209
+ decoded = APIHelper.json_deserialize(_response.raw_body)
210
+ return MessageResponse.from_hash(decoded)
211
+ end
212
+
213
+ # Delete an Item
214
+ # @param [String] item_id Required parameter: The item_id to delete its metadata.
215
+ # @return MessageResponse response from the API call
216
+ def delete_item(item_id)
217
+ # the base uri for api requests
218
+ _query_builder = Configuration.base_uri.dup
219
+
220
+ # prepare query string for API call
221
+ _query_builder << '/v1/items/{item_id}'
222
+
223
+ # process optional query parameters
224
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
225
+ 'item_id' => item_id
226
+ }
227
+
228
+ # validate and preprocess url
229
+ _query_url = APIHelper.clean_url _query_builder
230
+
231
+ # prepare headers
232
+ _headers = {
233
+ 'user-agent' => 'SUGGESTGRID',
234
+ 'accept' => 'application/json'
235
+ }
236
+
237
+ # Create the HttpRequest object for the call
238
+ _request = @http_client.delete _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
239
+
240
+ # Call the on_before_request callback
241
+ @http_call_back.on_before_request(_request) if @http_call_back
242
+
243
+ # Invoke the API call and get the response
244
+ _response = @http_client.execute_as_string(_request)
245
+
246
+ # Wrap the request and response in an HttpContext object
247
+ _context = HttpContext.new(_request, _response)
248
+
249
+ # Call the on_after_response callback
250
+ @http_call_back.on_after_response(_context) if @http_call_back
251
+
252
+ # Endpoint error handling using HTTP status codes.
253
+ if _response.status_code == 429
254
+ raise APIException.new '429 - Too many requests.', _context
255
+ elsif _response.status_code == 500
256
+ raise APIException.new '500 - Unexpected internal error.', _context
257
+ end
258
+
259
+ # Global error handling using HTTP status codes.
260
+ validate_response(_context)
261
+
262
+ # Return appropriate response type
263
+ decoded = APIHelper.json_deserialize(_response.raw_body)
264
+ return MessageResponse.from_hash(decoded)
265
+ end
266
+
267
+ # Get Items
268
+ # @return MetadataInformationResponse response from the API call
269
+ def get_items
270
+ # the base uri for api requests
271
+ _query_builder = Configuration.base_uri.dup
272
+
273
+ # prepare query string for API call
274
+ _query_builder << '/v1/items'
275
+
276
+ # validate and preprocess url
277
+ _query_url = APIHelper.clean_url _query_builder
278
+
279
+ # prepare headers
280
+ _headers = {
281
+ 'user-agent' => 'SUGGESTGRID',
282
+ 'accept' => 'application/json'
283
+ }
284
+
285
+ # Create the HttpRequest object for the call
286
+ _request = @http_client.get _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
287
+
288
+ # Call the on_before_request callback
289
+ @http_call_back.on_before_request(_request) if @http_call_back
290
+
291
+ # Invoke the API call and get the response
292
+ _response = @http_client.execute_as_string(_request)
293
+
294
+ # Wrap the request and response in an HttpContext object
295
+ _context = HttpContext.new(_request, _response)
296
+
297
+ # Call the on_after_response callback
298
+ @http_call_back.on_after_response(_context) if @http_call_back
299
+
300
+ # Endpoint error handling using HTTP status codes.
301
+ if _response.status_code == 429
302
+ raise APIException.new '429 - Too many requests.', _context
303
+ elsif _response.status_code == 500
304
+ raise APIException.new '500 - Unexpected internal error.', _context
305
+ end
306
+
307
+ # Global error handling using HTTP status codes.
308
+ validate_response(_context)
309
+
310
+ # Return appropriate response type
311
+ decoded = APIHelper.json_deserialize(_response.raw_body)
312
+ return MetadataInformationResponse.from_hash(decoded)
313
+ end
314
+
315
+ # Post an Item
316
+ # @param [Metadata] body Required parameter: The metadata to be saved. Metadata format has its restrictions.
317
+ # @return MessageResponse response from the API call
318
+ def post_item(body)
319
+ # the base uri for api requests
320
+ _query_builder = Configuration.base_uri.dup
321
+
322
+ # prepare query string for API call
323
+ _query_builder << '/v1/items'
324
+
325
+ # validate and preprocess url
326
+ _query_url = APIHelper.clean_url _query_builder
327
+
328
+ # prepare headers
329
+ _headers = {
330
+ 'user-agent' => 'SUGGESTGRID',
331
+ 'accept' => 'application/json',
332
+ 'content-type' => 'application/json; charset=utf-8'
333
+ }
334
+
335
+ # Create the HttpRequest object for the call
336
+ _request = @http_client.post _query_url, headers: _headers, parameters: body.to_json, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
337
+
338
+ # Call the on_before_request callback
339
+ @http_call_back.on_before_request(_request) if @http_call_back
340
+
341
+ # Invoke the API call and get the response
342
+ _response = @http_client.execute_as_string(_request)
343
+
344
+ # Wrap the request and response in an HttpContext object
345
+ _context = HttpContext.new(_request, _response)
346
+
347
+ # Call the on_after_response callback
348
+ @http_call_back.on_after_response(_context) if @http_call_back
349
+
350
+ # Endpoint error handling using HTTP status codes.
351
+ if _response.status_code == 400
352
+ raise APIException.new '400 - Metadata is invalid.', _context
353
+ elsif _response.status_code == 429
354
+ raise APIException.new '429 - Too many requests.', _context
355
+ elsif _response.status_code == 500
356
+ raise APIException.new '500 - Unexpected internal error.', _context
357
+ end
358
+
359
+ # Global error handling using HTTP status codes.
360
+ validate_response(_context)
361
+
362
+ # Return appropriate response type
363
+ decoded = APIHelper.json_deserialize(_response.raw_body)
364
+ return MessageResponse.from_hash(decoded)
365
+ end
366
+
367
+ # Delete All Items
368
+ # @return MessageResponse response from the API call
369
+ def delete_all_items
370
+ # the base uri for api requests
371
+ _query_builder = Configuration.base_uri.dup
372
+
373
+ # prepare query string for API call
374
+ _query_builder << '/v1/items'
375
+
376
+ # validate and preprocess url
377
+ _query_url = APIHelper.clean_url _query_builder
378
+
379
+ # prepare headers
380
+ _headers = {
381
+ 'user-agent' => 'SUGGESTGRID',
382
+ 'accept' => 'application/json'
383
+ }
384
+
385
+ # Create the HttpRequest object for the call
386
+ _request = @http_client.delete _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
387
+
388
+ # Call the on_before_request callback
389
+ @http_call_back.on_before_request(_request) if @http_call_back
390
+
391
+ # Invoke the API call and get the response
392
+ _response = @http_client.execute_as_string(_request)
393
+
394
+ # Wrap the request and response in an HttpContext object
395
+ _context = HttpContext.new(_request, _response)
396
+
397
+ # Call the on_after_response callback
398
+ @http_call_back.on_after_response(_context) if @http_call_back
399
+
400
+ # Endpoint error handling using HTTP status codes.
401
+ if _response.status_code == 429
402
+ raise APIException.new '429 - Too many requests.', _context
403
+ elsif _response.status_code == 500
404
+ raise APIException.new '500 - Unexpected internal error.', _context
405
+ end
406
+
407
+ # Global error handling using HTTP status codes.
408
+ validate_response(_context)
409
+
410
+ # Return appropriate response type
411
+ decoded = APIHelper.json_deserialize(_response.raw_body)
412
+ return MessageResponse.from_hash(decoded)
413
+ end
414
+
415
+ # Post Bulk Users
416
+ # @param [Collection] metas Required parameter: List of metadata, size is limited to 10 thousand.
417
+ # @return MessageResponse response from the API call
418
+ def post_bulk_users(metas)
419
+ body = ''
420
+ metas.each do |meta|
421
+ body += "#{meta.to_json}\n"
422
+ end
423
+ # the base uri for api requests
424
+ _query_builder = Configuration.base_uri.dup
425
+
426
+ # prepare query string for API call
427
+ _query_builder << '/v1/users/_bulk'
428
+
429
+ # validate and preprocess url
430
+ _query_url = APIHelper.clean_url _query_builder
431
+
432
+ # prepare headers
433
+ _headers = {
434
+ 'user-agent' => 'SUGGESTGRID',
435
+ 'accept' => 'application/json',
436
+ 'content-type' => 'text/plain; charset=utf-8'
437
+ }
438
+
439
+ # Create the HttpRequest object for the call
440
+ _request = @http_client.post _query_url, headers: _headers, parameters: body, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
441
+
442
+ # Call the on_before_request callback
443
+ @http_call_back.on_before_request(_request) if @http_call_back
444
+
445
+ # Invoke the API call and get the response
446
+ _response = @http_client.execute_as_string(_request)
447
+
448
+ # Wrap the request and response in an HttpContext object
449
+ _context = HttpContext.new(_request, _response)
450
+
451
+ # Call the on_after_response callback
452
+ @http_call_back.on_after_response(_context) if @http_call_back
453
+
454
+ # Endpoint error handling using HTTP status codes.
455
+ if _response.status_code == 209
456
+ raise APIException.new '209 - Some metadata is not uploaded successfully.', _context
457
+ elsif _response.status_code == 429
458
+ raise APIException.new '429 - Too many requests.', _context
459
+ elsif _response.status_code == 500
460
+ raise APIException.new '500 - Unexpected internal error.', _context
461
+ end
462
+
463
+ # Global error handling using HTTP status codes.
464
+ validate_response(_context)
465
+
466
+ # Return appropriate response type
467
+ decoded = APIHelper.json_deserialize(_response.raw_body)
468
+ return MessageResponse.from_hash(decoded)
469
+ end
470
+
471
+ # Post Bulk Items
472
+ # @param [Collection] metas Required parameter: List of metadata, size is limited to 10 thousand.
473
+ # @return MessageResponse response from the API call
474
+ def post_bulk_items(metas)
475
+ body = ''
476
+ metas.each do |meta|
477
+ body += "#{meta.to_json}\n"
478
+ end
479
+ # the base uri for api requests
480
+ _query_builder = Configuration.base_uri.dup
481
+
482
+ # prepare query string for API call
483
+ _query_builder << '/v1/items/_bulk'
484
+
485
+ # validate and preprocess url
486
+ _query_url = APIHelper.clean_url _query_builder
487
+
488
+ # prepare headers
489
+ _headers = {
490
+ 'user-agent' => 'SUGGESTGRID',
491
+ 'accept' => 'application/json',
492
+ 'content-type' => 'text/plain; charset=utf-8'
493
+ }
494
+
495
+ # Create the HttpRequest object for the call
496
+ _request = @http_client.post _query_url, headers: _headers, parameters: body, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
497
+
498
+ # Call the on_before_request callback
499
+ @http_call_back.on_before_request(_request) if @http_call_back
500
+
501
+ # Invoke the API call and get the response
502
+ _response = @http_client.execute_as_string(_request)
503
+
504
+ # Wrap the request and response in an HttpContext object
505
+ _context = HttpContext.new(_request, _response)
506
+
507
+ # Call the on_after_response callback
508
+ @http_call_back.on_after_response(_context) if @http_call_back
509
+
510
+ # Endpoint error handling using HTTP status codes.
511
+ if _response.status_code == 209
512
+ raise APIException.new '209 - Some metadata is not uploaded successfully.', _context
513
+ elsif _response.status_code == 429
514
+ raise APIException.new '429 - Too many requests.', _context
515
+ elsif _response.status_code == 500
516
+ raise APIException.new '500 - Unexpected internal error.', _context
517
+ end
518
+
519
+ # Global error handling using HTTP status codes.
520
+ validate_response(_context)
521
+
522
+ # Return appropriate response type
523
+ decoded = APIHelper.json_deserialize(_response.raw_body)
524
+ return MessageResponse.from_hash(decoded)
525
+ end
526
+ end
527
+ end
@@ -0,0 +1,119 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class RecommendationController < BaseController
5
+ @@instance = RecommendationController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # Get Recommended Users
12
+ # @param [GetRecommendedUsersBody] body Required parameter: Parameters for recommend users method.
13
+ # @return UsersResponse response from the API call
14
+ def get_recommended_users(body)
15
+ # the base uri for api requests
16
+ _query_builder = Configuration.base_uri.dup
17
+
18
+ # prepare query string for API call
19
+ _query_builder << '/v1/recommend/users'
20
+
21
+ # validate and preprocess url
22
+ _query_url = APIHelper.clean_url _query_builder
23
+
24
+ # prepare headers
25
+ _headers = {
26
+ 'user-agent' => 'SUGGESTGRID',
27
+ 'accept' => 'application/json',
28
+ 'content-type' => 'application/json; charset=utf-8'
29
+ }
30
+
31
+ # Create the HttpRequest object for the call
32
+ _request = @http_client.post _query_url, headers: _headers, parameters: body.to_json, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
33
+
34
+ # Call the on_before_request callback
35
+ @http_call_back.on_before_request(_request) if @http_call_back
36
+
37
+ # Invoke the API call and get the response
38
+ _response = @http_client.execute_as_string(_request)
39
+
40
+ # Wrap the request and response in an HttpContext object
41
+ _context = HttpContext.new(_request, _response)
42
+
43
+ # Call the on_after_response callback
44
+ @http_call_back.on_after_response(_context) if @http_call_back
45
+
46
+ # Endpoint error handling using HTTP status codes.
47
+ if _response.status_code == 400
48
+ raise APIException.new '400 - Request body is invalid.', _context
49
+ elsif _response.status_code == 422
50
+ raise APIException.new '422 - Required parameters are missing.', _context
51
+ elsif _response.status_code == 429
52
+ raise APIException.new '429 - Too many requests.', _context
53
+ elsif _response.status_code == 500
54
+ raise APIException.new '500 - Unexpected internal error.', _context
55
+ end
56
+
57
+ # Global error handling using HTTP status codes.
58
+ validate_response(_context)
59
+
60
+ # Return appropriate response type
61
+ decoded = APIHelper.json_deserialize(_response.raw_body)
62
+ return UsersResponse.from_hash(decoded)
63
+ end
64
+
65
+ # Get Recommended Items
66
+ # @param [GetRecommendedItemsBody] body Required parameter: Parameters for recommend items method.
67
+ # @return ItemsResponse response from the API call
68
+ def get_recommended_items(body)
69
+ # the base uri for api requests
70
+ _query_builder = Configuration.base_uri.dup
71
+
72
+ # prepare query string for API call
73
+ _query_builder << '/v1/recommend/items'
74
+
75
+ # validate and preprocess url
76
+ _query_url = APIHelper.clean_url _query_builder
77
+
78
+ # prepare headers
79
+ _headers = {
80
+ 'user-agent' => 'SUGGESTGRID',
81
+ 'accept' => 'application/json',
82
+ 'content-type' => 'application/json; charset=utf-8'
83
+ }
84
+
85
+ # Create the HttpRequest object for the call
86
+ _request = @http_client.post _query_url, headers: _headers, parameters: body.to_json, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
87
+
88
+ # Call the on_before_request callback
89
+ @http_call_back.on_before_request(_request) if @http_call_back
90
+
91
+ # Invoke the API call and get the response
92
+ _response = @http_client.execute_as_string(_request)
93
+
94
+ # Wrap the request and response in an HttpContext object
95
+ _context = HttpContext.new(_request, _response)
96
+
97
+ # Call the on_after_response callback
98
+ @http_call_back.on_after_response(_context) if @http_call_back
99
+
100
+ # Endpoint error handling using HTTP status codes.
101
+ if _response.status_code == 400
102
+ raise APIException.new '400 - Request body is invalid.', _context
103
+ elsif _response.status_code == 422
104
+ raise APIException.new '422 - Required parameters are missing.', _context
105
+ elsif _response.status_code == 429
106
+ raise APIException.new '429 - Too many requests.', _context
107
+ elsif _response.status_code == 500
108
+ raise APIException.new '500 - Unexpected internal error.', _context
109
+ end
110
+
111
+ # Global error handling using HTTP status codes.
112
+ validate_response(_context)
113
+
114
+ # Return appropriate response type
115
+ decoded = APIHelper.json_deserialize(_response.raw_body)
116
+ return ItemsResponse.from_hash(decoded)
117
+ end
118
+ end
119
+ end