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,119 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class SimilarityController < BaseController
5
+ @@instance = SimilarityController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # Get Similar Users
12
+ # @param [GetSimilarUsersBody] body Required parameter: Similar users method parameters.
13
+ # @return UsersResponse response from the API call
14
+ def get_similar_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/similar/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 Similar Items
66
+ # @param [GetSimilarItemsBody] body Required parameter: Similar items method parameter.
67
+ # @return ItemsResponse response from the API call
68
+ def get_similar_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/similar/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
@@ -0,0 +1,280 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class TypeController < BaseController
5
+ @@instance = TypeController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # Get All Types
12
+ # @return GetTypesResponse response from the API call
13
+ def get_all_types
14
+ # the base uri for api requests
15
+ _query_builder = Configuration.base_uri.dup
16
+
17
+ # prepare query string for API call
18
+ _query_builder << '/v1/types'
19
+
20
+ # validate and preprocess url
21
+ _query_url = APIHelper.clean_url _query_builder
22
+
23
+ # prepare headers
24
+ _headers = {
25
+ 'user-agent' => 'SUGGESTGRID',
26
+ 'accept' => 'application/json'
27
+ }
28
+
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)
37
+
38
+ # Wrap the request and response in an HttpContext object
39
+ _context = HttpContext.new(_request, _response)
40
+
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
46
+ raise APIException.new '429 - Too many requests.', _context
47
+ elsif _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(_response.raw_body)
56
+ return GetTypesResponse.from_hash(decoded)
57
+ end
58
+
59
+ # Delete All Types
60
+ # @return GetTypesResponse response from the API call
61
+ def delete_all_types
62
+ # the base uri for api requests
63
+ _query_builder = Configuration.base_uri.dup
64
+
65
+ # prepare query string for API call
66
+ _query_builder << '/v1/types'
67
+
68
+ # validate and preprocess url
69
+ _query_url = APIHelper.clean_url _query_builder
70
+
71
+ # prepare headers
72
+ _headers = {
73
+ 'user-agent' => 'SUGGESTGRID',
74
+ 'accept' => 'application/json'
75
+ }
76
+
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
82
+
83
+ # Invoke the API call and get the response
84
+ _response = @http_client.execute_as_string(_request)
85
+
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
94
+ raise APIException.new '429 - Too many requests.', _context
95
+ elsif _response.status_code == 500
96
+ raise APIException.new '500 - Unexpected internal error.', _context
97
+ end
98
+
99
+ # Global error handling using HTTP status codes.
100
+ validate_response(_context)
101
+
102
+ # Return appropriate response type
103
+ decoded = APIHelper.json_deserialize(_response.raw_body)
104
+ return GetTypesResponse.from_hash(decoded)
105
+ end
106
+
107
+ # Get Properties of a Type
108
+ # @param [String] type Required parameter: The name of the type to get properties.
109
+ # @return GetTypeResponse response from the API call
110
+ def get_type(type)
111
+ # the base uri for api requests
112
+ _query_builder = Configuration.base_uri.dup
113
+
114
+ # prepare query string for API call
115
+ _query_builder << '/v1/types/{type}'
116
+
117
+ # process optional query parameters
118
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
119
+ 'type' => type
120
+ }
121
+
122
+ # validate and preprocess url
123
+ _query_url = APIHelper.clean_url _query_builder
124
+
125
+ # prepare headers
126
+ _headers = {
127
+ 'user-agent' => 'SUGGESTGRID',
128
+ 'accept' => 'application/json'
129
+ }
130
+
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)
139
+
140
+ # Wrap the request and response in an HttpContext object
141
+ _context = HttpContext.new(_request, _response)
142
+
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
148
+ raise APIException.new '429 - Too many requests.', _context
149
+ elsif _response.status_code == 500
150
+ raise APIException.new '500 - Unexpected internal error.', _context
151
+ end
152
+
153
+ # Global error handling using HTTP status codes.
154
+ validate_response(_context)
155
+
156
+ # Return appropriate response type
157
+ decoded = APIHelper.json_deserialize(_response.raw_body)
158
+ return GetTypeResponse.from_hash(decoded)
159
+ end
160
+
161
+ # Create a New Type
162
+ # @param [String] type Required parameter: The name of the type to be created.
163
+ # @param [TypeRequestBody] body Optional parameter: Optional body for the rating parameter.
164
+ # @return MessageResponse response from the API call
165
+ def create_type(type,
166
+ body = nil)
167
+ # the base uri for api requests
168
+ _query_builder = Configuration.base_uri.dup
169
+
170
+ # prepare query string for API call
171
+ _query_builder << '/v1/types/{type}'
172
+
173
+ # process optional query parameters
174
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
175
+ 'type' => type
176
+ }
177
+
178
+ # validate and preprocess url
179
+ _query_url = APIHelper.clean_url _query_builder
180
+
181
+ # prepare headers
182
+ _headers = {
183
+ 'user-agent' => 'SUGGESTGRID',
184
+ 'accept' => 'application/json',
185
+ 'content-type' => 'application/json; charset=utf-8'
186
+ }
187
+
188
+ # Create the HttpRequest object for the call
189
+ _request = @http_client.put _query_url, headers: _headers, parameters: body.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)
199
+
200
+ # Call the on_after_response callback
201
+ @http_call_back.on_after_response(_context) if @http_call_back
202
+
203
+ # Endpoint error handling using HTTP status codes.
204
+ if _response.status_code == 402
205
+ raise APIException.new '402 - Type limit reached.', _context
206
+ elsif _response.status_code == 409
207
+ raise APIException.new '409 - Type already exists.', _context
208
+ elsif _response.status_code == 422
209
+ raise APIException.new '422 - Rating type is not `implicit` or `explicit`.', _context
210
+ elsif _response.status_code == 429
211
+ raise APIException.new '429 - Too many requests.', _context
212
+ elsif _response.status_code == 500
213
+ raise APIException.new '500 - Unexpected internal error.', _context
214
+ end
215
+
216
+ # Global error handling using HTTP status codes.
217
+ validate_response(_context)
218
+
219
+ # Return appropriate response type
220
+ decoded = APIHelper.json_deserialize(_response.raw_body)
221
+ return MessageResponse.from_hash(decoded)
222
+ end
223
+
224
+ # Delete a Type
225
+ # @param [String] type Required parameter: The name of the type to be deleted.
226
+ # @return MessageResponse response from the API call
227
+ def delete_type(type)
228
+ # the base uri for api requests
229
+ _query_builder = Configuration.base_uri.dup
230
+
231
+ # prepare query string for API call
232
+ _query_builder << '/v1/types/{type}'
233
+
234
+ # process optional query parameters
235
+ _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
236
+ 'type' => type
237
+ }
238
+
239
+ # validate and preprocess url
240
+ _query_url = APIHelper.clean_url _query_builder
241
+
242
+ # prepare headers
243
+ _headers = {
244
+ 'user-agent' => 'SUGGESTGRID',
245
+ 'accept' => 'application/json'
246
+ }
247
+
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)
259
+
260
+ # Call the on_after_response callback
261
+ @http_call_back.on_after_response(_context) if @http_call_back
262
+
263
+ # Endpoint error handling using HTTP status codes.
264
+ if _response.status_code == 404
265
+ raise APIException.new '404 - Type does not exists.', _context
266
+ elsif _response.status_code == 429
267
+ raise APIException.new '429 - Too many requests.', _context
268
+ elsif _response.status_code == 500
269
+ raise APIException.new '500 - Unexpected internal error.', _context
270
+ end
271
+
272
+ # Global error handling using HTTP status codes.
273
+ validate_response(_context)
274
+
275
+ # Return appropriate response type
276
+ decoded = APIHelper.json_deserialize(_response.raw_body)
277
+ return MessageResponse.from_hash(decoded)
278
+ end
279
+ end
280
+ end
@@ -0,0 +1,16 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class APIException < StandardError
5
+ attr_reader :context, :response_code
6
+
7
+ # The constructor.
8
+ # @param [String] The reason for raising an exception
9
+ # @param [HttpContext] The HttpContext of the API call.
10
+ def initialize(reason, context)
11
+ super(reason)
12
+ @context = context
13
+ @response_code = context.response.status_code
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class HttpCallBack
5
+ # A controller will call this method before making an HTTP Request.
6
+ # @param [HttpRequest] The HttpRequest object which the HttpClient will execute.
7
+ def on_before_request(http_request)
8
+ raise NotImplementedError, "This method needs to be implemented in a child class."
9
+ end
10
+
11
+ # A controller will call this method after making an HTTP Request.
12
+ # @param [HttpResponse] The HttpResponse object received from the HttpClient.
13
+ def on_after_response(http_response)
14
+ raise NotImplementedError, "This method needs to be implemented in a child class."
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,112 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class HttpClient
5
+ # Execute an HttpRequest when the response is expected to be a string.
6
+ # @param [HttpRequest] The HttpRequest to be executed.
7
+ def execute_as_string(http_request)
8
+ raise NotImplementedError, "This method needs to be implemented in a child class."
9
+ end
10
+
11
+ # Execute an HttpRequest when the response is expected to be binary.
12
+ # @param [HttpRequest] The HttpRequest to be executed.
13
+ def execute_as_binary(http_request)
14
+ raise NotImplementedError, "This method needs to be implemented in a child class."
15
+ end
16
+
17
+ # Converts the HTTP Response from the client to an HttpResponse object.
18
+ # @param [Dynamic] The response object received from the client.
19
+ def convert_response(response)
20
+ raise NotImplementedError, "This method needs to be implemented in a child class."
21
+ end
22
+
23
+ # Get a GET HttpRequest object.
24
+ # @param [String] The URL to send the request to.
25
+ # @param [Hash, Optional] The headers for the HTTP Request.
26
+ # @param [String, Optional] Username for Basic Auth requests.
27
+ # @param [String, Optional] Password for Basic Auth requests.
28
+ def get(query_url,
29
+ headers: nil,
30
+ username: nil,
31
+ password: nil)
32
+ return HttpRequest.new(HttpMethodEnum::GET,
33
+ query_url,
34
+ headers: headers,
35
+ username: username,
36
+ password: password)
37
+ end
38
+
39
+ # Get a POST HttpRequest object.
40
+ # @param [String] The URL to send the request to.
41
+ # @param [Hash, Optional] The headers for the HTTP Request.
42
+ # @param [Hash, Optional] The parameters for the HTTP Request.
43
+ # @param [String, Optional] Username for Basic Auth requests.
44
+ # @param [String, Optional] Password for Basic Auth requests.
45
+ def post(query_url,
46
+ headers: nil,
47
+ parameters: nil,
48
+ username: nil,
49
+ password: nil)
50
+ return HttpRequest.new(HttpMethodEnum::POST,
51
+ query_url,
52
+ headers: headers,
53
+ parameters: parameters,
54
+ username: username,
55
+ password: password)
56
+ end
57
+
58
+ # Get a PUT HttpRequest object.
59
+ # @param [String] The URL to send the request to.
60
+ # @param [Hash, Optional] The headers for the HTTP Request.
61
+ # @param [Hash, Optional] The parameters for the HTTP Request.
62
+ # @param [String, Optional] Username for Basic Auth requests.
63
+ # @param [String, Optional] Password for Basic Auth requests.
64
+ def put(query_url,
65
+ headers: nil,
66
+ parameters: nil,
67
+ username: nil,
68
+ password: nil)
69
+ return HttpRequest.new(HttpMethodEnum::PUT,
70
+ query_url,
71
+ headers: headers,
72
+ parameters: parameters,
73
+ username: username,
74
+ password: password)
75
+ end
76
+
77
+ # Get a PATCH HttpRequest object.
78
+ # @param [String] The URL to send the request to.
79
+ # @param [Hash, Optional] The headers for the HTTP Request.
80
+ # @param [Hash, Optional] The parameters for the HTTP Request.
81
+ # @param [String, Optional] Username for Basic Auth requests.
82
+ # @param [String, Optional] Password for Basic Auth requests.
83
+ def patch(query_url,
84
+ headers: nil,
85
+ parameters: nil,
86
+ username: nil,
87
+ password: nil)
88
+ return HttpRequest.new(HttpMethodEnum::PATCH,
89
+ query_url,
90
+ headers: headers,
91
+ parameters: parameters,
92
+ username: username,
93
+ password: password)
94
+ end
95
+
96
+ # Get a DELETE HttpRequest object.
97
+ # @param [String] The URL to send the request to.
98
+ # @param [Hash, Optional] The headers for the HTTP Request.
99
+ # @param [String, Optional] Username for Basic Auth requests.
100
+ # @param [String, Optional] Password for Basic Auth requests.
101
+ def delete(query_url,
102
+ headers: nil,
103
+ username: nil,
104
+ password: nil)
105
+ return HttpRequest.new(HttpMethodEnum::DELETE,
106
+ query_url,
107
+ headers: headers,
108
+ username: username,
109
+ password: password)
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,15 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class HttpContext
5
+ attr_accessor :request, :response
6
+
7
+ # The constructor.
8
+ # @param [HttpRequest] An HttpRequest object representing the HTTP request.
9
+ # @param [HttpResponse] An HttpResponse object representing the HTTP response.
10
+ def initialize(request, response)
11
+ @request = request
12
+ @response = response
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class HttpMethodEnum
5
+ HTTPMETHODENUM = [GET = "GET", POST = "POST", PUT = "PUT", PATCH = "PATCH", DELETE = "DELETE"]
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class HttpRequest
5
+ attr_accessor :http_method, :query_url, :headers, :parameters, :username, :password
6
+
7
+ # The constructor.
8
+ # @param [HttpMethodEnum] The HTTP method.
9
+ # @param [String] The URL to send the request to.
10
+ # @param [Hash, Optional] The headers for the HTTP Request.
11
+ # @param [Hash, Optional] The parameters for the HTTP Request.
12
+ # @param [String, Optional] Username for Basic Auth requests.
13
+ # @param [String, Optional] Password for Basic Auth requests.
14
+ def initialize(http_method,
15
+ query_url,
16
+ headers: nil,
17
+ parameters: nil,
18
+ username: nil,
19
+ password: nil)
20
+ @http_method = http_method
21
+ @query_url = query_url
22
+ @headers = headers
23
+ @parameters = parameters
24
+ @username = username
25
+ @password = password
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ module SuggestGrid
4
+ class HttpResponse
5
+ attr_accessor :status_code, :headers, :raw_body
6
+
7
+ # The constructor.
8
+ # @param [Integer] The status code returned by the server.
9
+ # @param [Hash] The headers sent by the server in the response.
10
+ # @param [String] The raw body of the response.
11
+ def initialize(status_code,
12
+ headers,
13
+ raw_body)
14
+ @status_code = status_code
15
+ @headers = headers
16
+ @raw_body = raw_body
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,41 @@
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
2
+ module SuggestGrid
3
+ class UnirestClient < HttpClient
4
+ # Method overridden from HttpClient.
5
+ def execute_as_string(http_request)
6
+
7
+ response = get_connection(http_request.username, http_request.password)
8
+ .send(http_request.http_method.downcase, http_request.query_url) do |faraday_request|
9
+ faraday_request.headers = http_request.headers
10
+ faraday_request.body = http_request.parameters
11
+ end
12
+
13
+ return convert_response(response)
14
+ end
15
+
16
+ # Method overridden from HttpClient.
17
+ def execute_as_binary(http_request)
18
+
19
+ response = get_connection(http_request.username, http_request.password)
20
+ .send(http_request.http_method.downcase, http_request.query_url) do |faraday_request|
21
+ faraday_request.headers = http_request.headers
22
+ faraday_request.body = http_request.parameters
23
+ end
24
+
25
+ return convert_response(response)
26
+ end
27
+
28
+ # Method overridden from HttpClient.
29
+ def convert_response(response)
30
+ return HttpResponse.new(response.status, response.headers, response.body)
31
+ end
32
+
33
+ def get_connection(user_name, password)
34
+ Faraday.new do |builder|
35
+ builder.request :retry
36
+ builder.request :basic_auth, user_name, password if user_name
37
+ builder.adapter :net_http
38
+ end
39
+ end
40
+ end
41
+ end