soapforce 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NDZjNzkzNzYxNzA5YmJhZmM4ZjA1ODZhYTgxMTVkYzYwMjU1MTEyYQ==
5
- data.tar.gz: !binary |-
6
- Y2Q5MThhZTIzZmQ3NGRiYjQ0MzM0MmViNDM1YThlODhhNTY4OGVmNQ==
2
+ SHA1:
3
+ metadata.gz: 9ad9594a32904ff7305f9fed654cc0a71148e7e0
4
+ data.tar.gz: 0fb2ff0b93f97172a1e6ce0eb53591e91e9c3441
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OGIzYzM3YTk1NjBlM2I5ZmMyOGZjNDYwM2VhYjJjM2UwNTNjODcwODE1ZjZl
10
- YjIzZDM1MmQ5MzYyZGU1Mjg3ZjRlYTA2MjMzZDlkNWJmMjU0OTlkYWIzZGZl
11
- YWVlNGQ3N2FhNzY1NzlmNDk2NTU3NjNkZWIxMzJmZGU5NmYzOWE=
12
- data.tar.gz: !binary |-
13
- ZmJkNDM4ZmY2NDJkYTNkNDQyMDcxNzMzYzlkYzExN2U3YmIwNzcwMGVkNTNk
14
- NTYyMGY5MmU3MTJhYjc3NGU0ZDlhMjIwZjM2NDMwODdlOWNjMGI2MzJmM2Ix
15
- OWQ3NDU0YWQzNDIyZDI1ZTM0NDE0NTUzYWM2YTkyZjIzOWQxODg=
6
+ metadata.gz: 56920bf8ee1aa09ef84d071011b39c8a9a791cb183659bad3de9924adb9f1dd5599f5373db8e64fcd8ca42437e96a42c17c16ad61373f7db916457bf51deeeca
7
+ data.tar.gz: fda094cc5420a8a8848549937f5207d31b9fbdf1cb786b8eb2361fe3fb41aea2c4005872fd909224344ba300904e3116dc9fa1fd0c8314d245edf5d96e4b8d3f
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ ## 0.3.0 (Mar 25, 2015)
2
+
3
+ * Adds merge command.
4
+
5
+ ## 0.2.1 (November 17, 2014)
6
+
7
+ * Widen Savon dependency
8
+ * Switch to TLS. SSLv3 has been disabled.
9
+
10
+ ## 0.2.0 (November 16, 2014)
11
+
12
+ * Adds support for accessing sandbox or custom endpoint. #4
13
+ * Adds describe_layout operation
14
+ * Adds configurable logger. Disabled by default.
15
+
16
+ ## 0.1.3 (October 25, 2014)
17
+
18
+ * Adds support for process operation (ProcessSubmitRequest and ProcessWorkItemRequest)
19
+
20
+ ## 0.1.2 (September 11, 2013)
21
+
22
+ * Adds create!, update!, delete! methods that raise Exceptions on error.
23
+
24
+ ## 0.1.0 (August 13, 2013)
25
+
26
+ * Initial Release
@@ -339,6 +339,46 @@ module Soapforce
339
339
  end
340
340
  alias_method :destroy!, :delete
341
341
 
342
+ # Public: Merges records together
343
+ #
344
+ # sobject - String name of the sobject
345
+ # master_record - Hash of the master record that other records will be merged into
346
+ # ids - Array of Salesforce Ids that will be merged into the master record
347
+ #
348
+ # Examples
349
+ #
350
+ # client.merge('Account', Id: '0016000000MRatd', ['012000000000000AAA'])
351
+ #
352
+ # Returns Hash if the records were merged successfully
353
+ # Raises an exception if an error is returned from Salesforce.
354
+ def merge!(sobject_type, master_record_hash, ids)
355
+ call_soap_api(
356
+ :merge,
357
+ request: {
358
+ masterRecord: master_record_hash.merge(:'@xsi:type' => sobject_type),
359
+ recordToMergeIds: ids
360
+ }
361
+ )
362
+ end
363
+
364
+ # Public: Merges records together
365
+ #
366
+ # sobject - String name of the sobject
367
+ # master_record - Hash of the master record that other records will be merged into
368
+ # ids - Array of Salesforce Ids that will be merged into the master record
369
+ #
370
+ # Examples
371
+ #
372
+ # client.merge('Account', Id: '0016000000MRatd', ['012000000000000AAA'])
373
+ #
374
+ # Returns Hash if the records were merged successfully
375
+ # Raises an exception if an error is returned from Salesforce.
376
+ def merge(sobject_type, master_record_hash, ids)
377
+ merge!(sobject_type, master_record_hash, ids)
378
+ rescue => e
379
+ false
380
+ end
381
+
342
382
  # Public: Finds a single record and returns all fields.
343
383
  #
344
384
  # sobject - The String name of the sobject.
@@ -532,4 +572,4 @@ module Soapforce
532
572
  {sObjects: sobjects}
533
573
  end
534
574
  end
535
- end
575
+ end
@@ -1,3 +1,3 @@
1
1
  module Soapforce
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0"?>
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com">
3
+ <soapenv:Body>
4
+ <mergeResponse>
5
+ <result>
6
+ <id>001160000000000AAG</id>
7
+ <mergedRecordIds>001140000000000AA4</mergedRecordIds>
8
+ <mergedRecordIds>001150000000000AAO</mergedRecordIds>
9
+ <success>true</success>
10
+ </result>
11
+ </mergeResponse>
12
+ </soapenv:Body>
13
+ </soapenv:Envelope>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0"?>
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com">
3
+ <soapenv:Body>
4
+ <mergeResponse>
5
+ <result>
6
+ <errors>
7
+ <message>bad id in recordsToMerge: 0011500000000</message>
8
+ <statusCode>MALFORMED_ID</statusCode>
9
+ </errors>
10
+ <id>001160000000000AAG</id>
11
+ <success>false</success>
12
+ </result>
13
+ </mergeResponse>
14
+ </soapenv:Body>
15
+ </soapenv:Envelope>
@@ -400,6 +400,46 @@ describe Soapforce::Client do
400
400
 
401
401
  end
402
402
 
403
+ describe "#merge" do
404
+ before(:each) do
405
+ @body = "<tns:merge><tns:request><tns:masterRecord xsi:type=\"Account\"><tns:id>001160000000000AAG</tns:id></tns:masterRecord><tns:recordToMergeIds>001140000000000AA4</tns:recordToMergeIds><tns:recordToMergeIds>001150000000000AAO</tns:recordToMergeIds></tns:request></tns:merge>"
406
+ @object = { id: "001160000000000AAG" }
407
+ @to_merge = ['001140000000000AA4','001150000000000AAO']
408
+ end
409
+
410
+ it "merges objects together" do
411
+ stub = stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response'})
412
+ response = subject.merge("Account", @object, @to_merge)
413
+
414
+ response[:success].should be_true
415
+ response[:id].should == @object[:id]
416
+ response[:merged_record_ids].sort.should == @to_merge
417
+ end
418
+
419
+ it "returns false if merge fails" do
420
+ stub = stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response_failure'})
421
+ response = subject.merge("Account", @object, @to_merge)
422
+
423
+ response.should be_false
424
+ end
425
+
426
+ it "merges objects with a bang" do
427
+ stub = stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response'})
428
+ response = subject.merge!("Account", @object, @to_merge)
429
+
430
+ response[:success].should be_true
431
+ response[:id].should == @object[:id]
432
+ response[:merged_record_ids].sort.should == @to_merge
433
+ end
434
+
435
+ it "raises an exception if merge fails" do
436
+ stub = stub_api_request(endpoint, {with_body: @body, fixture: 'merge_response_failure'})
437
+ expect {
438
+ subject.merge!('Account', @object, @to_merge)
439
+ }.to raise_error(Savon::Error)
440
+ end
441
+ end
442
+
403
443
  describe "process" do
404
444
 
405
445
  it "process submit request without approvers" do
metadata CHANGED
@@ -1,20 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Heth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.3.0
20
20
  - - <
@@ -24,7 +24,7 @@ dependencies:
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ! '>='
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 2.3.0
30
30
  - - <
@@ -37,7 +37,7 @@ dependencies:
37
37
  - - ~>
38
38
  - !ruby/object:Gem::Version
39
39
  version: 2.14.0
40
- - - ! '>='
40
+ - - '>='
41
41
  - !ruby/object:Gem::Version
42
42
  version: 2.14.0
43
43
  type: :development
@@ -47,7 +47,7 @@ dependencies:
47
47
  - - ~>
48
48
  - !ruby/object:Gem::Version
49
49
  version: 2.14.0
50
- - - ! '>='
50
+ - - '>='
51
51
  - !ruby/object:Gem::Version
52
52
  version: 2.14.0
53
53
  - !ruby/object:Gem::Dependency
@@ -57,7 +57,7 @@ dependencies:
57
57
  - - ~>
58
58
  - !ruby/object:Gem::Version
59
59
  version: 1.17.0
60
- - - ! '>='
60
+ - - '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: 1.17.0
63
63
  type: :development
@@ -67,7 +67,7 @@ dependencies:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
69
  version: 1.17.0
70
- - - ! '>='
70
+ - - '>='
71
71
  - !ruby/object:Gem::Version
72
72
  version: 1.17.0
73
73
  - !ruby/object:Gem::Dependency
@@ -77,7 +77,7 @@ dependencies:
77
77
  - - ~>
78
78
  - !ruby/object:Gem::Version
79
79
  version: 0.9.0
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.9.0
83
83
  type: :development
@@ -87,7 +87,7 @@ dependencies:
87
87
  - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.9.0
90
- - - ! '>='
90
+ - - '>='
91
91
  - !ruby/object:Gem::Version
92
92
  version: 0.9.0
93
93
  description: A ruby client for the Salesforce SOAP API based on Savon.
@@ -100,6 +100,7 @@ files:
100
100
  - .gitignore
101
101
  - .rspec
102
102
  - .travis.yml
103
+ - CHANGELOG.md
103
104
  - Gemfile
104
105
  - LICENSE.txt
105
106
  - README.md
@@ -122,6 +123,8 @@ files:
122
123
  - spec/fixtures/describe_s_objects_response.xml
123
124
  - spec/fixtures/get_user_info_response.xml
124
125
  - spec/fixtures/login_response.xml
126
+ - spec/fixtures/merge_response.xml
127
+ - spec/fixtures/merge_response_failure.xml
125
128
  - spec/fixtures/org_id_response.xml
126
129
  - spec/fixtures/process_submit_request_response.xml
127
130
  - spec/fixtures/process_workitem_request_response.xml
@@ -149,17 +152,17 @@ require_paths:
149
152
  - lib
150
153
  required_ruby_version: !ruby/object:Gem::Requirement
151
154
  requirements:
152
- - - ! '>='
155
+ - - '>='
153
156
  - !ruby/object:Gem::Version
154
157
  version: '0'
155
158
  required_rubygems_version: !ruby/object:Gem::Requirement
156
159
  requirements:
157
- - - ! '>='
160
+ - - '>='
158
161
  - !ruby/object:Gem::Version
159
162
  version: '0'
160
163
  requirements: []
161
164
  rubyforge_project:
162
- rubygems_version: 2.2.2
165
+ rubygems_version: 2.4.5
163
166
  signing_key:
164
167
  specification_version: 4
165
168
  summary: Wraps Savon with helper methods and custom types for interacting with the
@@ -175,6 +178,8 @@ test_files:
175
178
  - spec/fixtures/describe_s_objects_response.xml
176
179
  - spec/fixtures/get_user_info_response.xml
177
180
  - spec/fixtures/login_response.xml
181
+ - spec/fixtures/merge_response.xml
182
+ - spec/fixtures/merge_response_failure.xml
178
183
  - spec/fixtures/org_id_response.xml
179
184
  - spec/fixtures/process_submit_request_response.xml
180
185
  - spec/fixtures/process_workitem_request_response.xml