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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/suggestgrid/api_helper.rb +146 -54
  3. data/lib/suggestgrid/configuration.rb +5 -2
  4. data/lib/suggestgrid/controllers/action_controller.rb +178 -79
  5. data/lib/suggestgrid/controllers/base_controller.rb +18 -15
  6. data/lib/suggestgrid/controllers/metadata_controller.rb +313 -171
  7. data/lib/suggestgrid/controllers/recommendation_controller.rb +75 -35
  8. data/lib/suggestgrid/controllers/similarity_controller.rb +75 -35
  9. data/lib/suggestgrid/controllers/type_controller.rb +131 -74
  10. data/lib/suggestgrid/exceptions/api_exception.rb +4 -2
  11. data/lib/suggestgrid/exceptions/{detailed_error_response_error_exception.rb → detailed_error_response.rb} +9 -9
  12. data/lib/suggestgrid/exceptions/{error_response_error_exception.rb → error_response.rb} +9 -9
  13. data/lib/suggestgrid/exceptions/{limit_exceeded_error_response_error_exception.rb → limit_exceeded_error_response.rb} +9 -9
  14. data/lib/suggestgrid/http/auth/basic_auth.rb +8 -5
  15. data/lib/suggestgrid/http/faraday_client.rb +19 -7
  16. data/lib/suggestgrid/http/http_call_back.rb +11 -6
  17. data/lib/suggestgrid/http/http_client.rb +50 -32
  18. data/lib/suggestgrid/http/http_context.rb +5 -2
  19. data/lib/suggestgrid/http/http_method_enum.rb +6 -2
  20. data/lib/suggestgrid/http/http_request.rb +7 -3
  21. data/lib/suggestgrid/http/http_response.rb +3 -1
  22. data/lib/suggestgrid/models/action.rb +15 -14
  23. data/lib/suggestgrid/models/actions_response.rb +16 -14
  24. data/lib/suggestgrid/models/base_model.rb +11 -9
  25. data/lib/suggestgrid/models/bulk_post_error.rb +11 -11
  26. data/lib/suggestgrid/models/bulk_post_response.rb +16 -13
  27. data/lib/suggestgrid/models/get_recommended_items_body.rb +32 -25
  28. data/lib/suggestgrid/models/get_recommended_users_body.rb +32 -25
  29. data/lib/suggestgrid/models/get_similar_items_body.rb +33 -24
  30. data/lib/suggestgrid/models/get_similar_users_body.rb +30 -23
  31. data/lib/suggestgrid/models/get_type_response.rb +9 -9
  32. data/lib/suggestgrid/models/get_types_response.rb +9 -9
  33. data/lib/suggestgrid/models/items_response.rb +16 -14
  34. data/lib/suggestgrid/models/message_response.rb +9 -9
  35. data/lib/suggestgrid/models/metadata.rb +9 -8
  36. data/lib/suggestgrid/models/type_request_body.rb +11 -10
  37. data/lib/suggestgrid/models/users_response.rb +16 -14
  38. data/lib/suggestgrid/suggestgrid_client.rb +16 -14
  39. data/lib/suggestgrid.rb +5 -4
  40. data/spec/swagger.yaml +3 -3
  41. metadata +8 -8
@@ -1,87 +1,127 @@
1
- # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
2
3
 
3
4
  module SuggestGrid
5
+ # RecommendationController
4
6
  class RecommendationController < BaseController
5
- @@instance = RecommendationController.new
6
- # Singleton instance of the controller class
7
- def self.instance
8
- @@instance
7
+ @instance = RecommendationController.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
- # Gets Recommended Users
12
- # @param [GetRecommendedUsersBody] query Required parameter: Query for recommended users.
17
+ # Returns recommended users for the query.
18
+ # @param [GetRecommendedUsersBody] query Required parameter: Query for
19
+ # recommended users.
13
20
  # @return UsersResponse response from the API call
14
21
  def get_recommended_users(query)
15
-
16
- # prepare query url
22
+ # Prepare query url.
17
23
  _query_builder = Configuration.base_uri.dup
18
24
  _query_builder << '/v1/recommend/users'
19
25
  _query_url = APIHelper.clean_url _query_builder
20
26
 
21
- # prepare headers
27
+ # Prepare headers.
22
28
  _headers = {
23
29
  'accept' => 'application/json',
24
30
  'content-type' => 'application/json; charset=utf-8'
25
31
  }
26
32
 
27
- # prepare and execute HttpRequest
28
- _request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
33
+ # Prepare and execute HttpRequest.
34
+ _request = @http_client.post(
35
+ _query_url,
36
+ headers: _headers,
37
+ parameters: query.to_json
38
+ )
29
39
  BasicAuth.apply(_request)
30
40
  _context = execute_request(_request)
31
41
 
32
- # validate response against endpoint and global error codes
42
+ # Validate response against endpoint and global error codes.
33
43
  if _context.response.status_code == 400
34
- raise ErrorResponseErrorException.new 'Request body is invalid.', _context
44
+ raise ErrorResponse.new(
45
+ 'Request body is invalid.',
46
+ _context
47
+ )
35
48
  elsif _context.response.status_code == 404
36
- raise ErrorResponseErrorException.new 'At least one type in the request does not exist.', _context
49
+ raise ErrorResponse.new(
50
+ 'At least one type in the request does not exist.',
51
+ _context
52
+ )
37
53
  elsif _context.response.status_code == 422
38
- raise ErrorResponseErrorException.new 'Required parameters are missing.', _context
39
- elsif !_context.response.status_code.between?(200, 208)
40
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
54
+ raise ErrorResponse.new(
55
+ 'Required parameters are missing.',
56
+ _context
57
+ )
58
+ end
59
+ unless _context.response.status_code.between?(200, 208)
60
+ raise ErrorResponse.new(
61
+ 'Unexpected internal error.',
62
+ _context
63
+ )
41
64
  end
42
65
  validate_response(_context)
43
66
 
44
- # return appropriate response type
67
+ # Return appropriate response type.
45
68
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
46
- return UsersResponse.from_hash(decoded)
69
+ UsersResponse.from_hash(decoded)
47
70
  end
48
71
 
49
- # Gets Recommended Items
50
- # @param [GetRecommendedItemsBody] query Required parameter: Query for recommended items.
72
+ # Returns recommended items for the query.
73
+ # @param [GetRecommendedItemsBody] query Required parameter: Query for
74
+ # recommended items.
51
75
  # @return ItemsResponse response from the API call
52
76
  def get_recommended_items(query)
53
-
54
- # prepare query url
77
+ # Prepare query url.
55
78
  _query_builder = Configuration.base_uri.dup
56
79
  _query_builder << '/v1/recommend/items'
57
80
  _query_url = APIHelper.clean_url _query_builder
58
81
 
59
- # prepare headers
82
+ # Prepare headers.
60
83
  _headers = {
61
84
  'accept' => 'application/json',
62
85
  'content-type' => 'application/json; charset=utf-8'
63
86
  }
64
87
 
65
- # prepare and execute HttpRequest
66
- _request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
88
+ # Prepare and execute HttpRequest.
89
+ _request = @http_client.post(
90
+ _query_url,
91
+ headers: _headers,
92
+ parameters: query.to_json
93
+ )
67
94
  BasicAuth.apply(_request)
68
95
  _context = execute_request(_request)
69
96
 
70
- # validate response against endpoint and global error codes
97
+ # Validate response against endpoint and global error codes.
71
98
  if _context.response.status_code == 400
72
- raise ErrorResponseErrorException.new 'Request body is invalid.', _context
99
+ raise ErrorResponse.new(
100
+ 'Request body is invalid.',
101
+ _context
102
+ )
73
103
  elsif _context.response.status_code == 404
74
- raise ErrorResponseErrorException.new 'At least one type in the request does not exist.', _context
104
+ raise ErrorResponse.new(
105
+ 'At least one type in the request does not exist.',
106
+ _context
107
+ )
75
108
  elsif _context.response.status_code == 422
76
- raise ErrorResponseErrorException.new 'Required parameters are missing.', _context
77
- elsif !_context.response.status_code.between?(200, 208)
78
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
109
+ raise ErrorResponse.new(
110
+ 'Required parameters are missing.',
111
+ _context
112
+ )
113
+ end
114
+ unless _context.response.status_code.between?(200, 208)
115
+ raise ErrorResponse.new(
116
+ 'Unexpected internal error.',
117
+ _context
118
+ )
79
119
  end
80
120
  validate_response(_context)
81
121
 
82
- # return appropriate response type
122
+ # Return appropriate response type.
83
123
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
84
- return ItemsResponse.from_hash(decoded)
124
+ ItemsResponse.from_hash(decoded)
85
125
  end
86
126
  end
87
127
  end
@@ -1,87 +1,127 @@
1
- # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
2
3
 
3
4
  module SuggestGrid
5
+ # SimilarityController
4
6
  class SimilarityController < BaseController
5
- @@instance = SimilarityController.new
6
- # Singleton instance of the controller class
7
- def self.instance
8
- @@instance
7
+ @instance = SimilarityController.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
- # Gets Similar Users
12
- # @param [GetSimilarUsersBody] query Required parameter: Query for similar users.
17
+ # Returns similar users for the query.
18
+ # @param [GetSimilarUsersBody] query Required parameter: Query for similar
19
+ # users.
13
20
  # @return UsersResponse response from the API call
14
21
  def get_similar_users(query)
15
-
16
- # prepare query url
22
+ # Prepare query url.
17
23
  _query_builder = Configuration.base_uri.dup
18
24
  _query_builder << '/v1/similar/users'
19
25
  _query_url = APIHelper.clean_url _query_builder
20
26
 
21
- # prepare headers
27
+ # Prepare headers.
22
28
  _headers = {
23
29
  'accept' => 'application/json',
24
30
  'content-type' => 'application/json; charset=utf-8'
25
31
  }
26
32
 
27
- # prepare and execute HttpRequest
28
- _request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
33
+ # Prepare and execute HttpRequest.
34
+ _request = @http_client.post(
35
+ _query_url,
36
+ headers: _headers,
37
+ parameters: query.to_json
38
+ )
29
39
  BasicAuth.apply(_request)
30
40
  _context = execute_request(_request)
31
41
 
32
- # validate response against endpoint and global error codes
42
+ # Validate response against endpoint and global error codes.
33
43
  if _context.response.status_code == 400
34
- raise ErrorResponseErrorException.new 'Request body is invalid.', _context
44
+ raise ErrorResponse.new(
45
+ 'Request body is invalid.',
46
+ _context
47
+ )
35
48
  elsif _context.response.status_code == 404
36
- raise ErrorResponseErrorException.new 'At least one type in the request does not exist.', _context
49
+ raise ErrorResponse.new(
50
+ 'At least one type in the request does not exist.',
51
+ _context
52
+ )
37
53
  elsif _context.response.status_code == 422
38
- raise ErrorResponseErrorException.new 'Required parameters are missing.', _context
39
- elsif !_context.response.status_code.between?(200, 208)
40
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
54
+ raise ErrorResponse.new(
55
+ 'Required parameters are missing.',
56
+ _context
57
+ )
58
+ end
59
+ unless _context.response.status_code.between?(200, 208)
60
+ raise ErrorResponse.new(
61
+ 'Unexpected internal error.',
62
+ _context
63
+ )
41
64
  end
42
65
  validate_response(_context)
43
66
 
44
- # return appropriate response type
67
+ # Return appropriate response type.
45
68
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
46
- return UsersResponse.from_hash(decoded)
69
+ UsersResponse.from_hash(decoded)
47
70
  end
48
71
 
49
- # Gets Similar Items
50
- # @param [GetSimilarItemsBody] query Required parameter: Query for similar items.
72
+ # Returns similar items for the query.
73
+ # @param [GetSimilarItemsBody] query Required parameter: Query for similar
74
+ # items.
51
75
  # @return ItemsResponse response from the API call
52
76
  def get_similar_items(query)
53
-
54
- # prepare query url
77
+ # Prepare query url.
55
78
  _query_builder = Configuration.base_uri.dup
56
79
  _query_builder << '/v1/similar/items'
57
80
  _query_url = APIHelper.clean_url _query_builder
58
81
 
59
- # prepare headers
82
+ # Prepare headers.
60
83
  _headers = {
61
84
  'accept' => 'application/json',
62
85
  'content-type' => 'application/json; charset=utf-8'
63
86
  }
64
87
 
65
- # prepare and execute HttpRequest
66
- _request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
88
+ # Prepare and execute HttpRequest.
89
+ _request = @http_client.post(
90
+ _query_url,
91
+ headers: _headers,
92
+ parameters: query.to_json
93
+ )
67
94
  BasicAuth.apply(_request)
68
95
  _context = execute_request(_request)
69
96
 
70
- # validate response against endpoint and global error codes
97
+ # Validate response against endpoint and global error codes.
71
98
  if _context.response.status_code == 400
72
- raise ErrorResponseErrorException.new 'Request body is invalid.', _context
99
+ raise ErrorResponse.new(
100
+ 'Request body is invalid.',
101
+ _context
102
+ )
73
103
  elsif _context.response.status_code == 404
74
- raise ErrorResponseErrorException.new 'At least one type in the request does not exist.', _context
104
+ raise ErrorResponse.new(
105
+ 'At least one type in the request does not exist.',
106
+ _context
107
+ )
75
108
  elsif _context.response.status_code == 422
76
- raise ErrorResponseErrorException.new 'Required parameters are missing.', _context
77
- elsif !_context.response.status_code.between?(200, 208)
78
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
109
+ raise ErrorResponse.new(
110
+ 'Required parameters are missing.',
111
+ _context
112
+ )
113
+ end
114
+ unless _context.response.status_code.between?(200, 208)
115
+ raise ErrorResponse.new(
116
+ 'Unexpected internal error.',
117
+ _context
118
+ )
79
119
  end
80
120
  validate_response(_context)
81
121
 
82
- # return appropriate response type
122
+ # Return appropriate response type.
83
123
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
84
- return ItemsResponse.from_hash(decoded)
124
+ ItemsResponse.from_hash(decoded)
85
125
  end
86
126
  end
87
127
  end
@@ -1,186 +1,243 @@
1
- # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
2
3
 
3
4
  module SuggestGrid
5
+ # TypeController
4
6
  class TypeController < BaseController
5
- @@instance = TypeController.new
6
- # Singleton instance of the controller class
7
- def self.instance
8
- @@instance
7
+ @instance = TypeController.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
- # Creates a Type
17
+ # Creates a new type.
12
18
  # @param [String] type Required parameter: The name of the type.
13
- # @param [TypeRequestBody] settings Optional parameter: Optional settings for the rating parameter.
19
+ # @param [TypeRequestBody] settings Optional parameter: Optional settings
20
+ # for the rating parameter.
14
21
  # @return MessageResponse response from the API call
15
22
  def create_type(type,
16
23
  settings = nil)
17
-
18
- # prepare query url
24
+ # Prepare query url.
19
25
  _query_builder = Configuration.base_uri.dup
20
26
  _query_builder << '/v1/types/{type}'
21
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
27
+ _query_builder = APIHelper.append_url_with_template_parameters(
28
+ _query_builder,
22
29
  'type' => type
23
- }
30
+ )
24
31
  _query_url = APIHelper.clean_url _query_builder
25
32
 
26
- # prepare headers
33
+ # Prepare headers.
27
34
  _headers = {
28
35
  'accept' => 'application/json',
29
36
  'content-type' => 'application/json; charset=utf-8'
30
37
  }
31
38
 
32
- # prepare and execute HttpRequest
33
- _request = @http_client.put _query_url, headers: _headers, parameters: settings.to_json
39
+ # Prepare and execute HttpRequest.
40
+ _request = @http_client.put(
41
+ _query_url,
42
+ headers: _headers,
43
+ parameters: settings.to_json
44
+ )
34
45
  BasicAuth.apply(_request)
35
46
  _context = execute_request(_request)
36
47
 
37
- # validate response against endpoint and global error codes
48
+ # Validate response against endpoint and global error codes.
38
49
  if _context.response.status_code == 402
39
- raise LimitExceededErrorResponseErrorException.new 'Type limit reached.', _context
50
+ raise LimitExceededErrorResponse.new(
51
+ 'Type limit reached.',
52
+ _context
53
+ )
40
54
  elsif _context.response.status_code == 409
41
- raise ErrorResponseErrorException.new 'Type already exists.', _context
55
+ raise ErrorResponse.new(
56
+ 'Type already exists.',
57
+ _context
58
+ )
42
59
  elsif _context.response.status_code == 422
43
- raise ErrorResponseErrorException.new 'Rating type is not `implicit` or `explicit`.', _context
44
- elsif !_context.response.status_code.between?(200, 208)
45
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
60
+ raise ErrorResponse.new(
61
+ 'Rating type is not `implicit` or `explicit`.',
62
+ _context
63
+ )
64
+ end
65
+ unless _context.response.status_code.between?(200, 208)
66
+ raise ErrorResponse.new(
67
+ 'Unexpected internal error.',
68
+ _context
69
+ )
46
70
  end
47
71
  validate_response(_context)
48
72
 
49
- # return appropriate response type
73
+ # Return appropriate response type.
50
74
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
51
- return MessageResponse.from_hash(decoded)
75
+ MessageResponse.from_hash(decoded)
52
76
  end
53
77
 
54
- # Gets Properties of a Type
55
- # @param [String] type Required parameter: The name of the type to get properties.
78
+ # Returns the options of a type. The response rating parameter.
79
+ # @param [String] type Required parameter: The name of the type to get
80
+ # properties.
56
81
  # @return GetTypeResponse response from the API call
57
82
  def get_type(type)
58
-
59
- # prepare query url
83
+ # Prepare query url.
60
84
  _query_builder = Configuration.base_uri.dup
61
85
  _query_builder << '/v1/types/{type}'
62
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
86
+ _query_builder = APIHelper.append_url_with_template_parameters(
87
+ _query_builder,
63
88
  'type' => type
64
- }
89
+ )
65
90
  _query_url = APIHelper.clean_url _query_builder
66
91
 
67
- # prepare headers
92
+ # Prepare headers.
68
93
  _headers = {
69
94
  'accept' => 'application/json'
70
95
  }
71
96
 
72
- # prepare and execute HttpRequest
73
- _request = @http_client.get _query_url, headers: _headers
97
+ # Prepare and execute HttpRequest.
98
+ _request = @http_client.get(
99
+ _query_url,
100
+ headers: _headers
101
+ )
74
102
  BasicAuth.apply(_request)
75
103
  _context = execute_request(_request)
76
104
 
77
- # validate response against endpoint and global error codes
105
+ # Validate response against endpoint and global error codes.
78
106
  if _context.response.status_code == 404
79
- raise ErrorResponseErrorException.new 'Type does not exists.', _context
80
- elsif !_context.response.status_code.between?(200, 208)
81
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
107
+ raise ErrorResponse.new(
108
+ 'Type does not exists.',
109
+ _context
110
+ )
111
+ end
112
+ unless _context.response.status_code.between?(200, 208)
113
+ raise ErrorResponse.new(
114
+ 'Unexpected internal error.',
115
+ _context
116
+ )
82
117
  end
83
118
  validate_response(_context)
84
119
 
85
- # return appropriate response type
120
+ # Return appropriate response type.
86
121
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
87
- return GetTypeResponse.from_hash(decoded)
122
+ GetTypeResponse.from_hash(decoded)
88
123
  end
89
124
 
90
- # Deletes a Type
91
- # @param [String] type Required parameter: The name of the type to be deleted.
125
+ # Warning: Deletes the type with all of its actions and its recommendation
126
+ # model.
127
+ # @param [String] type Required parameter: The name of the type to be
128
+ # deleted.
92
129
  # @return MessageResponse response from the API call
93
130
  def delete_type(type)
94
-
95
- # prepare query url
131
+ # Prepare query url.
96
132
  _query_builder = Configuration.base_uri.dup
97
133
  _query_builder << '/v1/types/{type}'
98
- _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
134
+ _query_builder = APIHelper.append_url_with_template_parameters(
135
+ _query_builder,
99
136
  'type' => type
100
- }
137
+ )
101
138
  _query_url = APIHelper.clean_url _query_builder
102
139
 
103
- # prepare headers
140
+ # Prepare headers.
104
141
  _headers = {
105
142
  'accept' => 'application/json'
106
143
  }
107
144
 
108
- # prepare and execute HttpRequest
109
- _request = @http_client.delete _query_url, headers: _headers
145
+ # Prepare and execute HttpRequest.
146
+ _request = @http_client.delete(
147
+ _query_url,
148
+ headers: _headers
149
+ )
110
150
  BasicAuth.apply(_request)
111
151
  _context = execute_request(_request)
112
152
 
113
- # validate response against endpoint and global error codes
153
+ # Validate response against endpoint and global error codes.
114
154
  if _context.response.status_code == 404
115
- raise ErrorResponseErrorException.new 'Action type does not exists.', _context
116
- elsif !_context.response.status_code.between?(200, 208)
117
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
155
+ raise ErrorResponse.new(
156
+ 'Action type does not exists.',
157
+ _context
158
+ )
159
+ end
160
+ unless _context.response.status_code.between?(200, 208)
161
+ raise ErrorResponse.new(
162
+ 'Unexpected internal error.',
163
+ _context
164
+ )
118
165
  end
119
166
  validate_response(_context)
120
167
 
121
- # return appropriate response type
168
+ # Return appropriate response type.
122
169
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
123
- return MessageResponse.from_hash(decoded)
170
+ MessageResponse.from_hash(decoded)
124
171
  end
125
172
 
126
- # Gets All Types
173
+ # Returns all type names in an array named types.
127
174
  # @return GetTypesResponse response from the API call
128
175
  def get_all_types
129
-
130
- # prepare query url
176
+ # Prepare query url.
131
177
  _query_builder = Configuration.base_uri.dup
132
178
  _query_builder << '/v1/types'
133
179
  _query_url = APIHelper.clean_url _query_builder
134
180
 
135
- # prepare headers
181
+ # Prepare headers.
136
182
  _headers = {
137
183
  'accept' => 'application/json'
138
184
  }
139
185
 
140
- # prepare and execute HttpRequest
141
- _request = @http_client.get _query_url, headers: _headers
186
+ # Prepare and execute HttpRequest.
187
+ _request = @http_client.get(
188
+ _query_url,
189
+ headers: _headers
190
+ )
142
191
  BasicAuth.apply(_request)
143
192
  _context = execute_request(_request)
144
193
 
145
- # validate response against endpoint and global error codes
146
- if _context.response.status_code == 0
147
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
194
+ # Validate response against endpoint and global error codes.
195
+ unless _context.response.status_code.between?(200, 208)
196
+ raise ErrorResponse.new(
197
+ 'Unexpected internal error.',
198
+ _context
199
+ )
148
200
  end
149
201
  validate_response(_context)
150
202
 
151
- # return appropriate response type
203
+ # Return appropriate response type.
152
204
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
153
- return GetTypesResponse.from_hash(decoded)
205
+ GetTypesResponse.from_hash(decoded)
154
206
  end
155
207
 
156
- # Deletes All Types
208
+ # Deletes ALL the types and ALL the actions.
157
209
  # @return MessageResponse response from the API call
158
210
  def delete_all_types
159
-
160
- # prepare query url
211
+ # Prepare query url.
161
212
  _query_builder = Configuration.base_uri.dup
162
213
  _query_builder << '/v1/types'
163
214
  _query_url = APIHelper.clean_url _query_builder
164
215
 
165
- # prepare headers
216
+ # Prepare headers.
166
217
  _headers = {
167
218
  'accept' => 'application/json'
168
219
  }
169
220
 
170
- # prepare and execute HttpRequest
171
- _request = @http_client.delete _query_url, headers: _headers
221
+ # Prepare and execute HttpRequest.
222
+ _request = @http_client.delete(
223
+ _query_url,
224
+ headers: _headers
225
+ )
172
226
  BasicAuth.apply(_request)
173
227
  _context = execute_request(_request)
174
228
 
175
- # validate response against endpoint and global error codes
176
- if _context.response.status_code == 0
177
- raise ErrorResponseErrorException.new 'Unexpected internal error.', _context
229
+ # Validate response against endpoint and global error codes.
230
+ unless _context.response.status_code.between?(200, 208)
231
+ raise ErrorResponse.new(
232
+ 'Unexpected internal error.',
233
+ _context
234
+ )
178
235
  end
179
236
  validate_response(_context)
180
237
 
181
- # return appropriate response type
238
+ # Return appropriate response type.
182
239
  decoded = APIHelper.json_deserialize(_context.response.raw_body)
183
- return MessageResponse.from_hash(decoded)
240
+ MessageResponse.from_hash(decoded)
184
241
  end
185
242
  end
186
243
  end
@@ -1,11 +1,13 @@
1
- # This file was automatically generated for SuggestGrid by APIMATIC v2.0 ( https://apimatic.io ).
1
+ # This file was automatically generated for SuggestGrid by APIMATIC v2.0
2
+ # ( https://apimatic.io ).
2
3
 
3
4
  module SuggestGrid
5
+ # Class for exceptions when there is a network error, status code error, etc.
4
6
  class APIException < StandardError
5
7
  attr_reader :context, :response_code
6
8
 
7
9
  # The constructor.
8
- # @param [String] The reason for raising an exception
10
+ # @param [String] The reason for raising an exception.
9
11
  # @param [HttpContext] The HttpContext of the API call.
10
12
  def initialize(reason, context)
11
13
  super(reason)