Sha256: 818c45df0e1fbf4b0bf8dc999d5f3f4eb1482bca77222d440490144408fbc4a6

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 KB

Contents

module FlexmlsApi

  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 flexmls_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

9 entries across 9 versions & 2 rubygems

Version Path
spark_api-1.0.2 lib/spark_api/authentication/base_auth.rb~
spark_api-1.0.1 lib/spark_api/authentication/base_auth.rb~
spark_api-1.0.0 lib/spark_api/authentication/base_auth.rb~
flexmls_api-0.7.3 lib/flexmls_api/authentication/base_auth.rb
flexmls_api-0.7.5 lib/flexmls_api/authentication/base_auth.rb
flexmls_api-0.7.0 lib/flexmls_api/authentication/base_auth.rb
flexmls_api-0.6.5 lib/flexmls_api/authentication/base_auth.rb
flexmls_api-0.6.4 lib/flexmls_api/authentication/base_auth.rb
flexmls_api-0.4.5 lib/flexmls_api/authentication/base_auth.rb