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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/suggest_grid/api_helper.rb +2 -2
  3. data/lib/suggest_grid/configuration.rb +2 -1
  4. data/lib/suggest_grid/controllers/action_controller.rb +77 -99
  5. data/lib/suggest_grid/controllers/base_controller.rb +27 -2
  6. data/lib/suggest_grid/controllers/metadata_controller.rb +259 -209
  7. data/lib/suggest_grid/controllers/recommendation_controller.rb +32 -44
  8. data/lib/suggest_grid/controllers/similarity_controller.rb +32 -44
  9. data/lib/suggest_grid/controllers/type_controller.rb +74 -104
  10. data/lib/suggest_grid/exceptions/api_exception.rb +1 -1
  11. data/lib/suggest_grid/exceptions/delete_error_response_exception.rb +52 -0
  12. data/lib/suggest_grid/exceptions/detailed_error_response_exception.rb +3 -3
  13. data/lib/suggest_grid/exceptions/error_response_exception.rb +3 -3
  14. data/lib/suggest_grid/exceptions/limit_exceeded_error_response_exception.rb +3 -3
  15. data/lib/suggest_grid/http/auth/basic_auth.rb +17 -0
  16. data/lib/suggest_grid/http/faraday_client.rb +43 -0
  17. data/lib/suggest_grid/http/http_call_back.rb +2 -2
  18. data/lib/suggest_grid/http/http_client.rb +13 -43
  19. data/lib/suggest_grid/http/http_request.rb +24 -8
  20. data/lib/suggest_grid/models/actions_response.rb +58 -0
  21. data/lib/suggest_grid/models/{schema_error_response.rb → bulk_post_error.rb} +4 -4
  22. data/lib/suggest_grid/models/bulk_post_response.rb +49 -0
  23. data/lib/suggest_grid/models/get_recommended_items_body.rb +14 -5
  24. data/lib/suggest_grid/models/get_recommended_users_body.rb +11 -2
  25. data/lib/suggest_grid/models/get_similar_items_body.rb +14 -5
  26. data/lib/suggest_grid/models/get_similar_users_body.rb +11 -2
  27. data/lib/suggest_grid/models/items_response.rb +10 -1
  28. data/lib/suggest_grid/models/users_response.rb +10 -1
  29. data/lib/suggest_grid.rb +53 -53
  30. data/spec/swagger.yaml +185 -87
  31. metadata +41 -15
  32. data/lib/suggest_grid/exceptions/bulk_schema_error_response_exception.rb +0 -37
  33. data/lib/suggest_grid/http/unirest_client.rb +0 -41
  34. data/lib/suggest_grid/models/count_response.rb +0 -35
  35. data/lib/suggest_grid/models/delete_error_response.rb +0 -80
  36. data/lib/suggest_grid/models/metadata_information_response.rb +0 -35
@@ -12,6 +12,7 @@ module SuggestGrid
12
12
  # @param [GetRecommendedUsersBody] query Required parameter: The query for recommended users.
13
13
  # @return UsersResponse response from the API call
14
14
  def get_recommended_users(query)
15
+
15
16
  # the base uri for api requests
16
17
  _query_builder = Configuration.base_uri.dup
17
18
 
@@ -23,42 +24,35 @@ module SuggestGrid
23
24
 
24
25
  # prepare headers
25
26
  _headers = {
26
- 'user-agent' => 'SUGGESTGRID',
27
27
  'accept' => 'application/json',
28
28
  'content-type' => 'application/json; charset=utf-8'
29
29
  }
30
+
31
+ # create the HttpRequest object for the call
32
+ _request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
30
33
 
31
- # Create the HttpRequest object for the call
32
- _request = @http_client.post _query_url, headers: _headers, parameters: query.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)
34
+ # apply authentication
35
+ BasicAuth.apply(_request)
42
36
 
43
- # Call the on_after_response callback
44
- @http_call_back.on_after_response(_context) if @http_call_back
37
+ # execute the request
38
+ _context = execute_request(_request)
45
39
 
46
- # Endpoint error handling using HTTP status codes.
47
- if _response.status_code == 400
40
+ # endpoint error handling using HTTP status codes.
41
+ if _context.response.status_code == 400
48
42
  raise ErrorResponseException.new '400 - Request body is invalid.', _context
49
- elsif _response.status_code == 422
43
+ elsif _context.response.status_code == 422
50
44
  raise ErrorResponseException.new '422 - Required parameters are missing.', _context
51
- elsif _response.status_code == 429
45
+ elsif _context.response.status_code == 429
52
46
  raise ErrorResponseException.new '429 - Too many requests.', _context
53
- elsif _response.status_code == 500
47
+ elsif _context.response.status_code == 500
54
48
  raise APIException.new '500 - Unexpected internal error.', _context
55
49
  end
56
50
 
57
- # Global error handling using HTTP status codes.
51
+ # global error handling using HTTP status codes.
58
52
  validate_response(_context)
59
53
 
60
- # Return appropriate response type
61
- decoded = APIHelper.json_deserialize(_response.raw_body)
54
+ # return appropriate response type
55
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
62
56
  return UsersResponse.from_hash(decoded)
63
57
  end
64
58
 
@@ -66,6 +60,7 @@ module SuggestGrid
66
60
  # @param [GetRecommendedItemsBody] query Required parameter: The query for recommended items.
67
61
  # @return ItemsResponse response from the API call
68
62
  def get_recommended_items(query)
63
+
69
64
  # the base uri for api requests
70
65
  _query_builder = Configuration.base_uri.dup
71
66
 
@@ -77,42 +72,35 @@ module SuggestGrid
77
72
 
78
73
  # prepare headers
79
74
  _headers = {
80
- 'user-agent' => 'SUGGESTGRID',
81
75
  'accept' => 'application/json',
82
76
  'content-type' => 'application/json; charset=utf-8'
83
77
  }
78
+
79
+ # create the HttpRequest object for the call
80
+ _request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
84
81
 
85
- # Create the HttpRequest object for the call
86
- _request = @http_client.post _query_url, headers: _headers, parameters: query.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)
82
+ # apply authentication
83
+ BasicAuth.apply(_request)
96
84
 
97
- # Call the on_after_response callback
98
- @http_call_back.on_after_response(_context) if @http_call_back
85
+ # execute the request
86
+ _context = execute_request(_request)
99
87
 
100
- # Endpoint error handling using HTTP status codes.
101
- if _response.status_code == 400
88
+ # endpoint error handling using HTTP status codes.
89
+ if _context.response.status_code == 400
102
90
  raise ErrorResponseException.new '400 - Request body is invalid.', _context
103
- elsif _response.status_code == 422
91
+ elsif _context.response.status_code == 422
104
92
  raise ErrorResponseException.new '422 - Required parameters are missing.', _context
105
- elsif _response.status_code == 429
93
+ elsif _context.response.status_code == 429
106
94
  raise ErrorResponseException.new '429 - Too many requests.', _context
107
- elsif _response.status_code == 500
95
+ elsif _context.response.status_code == 500
108
96
  raise APIException.new '500 - Unexpected internal error.', _context
109
97
  end
110
98
 
111
- # Global error handling using HTTP status codes.
99
+ # global error handling using HTTP status codes.
112
100
  validate_response(_context)
113
101
 
114
- # Return appropriate response type
115
- decoded = APIHelper.json_deserialize(_response.raw_body)
102
+ # return appropriate response type
103
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
116
104
  return ItemsResponse.from_hash(decoded)
117
105
  end
118
106
  end
@@ -12,6 +12,7 @@ module SuggestGrid
12
12
  # @param [GetSimilarUsersBody] query Required parameter: The query for similar users.
13
13
  # @return UsersResponse response from the API call
14
14
  def get_similar_users(query)
15
+
15
16
  # the base uri for api requests
16
17
  _query_builder = Configuration.base_uri.dup
17
18
 
@@ -23,42 +24,35 @@ module SuggestGrid
23
24
 
24
25
  # prepare headers
25
26
  _headers = {
26
- 'user-agent' => 'SUGGESTGRID',
27
27
  'accept' => 'application/json',
28
28
  'content-type' => 'application/json; charset=utf-8'
29
29
  }
30
+
31
+ # create the HttpRequest object for the call
32
+ _request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
30
33
 
31
- # Create the HttpRequest object for the call
32
- _request = @http_client.post _query_url, headers: _headers, parameters: query.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)
34
+ # apply authentication
35
+ BasicAuth.apply(_request)
42
36
 
43
- # Call the on_after_response callback
44
- @http_call_back.on_after_response(_context) if @http_call_back
37
+ # execute the request
38
+ _context = execute_request(_request)
45
39
 
46
- # Endpoint error handling using HTTP status codes.
47
- if _response.status_code == 400
40
+ # endpoint error handling using HTTP status codes.
41
+ if _context.response.status_code == 400
48
42
  raise ErrorResponseException.new '400 - Request body is invalid.', _context
49
- elsif _response.status_code == 422
43
+ elsif _context.response.status_code == 422
50
44
  raise ErrorResponseException.new '422 - Required parameters are missing.', _context
51
- elsif _response.status_code == 429
45
+ elsif _context.response.status_code == 429
52
46
  raise ErrorResponseException.new '429 - Too many requests.', _context
53
- elsif _response.status_code == 500
47
+ elsif _context.response.status_code == 500
54
48
  raise APIException.new '500 - Unexpected internal error.', _context
55
49
  end
56
50
 
57
- # Global error handling using HTTP status codes.
51
+ # global error handling using HTTP status codes.
58
52
  validate_response(_context)
59
53
 
60
- # Return appropriate response type
61
- decoded = APIHelper.json_deserialize(_response.raw_body)
54
+ # return appropriate response type
55
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
62
56
  return UsersResponse.from_hash(decoded)
63
57
  end
64
58
 
@@ -66,6 +60,7 @@ module SuggestGrid
66
60
  # @param [GetSimilarItemsBody] query Required parameter: The query for similar items.
67
61
  # @return ItemsResponse response from the API call
68
62
  def get_similar_items(query)
63
+
69
64
  # the base uri for api requests
70
65
  _query_builder = Configuration.base_uri.dup
71
66
 
@@ -77,42 +72,35 @@ module SuggestGrid
77
72
 
78
73
  # prepare headers
79
74
  _headers = {
80
- 'user-agent' => 'SUGGESTGRID',
81
75
  'accept' => 'application/json',
82
76
  'content-type' => 'application/json; charset=utf-8'
83
77
  }
78
+
79
+ # create the HttpRequest object for the call
80
+ _request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
84
81
 
85
- # Create the HttpRequest object for the call
86
- _request = @http_client.post _query_url, headers: _headers, parameters: query.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)
82
+ # apply authentication
83
+ BasicAuth.apply(_request)
96
84
 
97
- # Call the on_after_response callback
98
- @http_call_back.on_after_response(_context) if @http_call_back
85
+ # execute the request
86
+ _context = execute_request(_request)
99
87
 
100
- # Endpoint error handling using HTTP status codes.
101
- if _response.status_code == 400
88
+ # endpoint error handling using HTTP status codes.
89
+ if _context.response.status_code == 400
102
90
  raise ErrorResponseException.new '400 - Request body is invalid.', _context
103
- elsif _response.status_code == 422
91
+ elsif _context.response.status_code == 422
104
92
  raise ErrorResponseException.new '422 - Required parameters are missing.', _context
105
- elsif _response.status_code == 429
93
+ elsif _context.response.status_code == 429
106
94
  raise ErrorResponseException.new '429 - Too many requests.', _context
107
- elsif _response.status_code == 500
95
+ elsif _context.response.status_code == 500
108
96
  raise APIException.new '500 - Unexpected internal error.', _context
109
97
  end
110
98
 
111
- # Global error handling using HTTP status codes.
99
+ # global error handling using HTTP status codes.
112
100
  validate_response(_context)
113
101
 
114
- # Return appropriate response type
115
- decoded = APIHelper.json_deserialize(_response.raw_body)
102
+ # return appropriate response type
103
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
116
104
  return ItemsResponse.from_hash(decoded)
117
105
  end
118
106
  end
@@ -11,6 +11,7 @@ module SuggestGrid
11
11
  # Get All Types
12
12
  # @return GetTypesResponse response from the API call
13
13
  def get_all_types
14
+
14
15
  # the base uri for api requests
15
16
  _query_builder = Configuration.base_uri.dup
16
17
 
@@ -22,43 +23,37 @@ module SuggestGrid
22
23
 
23
24
  # prepare headers
24
25
  _headers = {
25
- 'user-agent' => 'SUGGESTGRID',
26
26
  'accept' => 'application/json'
27
27
  }
28
+
29
+ # create the HttpRequest object for the call
30
+ _request = @http_client.get _query_url, headers: _headers
28
31
 
29
- # Create the HttpRequest object for the call
30
- _request = @http_client.get _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
31
-
32
- # Call the on_before_request callback
33
- @http_call_back.on_before_request(_request) if @http_call_back
34
-
35
- # Invoke the API call and get the response
36
- _response = @http_client.execute_as_string(_request)
32
+ # apply authentication
33
+ BasicAuth.apply(_request)
37
34
 
38
- # Wrap the request and response in an HttpContext object
39
- _context = HttpContext.new(_request, _response)
35
+ # execute the request
36
+ _context = execute_request(_request)
40
37
 
41
- # Call the on_after_response callback
42
- @http_call_back.on_after_response(_context) if @http_call_back
43
-
44
- # Endpoint error handling using HTTP status codes.
45
- if _response.status_code == 429
38
+ # endpoint error handling using HTTP status codes.
39
+ if _context.response.status_code == 429
46
40
  raise ErrorResponseException.new '429 - Too many requests.', _context
47
- elsif _response.status_code == 500
41
+ elsif _context.response.status_code == 500
48
42
  raise APIException.new '500 - Unexpected internal error.', _context
49
43
  end
50
44
 
51
- # Global error handling using HTTP status codes.
45
+ # global error handling using HTTP status codes.
52
46
  validate_response(_context)
53
47
 
54
- # Return appropriate response type
55
- decoded = APIHelper.json_deserialize(_response.raw_body)
48
+ # return appropriate response type
49
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
56
50
  return GetTypesResponse.from_hash(decoded)
57
51
  end
58
52
 
59
53
  # Delete All Types
60
54
  # @return GetTypesResponse response from the API call
61
55
  def delete_all_types
56
+
62
57
  # the base uri for api requests
63
58
  _query_builder = Configuration.base_uri.dup
64
59
 
@@ -70,37 +65,30 @@ module SuggestGrid
70
65
 
71
66
  # prepare headers
72
67
  _headers = {
73
- 'user-agent' => 'SUGGESTGRID',
74
68
  'accept' => 'application/json'
75
69
  }
70
+
71
+ # create the HttpRequest object for the call
72
+ _request = @http_client.delete _query_url, headers: _headers
76
73
 
77
- # Create the HttpRequest object for the call
78
- _request = @http_client.delete _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
79
-
80
- # Call the on_before_request callback
81
- @http_call_back.on_before_request(_request) if @http_call_back
74
+ # apply authentication
75
+ BasicAuth.apply(_request)
82
76
 
83
- # Invoke the API call and get the response
84
- _response = @http_client.execute_as_string(_request)
77
+ # execute the request
78
+ _context = execute_request(_request)
85
79
 
86
- # Wrap the request and response in an HttpContext object
87
- _context = HttpContext.new(_request, _response)
88
-
89
- # Call the on_after_response callback
90
- @http_call_back.on_after_response(_context) if @http_call_back
91
-
92
- # Endpoint error handling using HTTP status codes.
93
- if _response.status_code == 429
80
+ # endpoint error handling using HTTP status codes.
81
+ if _context.response.status_code == 429
94
82
  raise ErrorResponseException.new '429 - Too many requests.', _context
95
- elsif _response.status_code == 500
83
+ elsif _context.response.status_code == 500
96
84
  raise APIException.new '500 - Unexpected internal error.', _context
97
85
  end
98
86
 
99
- # Global error handling using HTTP status codes.
87
+ # global error handling using HTTP status codes.
100
88
  validate_response(_context)
101
89
 
102
- # Return appropriate response type
103
- decoded = APIHelper.json_deserialize(_response.raw_body)
90
+ # return appropriate response type
91
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
104
92
  return GetTypesResponse.from_hash(decoded)
105
93
  end
106
94
 
@@ -108,6 +96,7 @@ module SuggestGrid
108
96
  # @param [String] type Required parameter: The name of the type to get properties.
109
97
  # @return GetTypeResponse response from the API call
110
98
  def get_type(type)
99
+
111
100
  # the base uri for api requests
112
101
  _query_builder = Configuration.base_uri.dup
113
102
 
@@ -124,37 +113,30 @@ module SuggestGrid
124
113
 
125
114
  # prepare headers
126
115
  _headers = {
127
- 'user-agent' => 'SUGGESTGRID',
128
116
  'accept' => 'application/json'
129
117
  }
118
+
119
+ # create the HttpRequest object for the call
120
+ _request = @http_client.get _query_url, headers: _headers
130
121
 
131
- # Create the HttpRequest object for the call
132
- _request = @http_client.get _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
133
-
134
- # Call the on_before_request callback
135
- @http_call_back.on_before_request(_request) if @http_call_back
136
-
137
- # Invoke the API call and get the response
138
- _response = @http_client.execute_as_string(_request)
122
+ # apply authentication
123
+ BasicAuth.apply(_request)
139
124
 
140
- # Wrap the request and response in an HttpContext object
141
- _context = HttpContext.new(_request, _response)
125
+ # execute the request
126
+ _context = execute_request(_request)
142
127
 
143
- # Call the on_after_response callback
144
- @http_call_back.on_after_response(_context) if @http_call_back
145
-
146
- # Endpoint error handling using HTTP status codes.
147
- if _response.status_code == 429
128
+ # endpoint error handling using HTTP status codes.
129
+ if _context.response.status_code == 429
148
130
  raise ErrorResponseException.new '429 - Too many requests.', _context
149
- elsif _response.status_code == 500
131
+ elsif _context.response.status_code == 500
150
132
  raise APIException.new '500 - Unexpected internal error.', _context
151
133
  end
152
134
 
153
- # Global error handling using HTTP status codes.
135
+ # global error handling using HTTP status codes.
154
136
  validate_response(_context)
155
137
 
156
- # Return appropriate response type
157
- decoded = APIHelper.json_deserialize(_response.raw_body)
138
+ # return appropriate response type
139
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
158
140
  return GetTypeResponse.from_hash(decoded)
159
141
  end
160
142
 
@@ -164,6 +146,7 @@ module SuggestGrid
164
146
  # @return MessageResponse response from the API call
165
147
  def create_type(type,
166
148
  settings = nil)
149
+
167
150
  # the base uri for api requests
168
151
  _query_builder = Configuration.base_uri.dup
169
152
 
@@ -180,44 +163,37 @@ module SuggestGrid
180
163
 
181
164
  # prepare headers
182
165
  _headers = {
183
- 'user-agent' => 'SUGGESTGRID',
184
166
  'accept' => 'application/json',
185
167
  'content-type' => 'application/json; charset=utf-8'
186
168
  }
169
+
170
+ # create the HttpRequest object for the call
171
+ _request = @http_client.put _query_url, headers: _headers, parameters: settings.to_json
187
172
 
188
- # Create the HttpRequest object for the call
189
- _request = @http_client.put _query_url, headers: _headers, parameters: settings.to_json, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
190
-
191
- # Call the on_before_request callback
192
- @http_call_back.on_before_request(_request) if @http_call_back
193
-
194
- # Invoke the API call and get the response
195
- _response = @http_client.execute_as_string(_request)
196
-
197
- # Wrap the request and response in an HttpContext object
198
- _context = HttpContext.new(_request, _response)
173
+ # apply authentication
174
+ BasicAuth.apply(_request)
199
175
 
200
- # Call the on_after_response callback
201
- @http_call_back.on_after_response(_context) if @http_call_back
176
+ # execute the request
177
+ _context = execute_request(_request)
202
178
 
203
- # Endpoint error handling using HTTP status codes.
204
- if _response.status_code == 402
179
+ # endpoint error handling using HTTP status codes.
180
+ if _context.response.status_code == 402
205
181
  raise LimitExceededErrorResponseException.new '402 - Type limit reached.', _context
206
- elsif _response.status_code == 409
182
+ elsif _context.response.status_code == 409
207
183
  raise ErrorResponseException.new '409 - Type already exists.', _context
208
- elsif _response.status_code == 422
184
+ elsif _context.response.status_code == 422
209
185
  raise ErrorResponseException.new '422 - Rating type is not `implicit` or `explicit`.', _context
210
- elsif _response.status_code == 429
186
+ elsif _context.response.status_code == 429
211
187
  raise ErrorResponseException.new '429 - Too many requests.', _context
212
- elsif _response.status_code == 500
188
+ elsif _context.response.status_code == 500
213
189
  raise APIException.new '500 - Unexpected internal error.', _context
214
190
  end
215
191
 
216
- # Global error handling using HTTP status codes.
192
+ # global error handling using HTTP status codes.
217
193
  validate_response(_context)
218
194
 
219
- # Return appropriate response type
220
- decoded = APIHelper.json_deserialize(_response.raw_body)
195
+ # return appropriate response type
196
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
221
197
  return MessageResponse.from_hash(decoded)
222
198
  end
223
199
 
@@ -225,6 +201,7 @@ module SuggestGrid
225
201
  # @param [String] type Required parameter: The name of the type to be deleted.
226
202
  # @return MessageResponse response from the API call
227
203
  def delete_type(type)
204
+
228
205
  # the base uri for api requests
229
206
  _query_builder = Configuration.base_uri.dup
230
207
 
@@ -241,39 +218,32 @@ module SuggestGrid
241
218
 
242
219
  # prepare headers
243
220
  _headers = {
244
- 'user-agent' => 'SUGGESTGRID',
245
221
  'accept' => 'application/json'
246
222
  }
223
+
224
+ # create the HttpRequest object for the call
225
+ _request = @http_client.delete _query_url, headers: _headers
247
226
 
248
- # Create the HttpRequest object for the call
249
- _request = @http_client.delete _query_url, headers: _headers, username: Configuration.basic_auth_user_name, password: Configuration.basic_auth_password
250
-
251
- # Call the on_before_request callback
252
- @http_call_back.on_before_request(_request) if @http_call_back
253
-
254
- # Invoke the API call and get the response
255
- _response = @http_client.execute_as_string(_request)
256
-
257
- # Wrap the request and response in an HttpContext object
258
- _context = HttpContext.new(_request, _response)
227
+ # apply authentication
228
+ BasicAuth.apply(_request)
259
229
 
260
- # Call the on_after_response callback
261
- @http_call_back.on_after_response(_context) if @http_call_back
230
+ # execute the request
231
+ _context = execute_request(_request)
262
232
 
263
- # Endpoint error handling using HTTP status codes.
264
- if _response.status_code == 404
233
+ # endpoint error handling using HTTP status codes.
234
+ if _context.response.status_code == 404
265
235
  raise ErrorResponseException.new '404 - Type does not exists.', _context
266
- elsif _response.status_code == 429
236
+ elsif _context.response.status_code == 429
267
237
  raise ErrorResponseException.new '429 - Too many requests.', _context
268
- elsif _response.status_code == 500
238
+ elsif _context.response.status_code == 500
269
239
  raise APIException.new '500 - Unexpected internal error.', _context
270
240
  end
271
241
 
272
- # Global error handling using HTTP status codes.
242
+ # global error handling using HTTP status codes.
273
243
  validate_response(_context)
274
244
 
275
- # Return appropriate response type
276
- decoded = APIHelper.json_deserialize(_response.raw_body)
245
+ # return appropriate response type
246
+ decoded = APIHelper.json_deserialize(_context.response.raw_body)
277
247
  return MessageResponse.from_hash(decoded)
278
248
  end
279
249
  end
@@ -10,7 +10,7 @@ module SuggestGrid
10
10
  def initialize(reason, context)
11
11
  super(reason)
12
12
  @context = context
13
- @response_code = context.response.status_code
13
+ @response_code = context.response.status_code
14
14
  end
15
15
  end
16
16
  end
@@ -0,0 +1,52 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class DeleteErrorResponseException < APIException
5
+ # Message of the response.
6
+ # @return [String]
7
+ attr_accessor :error_text
8
+
9
+ # Description of the response.
10
+ # @return [String]
11
+ attr_accessor :error_description
12
+
13
+ # URI of the response for more details.
14
+ # @return [String]
15
+ attr_accessor :error_uri
16
+
17
+ # The number of records found for the delete query.
18
+ # @return [Integer]
19
+ attr_accessor :found
20
+
21
+ # The number of records deleted for the delete query.
22
+ # @return [Integer]
23
+ attr_accessor :deleted
24
+
25
+ # The number of records found but not deleted for the delete query.
26
+ # @return [Integer]
27
+ attr_accessor :failed
28
+
29
+ # The constructor.
30
+ # @param [String] The reason for raising an exception
31
+ # @param [HttpContext] The HttpContext of the API call.
32
+ def initialize(reason, context)
33
+ super(reason, context)
34
+ begin
35
+ hash = APIHelper.json_deserialize(@context.response.raw_body)
36
+ unbox(hash)
37
+ rescue TypeError
38
+ end
39
+ end
40
+
41
+ # Populates this object by extracting properties from a hash.
42
+ # @param [Hash] The deserialized response sent by the server in the response body.
43
+ def unbox(hash)
44
+ @error_text = hash["error_text"]
45
+ @error_description = hash["error_description"]
46
+ @error_uri = hash["error_uri"]
47
+ @found = hash["found"]
48
+ @deleted = hash["deleted"]
49
+ @failed = hash["failed"]
50
+ end
51
+ end
52
+ end
@@ -26,10 +26,10 @@ module SuggestGrid
26
26
  begin
27
27
  hash = APIHelper.json_deserialize(@context.response.raw_body)
28
28
  unbox(hash)
29
- rescue TypeError
30
- end
29
+ rescue TypeError
30
+ end
31
31
  end
32
-
32
+
33
33
  # Populates this object by extracting properties from a hash.
34
34
  # @param [Hash] The deserialized response sent by the server in the response body.
35
35
  def unbox(hash)
@@ -22,10 +22,10 @@ module SuggestGrid
22
22
  begin
23
23
  hash = APIHelper.json_deserialize(@context.response.raw_body)
24
24
  unbox(hash)
25
- rescue TypeError
26
- end
25
+ rescue TypeError
26
+ end
27
27
  end
28
-
28
+
29
29
  # Populates this object by extracting properties from a hash.
30
30
  # @param [Hash] The deserialized response sent by the server in the response body.
31
31
  def unbox(hash)