Sha256: 24ec77d45bd14c7139374efeea25e58341dac725ad7bd9604cc7e59c2630ed06

Contents?: true

Size: 764 Bytes

Versions: 5

Compression:

Stored size: 764 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[/(na|cs)\d+/]
      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

5 entries across 5 versions & 1 rubygems

Version Path
activeforce-2.0.1 lib/salesforce/authentication.rb
activeforce-2.0.0 lib/salesforce/authentication.rb
activeforce-1.9.1 lib/salesforce/authentication.rb
activeforce-1.9.0 lib/salesforce/authentication.rb
activeforce-1.8.0 lib/salesforce/authentication.rb