Sha256: af234e52f5141f14487ebf11fca5cb1c4e27ba610b46a576943e00778fa0aa89

Contents?: true

Size: 881 Bytes

Versions: 7

Compression:

Stored size: 881 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::SOAPFault => 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

7 entries across 7 versions & 1 rubygems

Version Path
activeforce-4.0.0 lib/salesforce/connection.rb
activeforce-3.1.0 lib/salesforce/connection.rb
activeforce-3.0.0 lib/salesforce/connection.rb
activeforce-2.1.1 lib/salesforce/connection.rb
activeforce-2.1.0 lib/salesforce/connection.rb
activeforce-2.0.1 lib/salesforce/connection.rb
activeforce-2.0.0 lib/salesforce/connection.rb