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