Sha256: 42e9cecb1843a9a6c4812e09b2b585bfefe854c336ccb36a8e57a2b7704eeff4

Contents?: true

Size: 882 Bytes

Versions: 12

Compression:

Stored size: 882 Bytes

Contents

require 'salesforce/connection/soap_api'
require 'salesforce/connection/rest_api'
require 'salesforce/connection/http_methods'
require 'salesforce/connection/conversion'
require 'salesforce/connection/async'

module Salesforce
  module Connection
    include SoapApi
    include RestApi
    include HttpMethods
    include Conversion
    include Async
    
    def self.as_logged_in_user(&block)
      count = 0 
      begin
        Salesforce::Authentication.session_id
        block.call
      rescue RestClient::Request::Unauthorized, Savon::SOAP::Fault => e
        if count < 1 && (e.message.downcase.include?("unauthorized") || e.message.downcase.include?("invalid_login"))
          count += 1
          Salesforce::Config.on_login_failure
          Salesforce::Authentication.logout
          retry
        else
          raise e
        end
      end
    
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
activeforce-1.10.4 lib/salesforce/connection.rb
activeforce-1.10.3 lib/salesforce/connection.rb
activeforce-1.10.2 lib/salesforce/connection.rb
activeforce-1.10.1 lib/salesforce/connection.rb
activeforce-1.10.0 lib/salesforce/connection.rb
activeforce-1.9.1 lib/salesforce/connection.rb
activeforce-1.9.0 lib/salesforce/connection.rb
activeforce-1.8.0 lib/salesforce/connection.rb
activeforce-1.7.1 lib/salesforce/connection.rb
activeforce-1.7.0 lib/salesforce/connection.rb
activeforce-1.6.0 lib/salesforce/connection.rb
activeforce-1.5.0 lib/salesforce/connection.rb