class Instapaper::HTTP::Headers

Public Class Methods

new(client, request_method, url, options = {}) click to toggle source
# File lib/instapaper/http/headers.rb, line 8
def initialize(client, request_method, url, options = {})
  @client = client
  @request_method = request_method.to_sym
  @uri = Addressable::URI.parse(url)
  @options = options
end

Public Instance Methods

request_headers() click to toggle source
# File lib/instapaper/http/headers.rb, line 15
def request_headers
  {
    user_agent: @client.user_agent,
    authorization: oauth_header,
  }
end

Private Instance Methods

credentials() click to toggle source

Authentication hash

@return [Hash]

# File lib/instapaper/http/headers.rb, line 31
def credentials
  if @client.credentials?
    {
      consumer_key: @client.consumer_key,
      consumer_secret: @client.consumer_secret,
      token: @client.oauth_token,
      token_secret: @client.oauth_token_secret,
    }
  else
    @client.consumer_credentials
  end
end
oauth_header() click to toggle source
# File lib/instapaper/http/headers.rb, line 24
def oauth_header
  SimpleOAuth::Header.new(@request_method, @uri, @options, credentials.merge(ignore_extra_keys: true))
end