Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accepts Headers #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Nerdenberger
Copy link

As a user of the SOAP API I often need to pass headers such as 'AllOrNone' or 'AssignmentRule' to salesforce to fit the requirements of my integration.

This PR adds the ability for a user to pass an optional headers argument to most SOAP calls.

header = { "AllOrNoneHeader" => { "allOrNone" => true } } 
client.upsert(table, external_id, batch, header)

@jheth
Copy link
Contributor

jheth commented Aug 16, 2017

Hey @Nerdenberger! Thanks for the PR. It looks like we have a mix of tabs vs spaces. Can you fix that up?

@@ -19,6 +19,9 @@ def initialize(options = {})
# to make SOAP calls in Professional/Group Edition organizations.

client_id = options[:client_id] || Soapforce.configuration.client_id

@headers = options[:headers] if options[:headers]

@headers = { 'tns:CallOptions' => { 'tns:client' => client_id } } if client_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This combination of client_id would not work with optional headers. What if you merge the hashes? @headers.merge(options[:headers]) if options[:headers].is_a?(Hash)

@@ -204,21 +207,21 @@ def describe_layout(sobject_type, layout_id=nil)
response
end

def query(soql)
call_soap_api(:query, {:queryString => soql})
def query(soql, header={})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing header into every method I think you can use @headers in call_soap_api and it would apply to all calls. Do you ever find yourself needing different headers per request?

@jheth
Copy link
Contributor

jheth commented Aug 29, 2017

@Nerdenberger What do you think of the comments I left on the commits?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants