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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Signable

#string_to_sign

Constructor Details

#initialize(request_env) ⇒ Request

Returns a new instance of Request.



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

def initialize(request_env)
  @request_env = request_env
end

Instance Attribute Details

#request_envObject (readonly)

Returns the value of attribute request_env.



33
34
35
# File 'lib/mauth/faraday.rb', line 33

def request_env
  @request_env
end

Instance Method Details

#attributes_for_signingObject



38
39
40
41
42
# File 'lib/mauth/faraday.rb', line 38

def attributes_for_signing
  request_url = @request_env[:url].path
  request_url = '/' if request_url.empty?
  @attributes_for_signing ||= { verb: @request_env[:method].to_s.upcase, request_url: request_url, body: @request_env[:body] }
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



46
47
48
# File 'lib/mauth/faraday.rb', line 46

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