Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Commit

Permalink
Merge pull request #7 from leifg/generic_host
Browse files Browse the repository at this point in the history
create host string in one method
  • Loading branch information
leifg committed Jul 4, 2013
2 parents 6af0549 + 4a17735 commit 33f966f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/executrix/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def self.login sandbox, username, password, api_version
host = sandbox ? 'test.salesforce.com' : 'login.salesforce.com'
Http::Request.new(
:post,
host,
generic_host(sandbox ? 'test' : 'login'),
"/services/Soap/u/#{api_version}",
body,
headers)
Expand All @@ -137,7 +137,7 @@ def self.create_job instance, session_id, operation, sobject, api_version, exter
'X-SFDC-Session' => session_id}
Http::Request.new(
:post,
"#{instance}.salesforce.com",
generic_host(instance),
"/services/async/#{api_version}/job",
body,
headers)
Expand All @@ -154,7 +154,7 @@ def self.close_job instance, session_id, job_id, api_version
'X-SFDC-Session' => session_id}
Http::Request.new(
:post,
"#{instance}.salesforce.com",
generic_host(instance),
"/services/async/#{api_version}/job/#{job_id}",
body,
headers)
Expand All @@ -164,7 +164,7 @@ 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,
"#{instance}.salesforce.com",
generic_host(instance),
"/services/async/#{api_version}/job/#{job_id}/batch",
data,
headers)
Expand All @@ -174,7 +174,7 @@ def self.query_batch instance, session_id, job_id, batch_id, api_version
headers = {'X-SFDC-Session' => session_id}
Http::Request.new(
:get,
"#{instance}.salesforce.com",
generic_host(instance),
"/services/async/#{api_version}/job/#{job_id}/batch/#{batch_id}",
nil,
headers)
Expand All @@ -186,7 +186,7 @@ def self.query_batch_result_id instance, session_id, job_id, batch_id, api_versi
'X-SFDC-Session' => session_id}
Http::Request.new(
:get,
"#{instance}.salesforce.com",
generic_host(instance),
"/services/async/#{api_version}/job/#{job_id}/batch/#{batch_id}/result",
nil,
headers)
Expand All @@ -203,12 +203,17 @@ def self.query_batch_result_data(instance,
'X-SFDC-Session' => session_id}
Http::Request.new(
:get,
"#{instance}.salesforce.com",
generic_host(instance),
"/services/async/#{api_version}" \
"/job/#{job_id}/batch/#{batch_id}/result/#{result_id}",
nil,
headers)
end

private
def self.generic_host prefix
"#{prefix}.salesforce.com"
end
end
end
end

0 comments on commit 33f966f

Please sign in to comment.