Module: VsClient
- Defined in:
- lib/vs_client.rb,
lib/vs_client/version.rb,
lib/vs_client/net_http.rb,
lib/vs_client/response.rb,
lib/vs_client/configuration.rb
Defined Under Namespace
Classes: Configuration, NetHttp, Response
Constant Summary collapse
- CLIENT_ERROR =
'client'- REMOTE_ERROR =
'remote'- VERSION =
"0.8.8"
Class Method Summary collapse
- .configuration ⇒ VsClient::Configuration
-
.configure {|configuration| ... } ⇒ Object
Override the default configurations.
-
.create_recent_search(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /search/recent:.
-
.delete_recent_search(headers: {}, fallback: nil) ⇒ Hash, NilClass
DELETE /search/recent:.
-
.delete_recent_search_by_home_module_id(home_module_id:, headers: {}, fallback: nil) ⇒ Hash, NilClass
DELETE /search/recent/home_modules/id:.
-
.get_filters(query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /filters:.
-
.get_premium_vendors(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /vendors/premium:.
-
.get_search_autocomplete(query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /search/autocomplete:.
-
.get_search_suggestions(query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /search/suggestions:.
-
.get_swimlanes(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /swimlanes:.
-
.get_vendor_coverage(vendor_id:, query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /vendor-coverage/vendor_id:.
-
.get_vendors_by_campaign_id(id:, query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /campaigns/id/vendors:.
-
.get_vendors_coverage(query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /vendor-coverage/vendors:.
-
.get_vendors_listing(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /vendors:.
-
.get_vendors_search(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /vendors/search:.
Class Method Details
.configuration ⇒ VsClient::Configuration
14 15 16 |
# File 'lib/vs_client.rb', line 14 def configuration @configuration ||= VsClient::Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Override the default configurations
19 20 21 22 |
# File 'lib/vs_client.rb', line 19 def configure yield configuration setup_http_client end |
.create_recent_search(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /search/recent:
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vs_client.rb', line 54 def create_recent_search(payload:, headers: {}, fallback: nil) path = '/search/recent' @http_client.start_session response = @http_client.post(path: path, payload: payload, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, payload, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, payload, e, headers]) end |
.delete_recent_search(headers: {}, fallback: nil) ⇒ Hash, NilClass
DELETE /search/recent:
211 212 213 214 215 216 217 218 219 220 |
# File 'lib/vs_client.rb', line 211 def delete_recent_search(headers: {}, fallback: nil) path = "/search/recent" @http_client.start_session response = @http_client.delete(path: path, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, nil, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, nil, e, headers]) end |
.delete_recent_search_by_home_module_id(home_module_id:, headers: {}, fallback: nil) ⇒ Hash, NilClass
DELETE /search/recent/home_modules/id:
229 230 231 232 233 234 235 236 237 238 |
# File 'lib/vs_client.rb', line 229 def delete_recent_search_by_home_module_id(home_module_id:, headers: {}, fallback: nil) path = "/search/recent/home_modules/#{home_module_id}" @http_client.start_session response = @http_client.delete(path: path, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, nil, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, nil, e, headers]) end |
.get_filters(query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /filters:
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vs_client.rb', line 34 def get_filters(query:, headers: {}, fallback: nil) path = '/filters' @http_client.start_session response = @http_client.get(path: path, query: query, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, query, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, query, e, headers]) end |
.get_premium_vendors(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /vendors/premium:
263 264 265 266 267 268 269 270 271 |
# File 'lib/vs_client.rb', line 263 def get_premium_vendors(payload:, headers: {}, fallback: nil) path = '/vendors/premium' @http_client.start_session response = @http_client.post(path: path, payload: payload, headers: headers, desired_api_version: '/api/v2') return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, payload, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, payload, e, headers]) end |
.get_search_autocomplete(query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /search/autocomplete:
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/vs_client.rb', line 97 def get_search_autocomplete(query:, headers: {}, fallback: nil) path = '/search/autocomplete' @http_client.start_session response = @http_client.get(path: path, query: query, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, query, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, query, e, headers]) end |
.get_search_suggestions(query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /search/suggestions:
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/vs_client.rb', line 75 def get_search_suggestions(query:, headers: {}, fallback: nil) path = '/search/suggestions' @http_client.start_session response = @http_client.get(path: path, query: query, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, query, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, query, e, headers]) end |
.get_swimlanes(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /swimlanes:
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/vs_client.rb', line 124 def get_swimlanes(payload:, headers: {}, fallback: nil) path = '/swimlanes' @http_client.start_session response = @http_client.post(path: path, payload: payload, headers: headers, desired_api_version: '/api/v3') return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, payload, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, payload, e, headers]) end |
.get_vendor_coverage(vendor_id:, query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /vendor-coverage/vendor_id:
304 305 306 307 308 309 310 311 312 313 |
# File 'lib/vs_client.rb', line 304 def get_vendor_coverage(vendor_id:, query:, headers: {}, fallback: nil) path = "/vendor-coverage/#{vendor_id}" @http_client.start_session headers.merge!(json_api_headers) response = @http_client.get(path: path, query: query, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, query, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, query, e, headers]) end |
.get_vendors_by_campaign_id(id:, query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /campaigns/id/vendors:
335 336 337 338 339 340 341 342 343 |
# File 'lib/vs_client.rb', line 335 def get_vendors_by_campaign_id(id:, query:, headers: {}, fallback: nil) path = "/campaigns/#{id}/vendors" @http_client.start_session response = @http_client.get(path: path, query: query, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, query, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, query, e, headers]) end |
.get_vendors_coverage(query:, headers: {}, fallback: nil) ⇒ Hash, NilClass
GET /vendor-coverage/vendors:
284 285 286 287 288 289 290 291 292 293 |
# File 'lib/vs_client.rb', line 284 def get_vendors_coverage(query:, headers: {}, fallback: nil) path = '/vendor-coverage/vendors' @http_client.start_session headers.merge!(json_api_headers) response = @http_client.get(path: path, query: query, headers: headers) return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, query, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, query, e, headers]) end |
.get_vendors_listing(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /vendors:
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/vs_client.rb', line 194 def get_vendors_listing(payload:, headers: {}, fallback: nil) path = '/vendors' @http_client.start_session response = @http_client.post(path: path, payload: payload, headers: headers, desired_api_version: '/api/v2') return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, payload, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, payload, e, headers]) end |
.get_vendors_search(payload:, headers: {}, fallback: nil) ⇒ Hash, NilClass
POST /vendors/search:
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/vs_client.rb', line 159 def get_vendors_search(payload:, headers: {}, fallback: nil) path = '/vendors/search' @http_client.start_session response = @http_client.post(path: path, payload: payload, headers: headers, desired_api_version: '/api/v2') return response.body if response.succeeded? handle_failure(fallback, REMOTE_ERROR, [path, payload, response, headers]) rescue => e handle_failure(fallback, CLIENT_ERROR, [path, payload, e, headers]) end |