suggestgrid 0.1.27 → 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/suggest_grid/api_helper.rb +6 -0
- data/lib/suggest_grid/configuration.rb +1 -0
- data/lib/suggest_grid/controllers/action_controller.rb +94 -142
- data/lib/suggest_grid/controllers/base_controller.rb +3 -2
- data/lib/suggest_grid/controllers/metadata_controller.rb +182 -330
- data/lib/suggest_grid/controllers/recommendation_controller.rb +18 -42
- data/lib/suggest_grid/controllers/similarity_controller.rb +18 -42
- data/lib/suggest_grid/controllers/type_controller.rb +76 -140
- data/lib/suggest_grid/exceptions/delete_error_response_exception.rb +7 -7
- data/lib/suggest_grid/exceptions/detailed_error_response_exception.rb +1 -1
- data/lib/suggest_grid/exceptions/error_response_exception.rb +1 -1
- data/lib/suggest_grid/exceptions/limit_exceeded_error_response_exception.rb +3 -3
- data/lib/suggest_grid/http/faraday_client.rb +3 -1
- data/lib/suggest_grid/http/http_client.rb +4 -2
- data/lib/suggest_grid/models/action.rb +19 -2
- data/lib/suggest_grid/models/actions_response.rb +10 -2
- data/lib/suggest_grid/models/base_model.rb +17 -0
- data/lib/suggest_grid/models/bulk_post_error.rb +10 -2
- data/lib/suggest_grid/models/bulk_post_response.rb +10 -2
- data/lib/suggest_grid/models/delete_success_response.rb +16 -8
- data/lib/suggest_grid/models/get_recommended_items_body.rb +16 -8
- data/lib/suggest_grid/models/get_recommended_users_body.rb +16 -8
- data/lib/suggest_grid/models/get_similar_items_body.rb +15 -7
- data/lib/suggest_grid/models/get_similar_users_body.rb +15 -7
- data/lib/suggest_grid/models/get_type_response.rb +10 -2
- data/lib/suggest_grid/models/get_types_response.rb +8 -9
- data/lib/suggest_grid/models/items_response.rb +10 -2
- data/lib/suggest_grid/models/message_response.rb +10 -2
- data/lib/suggest_grid/models/metadata.rb +19 -10
- data/lib/suggest_grid/models/type_request_body.rb +11 -5
- data/lib/suggest_grid/models/users_response.rb +10 -2
- data/lib/suggest_grid.rb +2 -0
- data/spec/swagger.yaml +122 -194
- metadata +21 -7
@@ -9,17 +9,13 @@ module SuggestGrid
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# Get Recommended Users
|
12
|
-
# @param [GetRecommendedUsersBody] query Required parameter:
|
12
|
+
# @param [GetRecommendedUsersBody] query Required parameter: Query for recommended users.
|
13
13
|
# @return UsersResponse response from the API call
|
14
14
|
def get_recommended_users(query)
|
15
15
|
|
16
|
-
#
|
16
|
+
# prepare query url
|
17
17
|
_query_builder = Configuration.base_uri.dup
|
18
|
-
|
19
|
-
# prepare query string for API call
|
20
18
|
_query_builder << '/v1/recommend/users'
|
21
|
-
|
22
|
-
# validate and preprocess url
|
23
19
|
_query_url = APIHelper.clean_url _query_builder
|
24
20
|
|
25
21
|
# prepare headers
|
@@ -27,28 +23,20 @@ module SuggestGrid
|
|
27
23
|
'accept' => 'application/json',
|
28
24
|
'content-type' => 'application/json; charset=utf-8'
|
29
25
|
}
|
30
|
-
|
31
|
-
# create the HttpRequest object for the call
|
32
|
-
_request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
|
33
26
|
|
34
|
-
#
|
27
|
+
# prepare and execute HttpRequest
|
28
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
|
35
29
|
BasicAuth.apply(_request)
|
36
|
-
|
37
|
-
# execute the request
|
38
30
|
_context = execute_request(_request)
|
39
31
|
|
40
|
-
#
|
32
|
+
# validate response against endpoint and global error codes
|
41
33
|
if _context.response.status_code == 400
|
42
|
-
raise ErrorResponseException.new '
|
34
|
+
raise ErrorResponseException.new 'Request body is invalid.', _context
|
43
35
|
elsif _context.response.status_code == 422
|
44
|
-
raise ErrorResponseException.new '
|
45
|
-
elsif _context.response.status_code
|
46
|
-
raise ErrorResponseException.new '
|
47
|
-
elsif _context.response.status_code == 500
|
48
|
-
raise APIException.new '500 - Unexpected internal error.', _context
|
36
|
+
raise ErrorResponseException.new 'Required parameters are missing.', _context
|
37
|
+
elsif !_context.response.status_code.between?(200, 208)
|
38
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
49
39
|
end
|
50
|
-
|
51
|
-
# global error handling using HTTP status codes.
|
52
40
|
validate_response(_context)
|
53
41
|
|
54
42
|
# return appropriate response type
|
@@ -57,17 +45,13 @@ module SuggestGrid
|
|
57
45
|
end
|
58
46
|
|
59
47
|
# Get Recommended Items
|
60
|
-
# @param [GetRecommendedItemsBody] query Required parameter:
|
48
|
+
# @param [GetRecommendedItemsBody] query Required parameter: Query for recommended items.
|
61
49
|
# @return ItemsResponse response from the API call
|
62
50
|
def get_recommended_items(query)
|
63
51
|
|
64
|
-
#
|
52
|
+
# prepare query url
|
65
53
|
_query_builder = Configuration.base_uri.dup
|
66
|
-
|
67
|
-
# prepare query string for API call
|
68
54
|
_query_builder << '/v1/recommend/items'
|
69
|
-
|
70
|
-
# validate and preprocess url
|
71
55
|
_query_url = APIHelper.clean_url _query_builder
|
72
56
|
|
73
57
|
# prepare headers
|
@@ -75,28 +59,20 @@ module SuggestGrid
|
|
75
59
|
'accept' => 'application/json',
|
76
60
|
'content-type' => 'application/json; charset=utf-8'
|
77
61
|
}
|
78
|
-
|
79
|
-
# create the HttpRequest object for the call
|
80
|
-
_request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
|
81
62
|
|
82
|
-
#
|
63
|
+
# prepare and execute HttpRequest
|
64
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
|
83
65
|
BasicAuth.apply(_request)
|
84
|
-
|
85
|
-
# execute the request
|
86
66
|
_context = execute_request(_request)
|
87
67
|
|
88
|
-
#
|
68
|
+
# validate response against endpoint and global error codes
|
89
69
|
if _context.response.status_code == 400
|
90
|
-
raise ErrorResponseException.new '
|
70
|
+
raise ErrorResponseException.new 'Request body is invalid.', _context
|
91
71
|
elsif _context.response.status_code == 422
|
92
|
-
raise ErrorResponseException.new '
|
93
|
-
elsif _context.response.status_code
|
94
|
-
raise ErrorResponseException.new '
|
95
|
-
elsif _context.response.status_code == 500
|
96
|
-
raise APIException.new '500 - Unexpected internal error.', _context
|
72
|
+
raise ErrorResponseException.new 'Required parameters are missing.', _context
|
73
|
+
elsif !_context.response.status_code.between?(200, 208)
|
74
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
97
75
|
end
|
98
|
-
|
99
|
-
# global error handling using HTTP status codes.
|
100
76
|
validate_response(_context)
|
101
77
|
|
102
78
|
# return appropriate response type
|
@@ -9,17 +9,13 @@ module SuggestGrid
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# Get Similar Users
|
12
|
-
# @param [GetSimilarUsersBody] query Required parameter:
|
12
|
+
# @param [GetSimilarUsersBody] query Required parameter: Query for similar users.
|
13
13
|
# @return UsersResponse response from the API call
|
14
14
|
def get_similar_users(query)
|
15
15
|
|
16
|
-
#
|
16
|
+
# prepare query url
|
17
17
|
_query_builder = Configuration.base_uri.dup
|
18
|
-
|
19
|
-
# prepare query string for API call
|
20
18
|
_query_builder << '/v1/similar/users'
|
21
|
-
|
22
|
-
# validate and preprocess url
|
23
19
|
_query_url = APIHelper.clean_url _query_builder
|
24
20
|
|
25
21
|
# prepare headers
|
@@ -27,28 +23,20 @@ module SuggestGrid
|
|
27
23
|
'accept' => 'application/json',
|
28
24
|
'content-type' => 'application/json; charset=utf-8'
|
29
25
|
}
|
30
|
-
|
31
|
-
# create the HttpRequest object for the call
|
32
|
-
_request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
|
33
26
|
|
34
|
-
#
|
27
|
+
# prepare and execute HttpRequest
|
28
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
|
35
29
|
BasicAuth.apply(_request)
|
36
|
-
|
37
|
-
# execute the request
|
38
30
|
_context = execute_request(_request)
|
39
31
|
|
40
|
-
#
|
32
|
+
# validate response against endpoint and global error codes
|
41
33
|
if _context.response.status_code == 400
|
42
|
-
raise ErrorResponseException.new '
|
34
|
+
raise ErrorResponseException.new 'Request body is invalid.', _context
|
43
35
|
elsif _context.response.status_code == 422
|
44
|
-
raise ErrorResponseException.new '
|
45
|
-
elsif _context.response.status_code
|
46
|
-
raise ErrorResponseException.new '
|
47
|
-
elsif _context.response.status_code == 500
|
48
|
-
raise APIException.new '500 - Unexpected internal error.', _context
|
36
|
+
raise ErrorResponseException.new 'Required parameters are missing.', _context
|
37
|
+
elsif !_context.response.status_code.between?(200, 208)
|
38
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
49
39
|
end
|
50
|
-
|
51
|
-
# global error handling using HTTP status codes.
|
52
40
|
validate_response(_context)
|
53
41
|
|
54
42
|
# return appropriate response type
|
@@ -57,17 +45,13 @@ module SuggestGrid
|
|
57
45
|
end
|
58
46
|
|
59
47
|
# Get Similar Items
|
60
|
-
# @param [GetSimilarItemsBody] query Required parameter:
|
48
|
+
# @param [GetSimilarItemsBody] query Required parameter: Query for similar items.
|
61
49
|
# @return ItemsResponse response from the API call
|
62
50
|
def get_similar_items(query)
|
63
51
|
|
64
|
-
#
|
52
|
+
# prepare query url
|
65
53
|
_query_builder = Configuration.base_uri.dup
|
66
|
-
|
67
|
-
# prepare query string for API call
|
68
54
|
_query_builder << '/v1/similar/items'
|
69
|
-
|
70
|
-
# validate and preprocess url
|
71
55
|
_query_url = APIHelper.clean_url _query_builder
|
72
56
|
|
73
57
|
# prepare headers
|
@@ -75,28 +59,20 @@ module SuggestGrid
|
|
75
59
|
'accept' => 'application/json',
|
76
60
|
'content-type' => 'application/json; charset=utf-8'
|
77
61
|
}
|
78
|
-
|
79
|
-
# create the HttpRequest object for the call
|
80
|
-
_request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
|
81
62
|
|
82
|
-
#
|
63
|
+
# prepare and execute HttpRequest
|
64
|
+
_request = @http_client.post _query_url, headers: _headers, parameters: query.to_json
|
83
65
|
BasicAuth.apply(_request)
|
84
|
-
|
85
|
-
# execute the request
|
86
66
|
_context = execute_request(_request)
|
87
67
|
|
88
|
-
#
|
68
|
+
# validate response against endpoint and global error codes
|
89
69
|
if _context.response.status_code == 400
|
90
|
-
raise ErrorResponseException.new '
|
70
|
+
raise ErrorResponseException.new 'Request body is invalid.', _context
|
91
71
|
elsif _context.response.status_code == 422
|
92
|
-
raise ErrorResponseException.new '
|
93
|
-
elsif _context.response.status_code
|
94
|
-
raise ErrorResponseException.new '
|
95
|
-
elsif _context.response.status_code == 500
|
96
|
-
raise APIException.new '500 - Unexpected internal error.', _context
|
72
|
+
raise ErrorResponseException.new 'Required parameters are missing.', _context
|
73
|
+
elsif !_context.response.status_code.between?(200, 208)
|
74
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
97
75
|
end
|
98
|
-
|
99
|
-
# global error handling using HTTP status codes.
|
100
76
|
validate_response(_context)
|
101
77
|
|
102
78
|
# return appropriate response type
|
@@ -8,238 +8,174 @@ module SuggestGrid
|
|
8
8
|
@@instance
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
12
|
-
# @
|
13
|
-
|
11
|
+
# Create a New Type
|
12
|
+
# @param [String] type Required parameter: The name of the type.
|
13
|
+
# @param [TypeRequestBody] settings Optional parameter: Optional settings for the rating parameter.
|
14
|
+
# @return MessageResponse response from the API call
|
15
|
+
def create_type(type,
|
16
|
+
settings = nil)
|
14
17
|
|
15
|
-
#
|
18
|
+
# prepare query url
|
16
19
|
_query_builder = Configuration.base_uri.dup
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# validate and preprocess url
|
20
|
+
_query_builder << '/v1/types/{type}'
|
21
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
22
|
+
'type' => type
|
23
|
+
}
|
22
24
|
_query_url = APIHelper.clean_url _query_builder
|
23
25
|
|
24
26
|
# prepare headers
|
25
27
|
_headers = {
|
26
|
-
'accept' => 'application/json'
|
28
|
+
'accept' => 'application/json',
|
29
|
+
'content-type' => 'application/json; charset=utf-8'
|
27
30
|
}
|
28
|
-
|
29
|
-
# create the HttpRequest object for the call
|
30
|
-
_request = @http_client.get _query_url, headers: _headers
|
31
31
|
|
32
|
-
#
|
32
|
+
# prepare and execute HttpRequest
|
33
|
+
_request = @http_client.put _query_url, headers: _headers, parameters: settings.to_json
|
33
34
|
BasicAuth.apply(_request)
|
34
|
-
|
35
|
-
# execute the request
|
36
35
|
_context = execute_request(_request)
|
37
36
|
|
38
|
-
#
|
39
|
-
if _context.response.status_code ==
|
40
|
-
raise
|
41
|
-
elsif _context.response.status_code ==
|
42
|
-
raise
|
37
|
+
# validate response against endpoint and global error codes
|
38
|
+
if _context.response.status_code == 402
|
39
|
+
raise LimitExceededErrorResponseException.new 'Type limit reached.', _context
|
40
|
+
elsif _context.response.status_code == 409
|
41
|
+
raise ErrorResponseException.new 'Type already exists.', _context
|
42
|
+
elsif _context.response.status_code == 422
|
43
|
+
raise ErrorResponseException.new 'Rating type is not `implicit` or `explicit`.', _context
|
44
|
+
elsif !_context.response.status_code.between?(200, 208)
|
45
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
43
46
|
end
|
44
|
-
|
45
|
-
# global error handling using HTTP status codes.
|
46
47
|
validate_response(_context)
|
47
48
|
|
48
49
|
# return appropriate response type
|
49
50
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
50
|
-
return
|
51
|
+
return MessageResponse.from_hash(decoded)
|
51
52
|
end
|
52
53
|
|
53
|
-
#
|
54
|
-
# @
|
55
|
-
|
54
|
+
# Get Properties of a Type
|
55
|
+
# @param [String] type Required parameter: The name of the type to get properties.
|
56
|
+
# @return GetTypeResponse response from the API call
|
57
|
+
def get_type(type)
|
56
58
|
|
57
|
-
#
|
59
|
+
# prepare query url
|
58
60
|
_query_builder = Configuration.base_uri.dup
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
# validate and preprocess url
|
61
|
+
_query_builder << '/v1/types/{type}'
|
62
|
+
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
63
|
+
'type' => type
|
64
|
+
}
|
64
65
|
_query_url = APIHelper.clean_url _query_builder
|
65
66
|
|
66
67
|
# prepare headers
|
67
68
|
_headers = {
|
68
69
|
'accept' => 'application/json'
|
69
70
|
}
|
70
|
-
|
71
|
-
# create the HttpRequest object for the call
|
72
|
-
_request = @http_client.delete _query_url, headers: _headers
|
73
71
|
|
74
|
-
#
|
72
|
+
# prepare and execute HttpRequest
|
73
|
+
_request = @http_client.get _query_url, headers: _headers
|
75
74
|
BasicAuth.apply(_request)
|
76
|
-
|
77
|
-
# execute the request
|
78
75
|
_context = execute_request(_request)
|
79
76
|
|
80
|
-
#
|
81
|
-
if _context.response.status_code ==
|
82
|
-
raise ErrorResponseException.new '
|
83
|
-
elsif _context.response.status_code
|
84
|
-
raise
|
77
|
+
# validate response against endpoint and global error codes
|
78
|
+
if _context.response.status_code == 404
|
79
|
+
raise ErrorResponseException.new 'Type does not exists.', _context
|
80
|
+
elsif !_context.response.status_code.between?(200, 208)
|
81
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
85
82
|
end
|
86
|
-
|
87
|
-
# global error handling using HTTP status codes.
|
88
83
|
validate_response(_context)
|
89
84
|
|
90
85
|
# return appropriate response type
|
91
86
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
92
|
-
return
|
87
|
+
return GetTypeResponse.from_hash(decoded)
|
93
88
|
end
|
94
89
|
|
95
|
-
#
|
96
|
-
# @param [String] type Required parameter: The name of the type to
|
97
|
-
# @return
|
98
|
-
def
|
90
|
+
# Delete a Type
|
91
|
+
# @param [String] type Required parameter: The name of the type to be deleted.
|
92
|
+
# @return MessageResponse response from the API call
|
93
|
+
def delete_type(type)
|
99
94
|
|
100
|
-
#
|
95
|
+
# prepare query url
|
101
96
|
_query_builder = Configuration.base_uri.dup
|
102
|
-
|
103
|
-
# prepare query string for API call
|
104
97
|
_query_builder << '/v1/types/{type}'
|
105
|
-
|
106
|
-
# process optional query parameters
|
107
98
|
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
108
99
|
'type' => type
|
109
100
|
}
|
110
|
-
|
111
|
-
# validate and preprocess url
|
112
101
|
_query_url = APIHelper.clean_url _query_builder
|
113
102
|
|
114
103
|
# prepare headers
|
115
104
|
_headers = {
|
116
105
|
'accept' => 'application/json'
|
117
106
|
}
|
118
|
-
|
119
|
-
# create the HttpRequest object for the call
|
120
|
-
_request = @http_client.get _query_url, headers: _headers
|
121
107
|
|
122
|
-
#
|
108
|
+
# prepare and execute HttpRequest
|
109
|
+
_request = @http_client.delete _query_url, headers: _headers
|
123
110
|
BasicAuth.apply(_request)
|
124
|
-
|
125
|
-
# execute the request
|
126
111
|
_context = execute_request(_request)
|
127
112
|
|
128
|
-
#
|
129
|
-
if _context.response.status_code ==
|
130
|
-
raise ErrorResponseException.new '
|
131
|
-
elsif _context.response.status_code
|
132
|
-
raise
|
113
|
+
# validate response against endpoint and global error codes
|
114
|
+
if _context.response.status_code == 404
|
115
|
+
raise ErrorResponseException.new 'Action type does not exists.', _context
|
116
|
+
elsif !_context.response.status_code.between?(200, 208)
|
117
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
133
118
|
end
|
134
|
-
|
135
|
-
# global error handling using HTTP status codes.
|
136
119
|
validate_response(_context)
|
137
120
|
|
138
121
|
# return appropriate response type
|
139
122
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
140
|
-
return
|
123
|
+
return MessageResponse.from_hash(decoded)
|
141
124
|
end
|
142
125
|
|
143
|
-
#
|
144
|
-
# @
|
145
|
-
|
146
|
-
# @return MessageResponse response from the API call
|
147
|
-
def create_type(type,
|
148
|
-
settings = nil)
|
126
|
+
# Get All Types
|
127
|
+
# @return GetTypesResponse response from the API call
|
128
|
+
def get_all_types
|
149
129
|
|
150
|
-
#
|
130
|
+
# prepare query url
|
151
131
|
_query_builder = Configuration.base_uri.dup
|
152
|
-
|
153
|
-
# prepare query string for API call
|
154
|
-
_query_builder << '/v1/types/{type}'
|
155
|
-
|
156
|
-
# process optional query parameters
|
157
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
158
|
-
'type' => type
|
159
|
-
}
|
160
|
-
|
161
|
-
# validate and preprocess url
|
132
|
+
_query_builder << '/v1/types'
|
162
133
|
_query_url = APIHelper.clean_url _query_builder
|
163
134
|
|
164
135
|
# prepare headers
|
165
136
|
_headers = {
|
166
|
-
'accept' => 'application/json'
|
167
|
-
'content-type' => 'application/json; charset=utf-8'
|
137
|
+
'accept' => 'application/json'
|
168
138
|
}
|
169
|
-
|
170
|
-
# create the HttpRequest object for the call
|
171
|
-
_request = @http_client.put _query_url, headers: _headers, parameters: settings.to_json
|
172
139
|
|
173
|
-
#
|
140
|
+
# prepare and execute HttpRequest
|
141
|
+
_request = @http_client.get _query_url, headers: _headers
|
174
142
|
BasicAuth.apply(_request)
|
175
|
-
|
176
|
-
# execute the request
|
177
143
|
_context = execute_request(_request)
|
178
144
|
|
179
|
-
#
|
180
|
-
if _context.response.status_code ==
|
181
|
-
raise
|
182
|
-
elsif _context.response.status_code == 409
|
183
|
-
raise ErrorResponseException.new '409 - Type already exists.', _context
|
184
|
-
elsif _context.response.status_code == 422
|
185
|
-
raise ErrorResponseException.new '422 - Rating type is not `implicit` or `explicit`.', _context
|
186
|
-
elsif _context.response.status_code == 429
|
187
|
-
raise ErrorResponseException.new '429 - Too many requests.', _context
|
188
|
-
elsif _context.response.status_code == 500
|
189
|
-
raise APIException.new '500 - Unexpected internal error.', _context
|
145
|
+
# validate response against endpoint and global error codes
|
146
|
+
if _context.response.status_code == 0
|
147
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
190
148
|
end
|
191
|
-
|
192
|
-
# global error handling using HTTP status codes.
|
193
149
|
validate_response(_context)
|
194
150
|
|
195
151
|
# return appropriate response type
|
196
152
|
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
197
|
-
return
|
153
|
+
return GetTypesResponse.from_hash(decoded)
|
198
154
|
end
|
199
155
|
|
200
|
-
# Delete
|
201
|
-
# @param [String] type Required parameter: The name of the type to be deleted.
|
156
|
+
# Delete All Types
|
202
157
|
# @return MessageResponse response from the API call
|
203
|
-
def
|
158
|
+
def delete_all_types
|
204
159
|
|
205
|
-
#
|
160
|
+
# prepare query url
|
206
161
|
_query_builder = Configuration.base_uri.dup
|
207
|
-
|
208
|
-
# prepare query string for API call
|
209
|
-
_query_builder << '/v1/types/{type}'
|
210
|
-
|
211
|
-
# process optional query parameters
|
212
|
-
_query_builder = APIHelper.append_url_with_template_parameters _query_builder, {
|
213
|
-
'type' => type
|
214
|
-
}
|
215
|
-
|
216
|
-
# validate and preprocess url
|
162
|
+
_query_builder << '/v1/types'
|
217
163
|
_query_url = APIHelper.clean_url _query_builder
|
218
164
|
|
219
165
|
# prepare headers
|
220
166
|
_headers = {
|
221
167
|
'accept' => 'application/json'
|
222
168
|
}
|
223
|
-
|
224
|
-
# create the HttpRequest object for the call
|
225
|
-
_request = @http_client.delete _query_url, headers: _headers
|
226
169
|
|
227
|
-
#
|
170
|
+
# prepare and execute HttpRequest
|
171
|
+
_request = @http_client.delete _query_url, headers: _headers
|
228
172
|
BasicAuth.apply(_request)
|
229
|
-
|
230
|
-
# execute the request
|
231
173
|
_context = execute_request(_request)
|
232
174
|
|
233
|
-
#
|
234
|
-
if _context.response.status_code ==
|
235
|
-
raise ErrorResponseException.new '
|
236
|
-
elsif _context.response.status_code == 429
|
237
|
-
raise ErrorResponseException.new '429 - Too many requests.', _context
|
238
|
-
elsif _context.response.status_code == 500
|
239
|
-
raise APIException.new '500 - Unexpected internal error.', _context
|
175
|
+
# validate response against endpoint and global error codes
|
176
|
+
if _context.response.status_code == 0
|
177
|
+
raise ErrorResponseException.new 'Unexpected internal error.', _context
|
240
178
|
end
|
241
|
-
|
242
|
-
# global error handling using HTTP status codes.
|
243
179
|
validate_response(_context)
|
244
180
|
|
245
181
|
# return appropriate response type
|
@@ -10,20 +10,20 @@ module SuggestGrid
|
|
10
10
|
# @return [String]
|
11
11
|
attr_accessor :error_description
|
12
12
|
|
13
|
-
# URI of the
|
13
|
+
# The URI of the error for more details.
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :error_uri
|
16
16
|
|
17
|
-
# The number of records found
|
18
|
-
# @return [
|
17
|
+
# The number of records found.
|
18
|
+
# @return [Long]
|
19
19
|
attr_accessor :found
|
20
20
|
|
21
|
-
# The number of records deleted
|
22
|
-
# @return [
|
21
|
+
# The number of records deleted.
|
22
|
+
# @return [Long]
|
23
23
|
attr_accessor :deleted
|
24
24
|
|
25
|
-
# The number of records
|
26
|
-
# @return [
|
25
|
+
# The number of records failed to be deleted.
|
26
|
+
# @return [Long]
|
27
27
|
attr_accessor :failed
|
28
28
|
|
29
29
|
# The constructor.
|
@@ -10,16 +10,16 @@ module SuggestGrid
|
|
10
10
|
# @return [String]
|
11
11
|
attr_accessor :error_description
|
12
12
|
|
13
|
-
# URI of the
|
13
|
+
# The URI of the error for more details.
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :error_uri
|
16
16
|
|
17
17
|
# The quantity used by the account.
|
18
|
-
# @return [
|
18
|
+
# @return [Long]
|
19
19
|
attr_accessor :used
|
20
20
|
|
21
21
|
# The limit quantity of the account.
|
22
|
-
# @return [
|
22
|
+
# @return [Long]
|
23
23
|
attr_accessor :limit
|
24
24
|
|
25
25
|
# The constructor.
|
@@ -4,14 +4,16 @@ require 'faraday/http_cache'
|
|
4
4
|
module SuggestGrid
|
5
5
|
class FaradayClient < HttpClient
|
6
6
|
# The constructor.
|
7
|
-
def initialize(timeout: nil, cache: false)
|
7
|
+
def initialize(timeout: nil, cache: false, max_retries: nil, retry_interval: nil)
|
8
8
|
@connection = Faraday.new do |faraday|
|
9
9
|
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
10
10
|
faraday.request :multipart
|
11
11
|
faraday.request :url_encoded
|
12
12
|
faraday.ssl[:ca_file] = Certifi.where
|
13
13
|
faraday.adapter Faraday.default_adapter
|
14
|
+
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
14
15
|
faraday.options[:open_timeout] = timeout if timeout
|
16
|
+
faraday.request :retry, max: max_retries, interval: retry_interval if (max_retries and retry_interval)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -73,10 +73,12 @@ module SuggestGrid
|
|
73
73
|
# @param [String] The URL to send the request to.
|
74
74
|
# @param [Hash, Optional] The headers for the HTTP Request.
|
75
75
|
def delete(query_url,
|
76
|
-
headers: {}
|
76
|
+
headers: {},
|
77
|
+
parameters: {})
|
77
78
|
return HttpRequest.new(HttpMethodEnum::DELETE,
|
78
79
|
query_url,
|
79
|
-
headers: headers
|
80
|
+
headers: headers,
|
81
|
+
parameters: parameters)
|
80
82
|
end
|
81
83
|
end
|
82
84
|
end
|