class Executrix::Http::Request
Attributes
body[R]
headers[R]
host[R]
http_method[R]
path[R]
Public Class Methods
add_batch(instance, session_id, job_id, data, api_version)
click to toggle source
# File lib/executrix/http.rb, line 175 def self.add_batch instance, session_id, job_id, data, api_version headers = {'Content-Type' => 'text/csv; charset=UTF-8', 'X-SFDC-Session' => session_id} Http::Request.new( :post, generic_host(instance), "/services/async/#{api_version}/job/#{job_id}/batch", data, headers) end
close_job(instance, session_id, job_id, api_version)
click to toggle source
# File lib/executrix/http.rb, line 158 def self.close_job instance, session_id, job_id, api_version body = %Q{<?xml version="1.0" encoding="utf-8" ?> <jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <state>Closed</state> </jobInfo> } headers = { 'Content-Type' => 'application/xml; charset=utf-8', 'X-SFDC-Session' => session_id} Http::Request.new( :post, generic_host(instance), "/services/async/#{api_version}/job/#{job_id}", body, headers) end
create_job(instance, session_id, operation, sobject, content_type, api_version, external_field = nil)
click to toggle source
# File lib/executrix/http.rb, line 136 def self.create_job instance, session_id, operation, sobject, content_type, api_version, external_field = nil external_field_line = external_field ? "<externalIdFieldName>#{external_field}</externalIdFieldName>" : nil body = %Q{<?xml version="1.0" encoding="utf-8" ?> <jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <operation>#{operation}</operation> <object>#{sobject}</object> #{external_field_line} <contentType>#{content_type}</contentType> </jobInfo> } headers = { 'Content-Type' => 'application/xml; charset=utf-8', 'X-SFDC-Session' => session_id} Http::Request.new( :post, generic_host(instance), "/services/async/#{api_version}/job", body, headers) end
generic_host(prefix)
click to toggle source
# File lib/executrix/http.rb, line 225 def self.generic_host prefix "#{prefix}.salesforce.com" end
login(sandbox, username, password, api_version)
click to toggle source
# File lib/executrix/http.rb, line 112 def self.login sandbox, username, password, api_version body = %Q{<?xml version="1.0" encoding="utf-8" ?> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <n1:login xmlns:n1="urn:partner.soap.sforce.com"> <n1:username>#{username}</n1:username> <n1:password>#{password}</n1:password> </n1:login> </env:Body> </env:Envelope>} headers = { 'Content-Type' => 'text/xml; charset=utf-8', 'SOAPAction' => 'login' } Http::Request.new( :post, generic_host(sandbox ? 'test' : 'login'), "/services/Soap/u/#{api_version}", body, headers) end
new(http_method, host, path, body, headers)
click to toggle source
# File lib/executrix/http.rb, line 104 def initialize http_method, host, path, body, headers @http_method = http_method @host = host @path = path @body = body @headers = headers end
query_batch(instance, session_id, job_id, batch_id, api_version)
click to toggle source
# File lib/executrix/http.rb, line 185 def self.query_batch instance, session_id, job_id, batch_id, api_version headers = {'X-SFDC-Session' => session_id} Http::Request.new( :get, generic_host(instance), "/services/async/#{api_version}/job/#{job_id}/batch/#{batch_id}", nil, headers) end
query_batch_result_data(instance, session_id, job_id, batch_id, result_id, api_version)
click to toggle source
# File lib/executrix/http.rb, line 207 def self.query_batch_result_data(instance, session_id, job_id, batch_id, result_id, api_version) headers = { 'Content-Type' => 'text/csv; charset=UTF-8', 'X-SFDC-Session' => session_id} Http::Request.new( :get, generic_host(instance), "/services/async/#{api_version}" \ "/job/#{job_id}/batch/#{batch_id}/result/#{result_id}", nil, headers) end
query_batch_result_id(instance, session_id, job_id, batch_id, api_version)
click to toggle source
# File lib/executrix/http.rb, line 195 def self.query_batch_result_id instance, session_id, job_id, batch_id, api_version headers = { 'Content-Type' => 'application/xml; charset=utf-8', 'X-SFDC-Session' => session_id} Http::Request.new( :get, generic_host(instance), "/services/async/#{api_version}/job/#{job_id}/batch/#{batch_id}/result", nil, headers) end