soapforce 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
data/lib/soapforce/client.rb
CHANGED
@@ -387,6 +387,44 @@ module Soapforce
|
|
387
387
|
sobject ? SObject.new(sobject) : nil
|
388
388
|
end
|
389
389
|
|
390
|
+
# ProcessSubmitRequest
|
391
|
+
# request = {objectId: .., comments: ..., nextApproverIds: [...] }
|
392
|
+
# ProcessWorkItemRequest
|
393
|
+
# request = {action: .., workitemId: .., comments: ..., nextApproverIds: [...] }
|
394
|
+
#
|
395
|
+
# Returns Hash of process status.
|
396
|
+
def process(request)
|
397
|
+
|
398
|
+
# approverIds is optional if Approval is configured to auto-assign the approver.
|
399
|
+
# Ensure approver ids is an array.
|
400
|
+
approver_ids = request[:approverIds] || []
|
401
|
+
approver_ids = approver_ids.is_a?(Array) ? approver_ids : [approver_ids]
|
402
|
+
|
403
|
+
request_type = request[:workitemId] ? "ProcessWorkitemRequest" : "ProcessSubmitRequest"
|
404
|
+
|
405
|
+
# Unfortunately had to use XML since I could not figure out
|
406
|
+
# how to get Savon2 to include the proper xsi:type attribute
|
407
|
+
# on the actions element.
|
408
|
+
xml = "<tns:actions xsi:type=\"tns:#{request_type}\">"
|
409
|
+
# Account for Submit or Workitem Request
|
410
|
+
if request[:objectId]
|
411
|
+
xml << "<tns:objectId>#{request[:objectId]}</tns:objectId>"
|
412
|
+
else
|
413
|
+
xml << "<tns:action>#{request[:action]}</tns:action>"
|
414
|
+
xml << "<tns:workitemId>#{request[:workitemId]}</tns:workitemId>"
|
415
|
+
end
|
416
|
+
|
417
|
+
xml << "<tns:comments>#{request[:comments]}</tns:comments>"
|
418
|
+
approver_ids.each do |aid|
|
419
|
+
xml << "<tns:nextApproverIds>#{aid}</tns:nextApproverIds>"
|
420
|
+
end
|
421
|
+
xml << "</tns:actions>"
|
422
|
+
|
423
|
+
call_soap_api(:process, xml)
|
424
|
+
end
|
425
|
+
|
426
|
+
# Helpers
|
427
|
+
|
390
428
|
def field_list(sobject)
|
391
429
|
description = describe(sobject)
|
392
430
|
field_list = description[:fields].collect {|c| c[:name] }
|
data/lib/soapforce/version.rb
CHANGED
data/soapforce.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.description = %q{A ruby client for the Salesforce SOAP API based on Savon.}
|
12
12
|
gem.summary = %q{Wraps Savon with helper methods and custom types for interacting with the Salesforce SOAP API.}
|
13
13
|
gem.homepage = "https://github.com/TinderBox/soapforce"
|
14
|
+
gem.license = 'MIT'
|
14
15
|
|
15
16
|
ignores = File.readlines('.gitignore').grep(/\S+/).map(&:chomp)
|
16
17
|
dotfiles = %w[.gitignore .travis.yml]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com">
|
3
|
+
<soapenv:Body>
|
4
|
+
<processResponse>
|
5
|
+
<result>
|
6
|
+
<actorIds>005i0000000Fi7vAAC</actorIds>
|
7
|
+
<entityId>a00i0000007JBLJAA4</entityId>
|
8
|
+
<instanceId>04gi00000009u5ZAAQ</instanceId>
|
9
|
+
<instanceStatus>Pending</instanceStatus>
|
10
|
+
<newWorkitemIds>04ii000000098uLAAQ</newWorkitemIds>
|
11
|
+
<success>true</success>
|
12
|
+
</result>
|
13
|
+
</processResponse>
|
14
|
+
</soapenv:Body>
|
15
|
+
</soapenv:Envelope>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com">
|
3
|
+
<soapenv:Body>
|
4
|
+
<processResponse>
|
5
|
+
<result>
|
6
|
+
<entityId>a00i0000007JBLJAA4</entityId>
|
7
|
+
<instanceId>04gi00000009u5PAAQ</instanceId>
|
8
|
+
<instanceStatus>Removed</instanceStatus>
|
9
|
+
<success>true</success>
|
10
|
+
</result>
|
11
|
+
</processResponse>
|
12
|
+
</soapenv:Body>
|
13
|
+
</soapenv:Envelope>
|
data/spec/lib/client_spec.rb
CHANGED
@@ -376,7 +376,41 @@ describe Soapforce::Client do
|
|
376
376
|
}.to raise_error(Savon::Error)
|
377
377
|
end
|
378
378
|
|
379
|
+
end
|
380
|
+
|
381
|
+
describe "process" do
|
382
|
+
|
383
|
+
it "process submit request without approvers" do
|
384
|
+
|
385
|
+
@body = '<tns:process><tns:actions xsi:type="tns:ProcessSubmitRequest"><tns:objectId>a00i0000007JBLJAA4</tns:objectId><tns:comments>Submitting for Approval</tns:comments></tns:actions></tns:process>'
|
386
|
+
|
387
|
+
stub = stub_api_request(endpoint, {with_body: @body, fixture: 'process_submit_request_response'})
|
388
|
+
response = subject.process({objectId: "a00i0000007JBLJAA4", comments: "Submitting for Approval"})
|
389
|
+
|
390
|
+
response[:success].should be_true
|
391
|
+
response[:new_workitem_ids].should == "04ii000000098uLAAQ"
|
392
|
+
end
|
393
|
+
|
394
|
+
it "process submit request with approvers" do
|
379
395
|
|
396
|
+
@body = '<tns:process><tns:actions xsi:type="tns:ProcessSubmitRequest"><tns:objectId>a00i0000007JBLJAA4</tns:objectId><tns:comments>Submitting for Approval</tns:comments><tns:nextApproverIds>abcde12345</tns:nextApproverIds></tns:actions></tns:process>'
|
397
|
+
|
398
|
+
stub = stub_api_request(endpoint, {with_body: @body, fixture: 'process_submit_request_response'})
|
399
|
+
response = subject.process({objectId: "a00i0000007JBLJAA4", comments: "Submitting for Approval", approverIds: "abcde12345"})
|
400
|
+
|
401
|
+
response[:success].should be_true
|
402
|
+
response[:new_workitem_ids].should == "04ii000000098uLAAQ"
|
403
|
+
end
|
404
|
+
|
405
|
+
it "process workitem request" do
|
406
|
+
@body = '<tns:process><tns:actions xsi:type="tns:ProcessWorkitemRequest"><tns:action>Removed</tns:action><tns:workitemId>a00i0000007JBLJAA4</tns:workitemId><tns:comments>Recalling Request</tns:comments></tns:actions></tns:process>'
|
407
|
+
|
408
|
+
stub = stub_api_request(endpoint, {with_body: @body, fixture: 'process_workitem_request_response'})
|
409
|
+
response = subject.process({action: "Removed", workitemId: "a00i0000007JBLJAA4", comments: "Recalling Request"})
|
410
|
+
|
411
|
+
response[:success].should be_true
|
412
|
+
response[:instance_status].should == "Removed"
|
413
|
+
end
|
380
414
|
end
|
381
415
|
|
382
416
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soapforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -107,6 +107,8 @@ files:
|
|
107
107
|
- spec/fixtures/get_user_info_response.xml
|
108
108
|
- spec/fixtures/login_response.xml
|
109
109
|
- spec/fixtures/org_id_response.xml
|
110
|
+
- spec/fixtures/process_submit_request_response.xml
|
111
|
+
- spec/fixtures/process_workitem_request_response.xml
|
110
112
|
- spec/fixtures/query_all_response.xml
|
111
113
|
- spec/fixtures/query_more_response.xml
|
112
114
|
- spec/fixtures/query_response.xml
|
@@ -123,7 +125,8 @@ files:
|
|
123
125
|
- spec/support/fixture_helpers.rb
|
124
126
|
- test.rb
|
125
127
|
homepage: https://github.com/TinderBox/soapforce
|
126
|
-
licenses:
|
128
|
+
licenses:
|
129
|
+
- MIT
|
127
130
|
post_install_message:
|
128
131
|
rdoc_options: []
|
129
132
|
require_paths:
|
@@ -158,6 +161,8 @@ test_files:
|
|
158
161
|
- spec/fixtures/get_user_info_response.xml
|
159
162
|
- spec/fixtures/login_response.xml
|
160
163
|
- spec/fixtures/org_id_response.xml
|
164
|
+
- spec/fixtures/process_submit_request_response.xml
|
165
|
+
- spec/fixtures/process_workitem_request_response.xml
|
161
166
|
- spec/fixtures/query_all_response.xml
|
162
167
|
- spec/fixtures/query_more_response.xml
|
163
168
|
- spec/fixtures/query_response.xml
|