Class: MAuth::Faraday::Request

Inherits:
Request
  • Object
show all
Defined in:
lib/mauth/faraday.rb

Overview

representation of a request (outgoing) composed from a Faraday request env which can be passed to a Mauth::Client for signing

Constant Summary

Constants inherited from Request

Request::SIGNATURE_COMPONENTS, Request::SIGNATURE_COMPONENTS_V2

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Signable

#normalize_path, #string_to_sign_v1, #string_to_sign_v2, #unescape_encode_query_string, #uri_escape

Constructor Details

#initialize(request_env) ⇒ Request

Returns a new instance of Request.



37
38
39
# File 'lib/mauth/faraday.rb', line 37

def initialize(request_env)
  @request_env = request_env
end

Instance Attribute Details

#request_envObject (readonly)

Returns the value of attribute request_env.



35
36
37
# File 'lib/mauth/faraday.rb', line 35

def request_env
  @request_env
end

Instance Method Details

#attributes_for_signingObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mauth/faraday.rb', line 41

def attributes_for_signing
  @attributes_for_signing ||= begin
    request_url = @request_env[:url].path.empty? ? '/' : @request_env[:url].path
    {
      verb: @request_env[:method].to_s.upcase,
      request_url: request_url,
      body: @request_env[:body],
      query_string: @request_env[:url].query
    }
  end
end

#merge_headers(headers) ⇒ Object

takes a Hash of headers; returns an instance of this class whose headers have been merged with the argument headers



55
56
57
# File 'lib/mauth/faraday.rb', line 55

def merge_headers(headers)
  self.class.new(@request_env.merge(request_headers: @request_env[:request_headers].merge(headers)))
end