Sha256: e8885bc604597edb8d603f7a03204b092dc80ecafc30d491e277f8857de6ad2c

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 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::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

1 entries across 1 versions & 1 rubygems

Version Path
activeforce-5.0.0 lib/salesforce/connection.rb