lib/freno/client/request.rb in freno-client-0.7.0 vs lib/freno/client/request.rb in freno-client-0.8.0

- old
+ new

@@ -10,11 +10,11 @@ attr_reader :faraday, :args, :options attr_reader :raise_on_timeout def self.perform(**kwargs) - new(kwargs).perform + new(**kwargs).perform end def initialize(**kwargs) @args = kwargs @faraday = kwargs.delete(:faraday) || nil @@ -23,23 +23,23 @@ @raise_on_timeout = options.fetch(:raise_on_timeout, true) @verb = options.fetch(:verb, :head) end def perform - response = request(verb, path) + response = request(verb, path, params) process_response(response) rescue Faraday::TimeoutError => ex raise Freno::Error.new(ex) if raise_on_timeout Result.from_meaning(:request_timeout) rescue => ex raise Freno::Error.new(ex) end protected - def request(verb, path) - faraday.send(verb, path) + def request(verb, path, params) + faraday.send(verb, path, params) end def path @path || begin raise NotImplementedError("must be overriden in specific requests, or memoized in @path") @@ -48,9 +48,13 @@ def verb @verb || begin raise NotImplementedError("must be overriden in specific requests, or memoized in @verb") end + end + + def params + @params ||= {} end def process_response(response) Result.from_faraday_response(response) end