class Twimock::API::OAuth::Authenticate

Constants

METHOD
PATH
VIEW_DIRECTORY
VIEW_FILE_NAME

Public Class Methods

view(oauth_token) click to toggle source
# File lib/twimock/api/oauth/authenticate.rb, line 36
def self.view(oauth_token)
  @action_url = Twimock::API::Intent::Sessions::PATH
  @oauth_token = oauth_token
  erb = ERB.new(File.read(filepath))
  erb.result(binding)
end

Private Class Methods

filepath() click to toggle source
# File lib/twimock/api/oauth/authenticate.rb, line 45
def self.filepath
  File.join(VIEW_DIRECTORY, VIEW_FILE_NAME)
end

Public Instance Methods

call(env) click to toggle source
Calls superclass method Twimock::API::OAuth#call
# File lib/twimock/api/oauth/authenticate.rb, line 15
def call(env)
  return super unless called?(env)
  begin
    request = Rack::Request.new(env)
    @oauth_token = request.params["oauth_token"]

    if !validate_request_token(@oauth_token)
      raise Twimock::Errors::InvalidRequestToken.new
    end

    status = 200
    body   = Twimock::API::OAuth::Authenticate.view(@oauth_token)
    header = { "Content-Length" => body.bytesize.to_s }
    [ status, header, [ body ] ]
  rescue Twimock::Errors::InvalidRequestToken => @error
    unauthorized
  rescue => @error
    internal_server_error
  end
end