Sha256: 1771745c9159ac34d2aa84b5eb65becc889670c232e03333eb8089c67875cac8

Contents?: true

Size: 1.29 KB

Versions: 73

Compression:

Stored size: 1.29 KB

Contents

module SparkApi

  module Authentication
    #=Authentication Base
    # This base class defines the basic interface supported by all client authentication 
    # implementations.
    class BaseAuth
      attr_accessor :session
      # All ihheriting classes should accept the spark_api client as a part of initialization
      def initialize(client)
        @client = client
      end
      
      # Perform requests to authenticate the client with the API
      def authenticate
        raise "Implement me!"
      end

      # Called prior to running authenticate (except in case of api authentication errors)
      def authenticated?
        !(session.nil? || session.expired?)
      end
      
      # Terminate the active session
      def logout
        raise "Implement me!"
      end
        
      # Perform an HTTP request (no data)
      def request(method, path, body, options)
        raise "Implement me!"
      end
      
      # Format a hash as request parameters
      # 
      # :returns:
      #   Stringized form of the parameters as needed for an HTTP request
      def build_url_parameters(parameters={})
        array = parameters.map do |key,value|
          escaped_value = CGI.escape("#{value}")
          "#{key}=#{escaped_value}"
        end
        array.join "&"
      end
    end
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
spark_api-1.6.3 lib/spark_api/authentication/base_auth.rb
spark_api-1.6.2 lib/spark_api/authentication/base_auth.rb
spark_api-1.6.1 lib/spark_api/authentication/base_auth.rb
spark_api-1.5.7 lib/spark_api/authentication/base_auth.rb
spark_api-1.6.0 lib/spark_api/authentication/base_auth.rb
spark_api-1.5.6 lib/spark_api/authentication/base_auth.rb
spark_api-1.5.5 lib/spark_api/authentication/base_auth.rb
spark_api-1.5.4 lib/spark_api/authentication/base_auth.rb
spark_api-1.5.3 lib/spark_api/authentication/base_auth.rb
spark_api-1.5.2 lib/spark_api/authentication/base_auth.rb
spark_api-1.5.1 lib/spark_api/authentication/base_auth.rb
spark_api-1.5.0 lib/spark_api/authentication/base_auth.rb
spark_api-1.4.34 lib/spark_api/authentication/base_auth.rb
spark_api-1.4.32 lib/spark_api/authentication/base_auth.rb
spark_api-1.4.31 lib/spark_api/authentication/base_auth.rb
spark_api-1.4.29 lib/spark_api/authentication/base_auth.rb
spark_api-1.4.28 lib/spark_api/authentication/base_auth.rb
spark_api-1.4.27 lib/spark_api/authentication/base_auth.rb
spark_api-1.4.26 lib/spark_api/authentication/base_auth.rb
spark_api-1.4.25 lib/spark_api/authentication/base_auth.rb