Class: SalesforceBulkApi::Connection
- Inherits:
-
Object
- Object
- SalesforceBulkApi::Connection
- 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 ⇒ Object
readonly
Returns the value of attribute instance.
-
#instance_host ⇒ Object
readonly
Returns the value of attribute instance_host.
-
#server_url ⇒ Object
readonly
Returns the value of attribute server_url.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
Instance Method Summary collapse
- #counters ⇒ Object
- #get_request(host, path, headers) ⇒ Object
-
#initialize(api_version, client) ⇒ Connection
constructor
A new instance of Connection.
- #post_xml(host, path, xml, headers) ⇒ Object
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) login end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
10 11 12 |
# File 'lib/salesforce_bulk_api/connection.rb', line 10 def instance @instance end |
#instance_host ⇒ Object (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_url ⇒ Object (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_id ⇒ Object (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
#counters ⇒ Object
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 == LOGIN_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 == LOGIN_HOST path = "#{@path_prefix}#{path}" unless host == LOGIN_HOST perform_request(:post, host, path, xml, headers) end |