Class: Evervault::Http::Request
- Inherits:
-
Object
- Object
- Evervault::Http::Request
- Defined in:
- lib/evervault/http/request.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #execute(method, url, body = nil, basic_auth = false, error_map = Evervault::Errors::LegacyErrorMap) ⇒ Object
-
#initialize(config:) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(config:) ⇒ Request
Returns a new instance of Request.
13 14 15 |
# File 'lib/evervault/http/request.rb', line 13 def initialize(config:) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/evervault/http/request.rb', line 11 def config @config end |
Instance Method Details
#execute(method, url, body = nil, basic_auth = false, error_map = Evervault::Errors::LegacyErrorMap) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/evervault/http/request.rb', line 17 def execute(method, url, body = nil, basic_auth = false, error_map = Evervault::Errors::LegacyErrorMap) resp = faraday(basic_auth).public_send(method, url) do |req, _url| req.body = body.nil? || body.empty? ? nil : body.to_json req.headers = build_headers(basic_auth) req..timeout = config.request_timeout end return resp if resp.status >= 200 && resp.status <= 300 error_map.raise_errors_on_failure(resp.status, resp.body, resp.headers) end |