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