Class: SalesforceBulkApi::Connection

Inherits:
Object
  • Object
show all
Includes:
SalesforceBulkApi::Concerns::Throttling
Defined in:
lib/salesforce_bulk_api/connection.rb

Constant Summary collapse

LOGIN_HOST =
"login.salesforce.com".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SalesforceBulkApi::Concerns::Throttling

#add_throttle, #set_status_throttle, #set_throttle_limit_in_seconds, #throttles

Constructor Details

#initialize(api_version, client) ⇒ Connection

Returns a new instance of Connection.



12
13
14
15
16
17
18
19
# File 'lib/salesforce_bulk_api/connection.rb', line 12

def initialize(api_version, client)
  @client = client
  @api_version = api_version
  @path_prefix = "/services/async/#{@api_version}/"
  @counters = Hash.new(0)

  
end

Instance Attribute Details

#instanceObject (readonly)

Returns the value of attribute instance.



10
11
12
# File 'lib/salesforce_bulk_api/connection.rb', line 10

def instance
  @instance
end

#instance_hostObject (readonly)

Returns the value of attribute instance_host.



10
11
12
# File 'lib/salesforce_bulk_api/connection.rb', line 10

def instance_host
  @instance_host
end

#server_urlObject (readonly)

Returns the value of attribute server_url.



10
11
12
# File 'lib/salesforce_bulk_api/connection.rb', line 10

def server_url
  @server_url
end

#session_idObject (readonly)

Returns the value of attribute session_id.



10
11
12
# File 'lib/salesforce_bulk_api/connection.rb', line 10

def session_id
  @session_id
end

Instance Method Details

#countersObject



37
38
39
40
41
42
# File 'lib/salesforce_bulk_api/connection.rb', line 37

def counters
  {
    get: @counters[:get],
    post: @counters[:post]
  }
end

#get_request(host, path, headers) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/salesforce_bulk_api/connection.rb', line 29

def get_request(host, path, headers)
  host ||= @instance_host
  path = "#{@path_prefix}#{path}"
  headers["X-SFDC-Session"] = @session_id unless host == 

  perform_request(:get, host, path, nil, headers)
end

#post_xml(host, path, xml, headers) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/salesforce_bulk_api/connection.rb', line 21

def post_xml(host, path, xml, headers)
  host ||= @instance_host
  headers["X-SFDC-Session"] = @session_id unless host == 
  path = "#{@path_prefix}#{path}" unless host == 

  perform_request(:post, host, path, xml, headers)
end