class SparkApi::Authentication::BaseAuth

Authentication Base

This base class defines the basic interface supported by all client authentication 
implementations.

Attributes

session[RW]

Public Class Methods

new(client) click to toggle source

All ihheriting classes should accept the spark_api client as a part of initialization

# File lib/spark_api/authentication/base_auth.rb, line 10
def initialize(client)
  @client = client
end

Public Instance Methods

authenticate() click to toggle source

Perform requests to authenticate the client with the API

# File lib/spark_api/authentication/base_auth.rb, line 15
def authenticate
  raise "Implement me!"
end
authenticated?() click to toggle source

Called prior to running authenticate (except in case of api authentication errors)

# File lib/spark_api/authentication/base_auth.rb, line 20
def authenticated?
  !(session.nil? || session.expired?)
end
build_url_parameters(parameters={}) click to toggle source

Format a hash as request parameters

:returns:

Stringized form of the parameters as needed for an HTTP request
# File lib/spark_api/authentication/base_auth.rb, line 38
def build_url_parameters(parameters={})
  array = parameters.map do |key,value|
    escaped_value = CGI.escape("#{value}")
    "#{key}=#{escaped_value}"
  end
  array.join "&"
end
logout() click to toggle source

Terminate the active session

# File lib/spark_api/authentication/base_auth.rb, line 25
def logout
  raise "Implement me!"
end
request(method, path, body, options) click to toggle source

Perform an HTTP request (no data)

# File lib/spark_api/authentication/base_auth.rb, line 30
def request(method, path, body, options)
  raise "Implement me!"
end