Class: Restforce::Bulk::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/restforce/bulk/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(restforce_client = nil) ⇒ Client

Returns a new instance of Client.



4
5
6
# File 'lib/restforce/bulk/client.rb', line 4

def initialize(restforce_client=nil)
  @restforce_client = restforce_client
end

Instance Method Details

#connectionObject



8
9
10
11
12
13
14
15
# File 'lib/restforce/bulk/client.rb', line 8

def connection
  @connection ||= (@restforce_client || Restforce.new).tap do |client|
    client.authenticate!
    client.middleware.insert_after Restforce::Middleware::Authorization, Restforce::Bulk::Middleware::Authorization, client, client.options
    client.middleware.response :xml, content_type: /\bxml$/
    client.middleware.use Restforce::Bulk::Middleware::ParseCsv, content_type: /\bcsv$/
  end
end

#perform_request(method, path, data = nil, content_type = :xml, headers = {}) ⇒ Object



17
18
19
20
21
# File 'lib/restforce/bulk/client.rb', line 17

def perform_request(method, path, data=nil, content_type=:xml, headers={})
  result_headers = content_type_header_for(content_type).merge(headers)

  connection.send(method, [base_path, path].join('/'), data, result_headers)
end