class DeskApi::Request::OAuth

{DeskApi::Request::OAuth} is the Faraday middleware to sign requests with an OAuth header.

@author Thomas Stachl <tstachl@salesforce.com> @copyright Copyright © 2013-2016 Salesforce.com @license BSD 3-Clause License

Public Class Methods

new(app, options) click to toggle source

Initializies the middleware and sets options

@param app [Hash] the faraday environment hash @param options [Hash] additional options

Calls superclass method
# File lib/desk_api/request/oauth.rb, line 44
def initialize(app, options)
  super(app)
  @options = options
end

Public Instance Methods

call(env) click to toggle source

Changes the request before it gets sent

@param env [Hash] the request hash

# File lib/desk_api/request/oauth.rb, line 52
def call(env)
  env[:request_headers]['Authorization'] = oauth(env).to_s
  @app.call env
end

Private Instance Methods

oauth(env) click to toggle source

Returns the OAuth header

@param env [Hash] the request hash @return [String]

# File lib/desk_api/request/oauth.rb, line 63
def oauth(env)
  SimpleOAuth::Header.new env[:method], env[:url].to_s, {}, @options
end