Sha256: 2fa7f797f6697289c86859d16e771fca1cc77ff8b79e61d5b14d0cc3f965b280

Contents?: true

Size: 767 Bytes

Versions: 4

Compression:

Stored size: 767 Bytes

Contents

module Salesforce
  class Authentication
    cattr_accessor :username
    cattr_accessor :password
    
    def self.session_id
      raise InvalidCredentials.new("No credentials provided.") if Config.username.blank? || Config.password.blank?
      Config.session_id || generate_new_session_id
    end
    
    def self.generate_new_session_id
      result = Connection.login    
      Config.instance.soap_endpoint_url result[:server_url]
      Config.instance.session_id        result[:session_id]
      Config.instance.server_instance   URI.parse(result[:server_url]).host.split("-").first
      Config.instance.user_id           result[:user_id]
      Config.session_id
    end
    
    def self.logout
      Config.instance.session_id nil
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activeforce-1.7.1 lib/salesforce/authentication.rb
activeforce-1.7.0 lib/salesforce/authentication.rb
activeforce-1.6.0 lib/salesforce/authentication.rb
activeforce-1.5.0 lib/salesforce/authentication.rb