restforce 5.2.1 → 5.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +8 -3
- data/CHANGELOG.md +14 -0
- data/Gemfile +3 -3
- data/README.md +1 -1
- data/lib/restforce/collection.rb +5 -1
- data/lib/restforce/concerns/base.rb +2 -2
- data/lib/restforce/concerns/composite_api.rb +4 -4
- data/lib/restforce/error_code.rb +3 -0
- data/lib/restforce/version.rb +1 -1
- data/restforce.gemspec +1 -1
- data/spec/fixtures/sobject/list_view_results_success_response.json +151 -0
- data/spec/unit/collection_spec.rb +18 -0
- data/spec/unit/concerns/composite_api_spec.rb +2 -2
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfdaff5160d8845afd9c6ed3c384c7edf7d9ecb2593d562bae4d9a4812904137
|
4
|
+
data.tar.gz: 8510146b906c8f7f0869a467db96d9bd3416446338a9d237d8c2e633c911cc35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 592471696b0c585cb73bc26cca75267cfc7a2f3543f86449edd4e3ffc5401975cd4ded7cc7a20b63b5854434c06e6e63c48e0f49bf51839b8b8bee15e02113e8
|
7
|
+
data.tar.gz: 71c9272a0799c6e899bbdd56a0380b6ae5b7112d11e56fb3860a10ca0ba0b1dfb9cf58bb25b0bf59ad8f8b38f50360f5f8ccbed4090afa194a67a19a7ae28318
|
data/.circleci/config.yml
CHANGED
@@ -34,23 +34,28 @@ references:
|
|
34
34
|
destination: test-results
|
35
35
|
|
36
36
|
jobs:
|
37
|
+
build-ruby31:
|
38
|
+
docker:
|
39
|
+
- image: cimg/ruby:3.1
|
40
|
+
steps: *steps
|
37
41
|
build-ruby30:
|
38
42
|
docker:
|
39
|
-
- image:
|
43
|
+
- image: cimg/ruby:3.0
|
40
44
|
steps: *steps
|
41
45
|
build-ruby27:
|
42
46
|
docker:
|
43
|
-
- image:
|
47
|
+
- image: cimg/ruby:2.7
|
44
48
|
steps: *steps
|
45
49
|
build-ruby26:
|
46
50
|
docker:
|
47
|
-
- image:
|
51
|
+
- image: cimg/ruby:2.6
|
48
52
|
steps: *steps
|
49
53
|
|
50
54
|
workflows:
|
51
55
|
version: 2
|
52
56
|
tests:
|
53
57
|
jobs:
|
58
|
+
- build-ruby31
|
54
59
|
- build-ruby30
|
55
60
|
- build-ruby27
|
56
61
|
- build-ruby26
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# 5.2.4 (Mar 16, 2022)
|
2
|
+
|
3
|
+
* Fix `Restforce::Collection#size` for Salesforce APIs that use the `size` property to return the total number of results, instead of `totalSize` (@kwong-yw)
|
4
|
+
|
5
|
+
# 5.2.3 (Jan 17, 2022)
|
6
|
+
|
7
|
+
* Add official support for Ruby 3.1 (@timrogers)
|
8
|
+
* Fix handling of responses from the Composite API (@robob27)
|
9
|
+
* Fix dependencies to correctly declare that the gem doesn't work with [faraday](https://github.com/lostisland/faraday) `v1.9.0` or later (@timrogers)
|
10
|
+
|
11
|
+
# 5.2.2 (Dec 16, 2021)
|
12
|
+
|
13
|
+
* Handle the `MALFORMED_SEARCH` error returned by Salesforce (@timrogers)
|
14
|
+
|
1
15
|
# 5.2.1 (Dec 8, 2021)
|
2
16
|
|
3
17
|
* Handle the `OPERATION_TOO_LARGE` error returned by Salesforce (@timrogers)
|
data/Gemfile
CHANGED
@@ -8,10 +8,10 @@ gem 'guard-rspec'
|
|
8
8
|
gem 'guard-rubocop'
|
9
9
|
gem 'jruby-openssl', platforms: :jruby
|
10
10
|
gem 'rake'
|
11
|
-
gem 'rspec', '~> 3.
|
11
|
+
gem 'rspec', '~> 3.11.0'
|
12
12
|
gem 'rspec-collection_matchers', '~> 1.2.0'
|
13
13
|
gem 'rspec-its', '~> 1.3.0'
|
14
|
-
gem 'rspec_junit_formatter', '~> 0.
|
15
|
-
gem 'rubocop', '~> 1.
|
14
|
+
gem 'rspec_junit_formatter', '~> 0.5.1'
|
15
|
+
gem 'rubocop', '~> 1.26.0'
|
16
16
|
gem 'simplecov', '~> 0.21.2'
|
17
17
|
gem 'webmock', '~> 3.14.0'
|
data/README.md
CHANGED
data/lib/restforce/collection.rb
CHANGED
@@ -30,8 +30,12 @@ module Restforce
|
|
30
30
|
# Return the number of items in the Collection without making any additional
|
31
31
|
# requests and going through all of the pages of results, one by one. Instead,
|
32
32
|
# we can rely on the total count of results which Salesforce returns.
|
33
|
+
#
|
34
|
+
# Most of the Salesforce API returns this in the `totalSize` attribute. For
|
35
|
+
# some reason, the [List View Results](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_listviewresults.htm)
|
36
|
+
# endpoint (and maybe others?!) uses the `size` attribute.
|
33
37
|
def size
|
34
|
-
@raw_page['totalSize']
|
38
|
+
@raw_page['totalSize'] || @raw_page['size']
|
35
39
|
end
|
36
40
|
alias length size
|
37
41
|
|
@@ -61,9 +61,9 @@ module Restforce
|
|
61
61
|
def initialize(opts = {})
|
62
62
|
raise ArgumentError, 'Please specify a hash of options' unless opts.is_a?(Hash)
|
63
63
|
|
64
|
-
@options = Restforce.configuration.options.
|
64
|
+
@options = Restforce.configuration.options.to_h do |option|
|
65
65
|
[option, Restforce.configuration.send(option)]
|
66
|
-
end
|
66
|
+
end
|
67
67
|
|
68
68
|
@options.merge! opts
|
69
69
|
yield builder if block_given?
|
@@ -24,12 +24,12 @@ module Restforce
|
|
24
24
|
}
|
25
25
|
response = api_post('composite', properties.to_json)
|
26
26
|
|
27
|
-
results = response.body['
|
28
|
-
has_errors = results.any? { |result| result['
|
27
|
+
results = response.body['compositeResponse']
|
28
|
+
has_errors = results.any? { |result| result['httpStatusCode'].digits.last == 4 }
|
29
29
|
if all_or_none && has_errors
|
30
|
-
last_error_index = results.rindex { |result| result['
|
30
|
+
last_error_index = results.rindex { |result| result['httpStatusCode'] != 412 }
|
31
31
|
last_error = results[last_error_index]
|
32
|
-
raise CompositeAPIError, last_error['
|
32
|
+
raise CompositeAPIError, last_error['body'][0]['errorCode']
|
33
33
|
end
|
34
34
|
|
35
35
|
results
|
data/lib/restforce/error_code.rb
CHANGED
@@ -277,6 +277,8 @@ module Restforce
|
|
277
277
|
|
278
278
|
class MalformedQuery < ResponseError; end
|
279
279
|
|
280
|
+
class MalformedSearch < ResponseError; end
|
281
|
+
|
280
282
|
class ManagerNotDefined < ResponseError; end
|
281
283
|
|
282
284
|
class MassmailRetryLimitExceeded < ResponseError; end
|
@@ -551,6 +553,7 @@ module Restforce
|
|
551
553
|
"LOGIN_MUST_USE_SECURITY_TOKEN" => LoginMustUseSecurityToken,
|
552
554
|
"MALFORMED_ID" => MalformedId,
|
553
555
|
"MALFORMED_QUERY" => MalformedQuery,
|
556
|
+
"MALFORMED_SEARCH" => MalformedSearch,
|
554
557
|
"MANAGER_NOT_DEFINED" => ManagerNotDefined,
|
555
558
|
"MASSMAIL_RETRY_LIMIT_EXCEEDED" => MassmailRetryLimitExceeded,
|
556
559
|
"MASS_MAIL_LIMIT_EXCEEDED" => MassMailLimitExceeded,
|
data/lib/restforce/version.rb
CHANGED
data/restforce.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
|
|
25
25
|
|
26
26
|
gem.required_ruby_version = '>= 2.6'
|
27
27
|
|
28
|
-
gem.add_dependency 'faraday', '
|
28
|
+
gem.add_dependency 'faraday', '< 1.9.0', '>= 0.9.0'
|
29
29
|
gem.add_dependency 'faraday_middleware', ['>= 0.8.8', '<= 2.0']
|
30
30
|
gem.add_dependency 'hashie', '>= 1.2.0', '< 6.0'
|
31
31
|
gem.add_dependency 'jwt', ['>= 1.5.6']
|
@@ -0,0 +1,151 @@
|
|
1
|
+
{
|
2
|
+
"columns" : [ {
|
3
|
+
"ascendingLabel" : "Z-A",
|
4
|
+
"descendingLabel" : "A-Z",
|
5
|
+
"fieldNameOrPath" : "Name",
|
6
|
+
"hidden" : false,
|
7
|
+
"label" : "Account Name",
|
8
|
+
"selectListItem" : "Name",
|
9
|
+
"sortDirection" : "ascending",
|
10
|
+
"sortIndex" : 0,
|
11
|
+
"sortable" : true,
|
12
|
+
"type" : "string"
|
13
|
+
}, {
|
14
|
+
"ascendingLabel" : "Z-A",
|
15
|
+
"descendingLabel" : "A-Z",
|
16
|
+
"fieldNameOrPath" : "Site",
|
17
|
+
"hidden" : false,
|
18
|
+
"label" : "Account Site",
|
19
|
+
"selectListItem" : "Site",
|
20
|
+
"sortDirection" : null,
|
21
|
+
"sortIndex" : null,
|
22
|
+
"sortable" : true,
|
23
|
+
"type" : "string"
|
24
|
+
}, {
|
25
|
+
"ascendingLabel" : "Z-A",
|
26
|
+
"descendingLabel" : "A-Z",
|
27
|
+
"fieldNameOrPath" : "BillingState",
|
28
|
+
"hidden" : false,
|
29
|
+
"label" : "Billing State/Province",
|
30
|
+
"selectListItem" : "BillingState",
|
31
|
+
"sortDirection" : null,
|
32
|
+
"sortIndex" : null,
|
33
|
+
"sortable" : true,
|
34
|
+
"type" : "string"
|
35
|
+
}, {
|
36
|
+
"ascendingLabel" : "9-0",
|
37
|
+
"descendingLabel" : "0-9",
|
38
|
+
"fieldNameOrPath" : "Phone",
|
39
|
+
"hidden" : false,
|
40
|
+
"label" : "Phone",
|
41
|
+
"selectListItem" : "Phone",
|
42
|
+
"sortDirection" : null,
|
43
|
+
"sortIndex" : null,
|
44
|
+
"sortable" : true,
|
45
|
+
"type" : "phone"
|
46
|
+
}, {
|
47
|
+
"ascendingLabel" : "Low to High",
|
48
|
+
"descendingLabel" : "High to Low",
|
49
|
+
"fieldNameOrPath" : "Type",
|
50
|
+
"hidden" : false,
|
51
|
+
"label" : "Type",
|
52
|
+
"selectListItem" : "toLabel(Type)",
|
53
|
+
"sortDirection" : null,
|
54
|
+
"sortIndex" : null,
|
55
|
+
"sortable" : true,
|
56
|
+
"type" : "picklist"
|
57
|
+
}, {
|
58
|
+
"ascendingLabel" : "Z-A",
|
59
|
+
"descendingLabel" : "A-Z",
|
60
|
+
"fieldNameOrPath" : "Owner.Alias",
|
61
|
+
"hidden" : false,
|
62
|
+
"label" : "Account Owner Alias",
|
63
|
+
"selectListItem" : "Owner.Alias",
|
64
|
+
"sortDirection" : null,
|
65
|
+
"sortIndex" : null,
|
66
|
+
"sortable" : true,
|
67
|
+
"type" : "string"
|
68
|
+
}, {
|
69
|
+
"ascendingLabel" : null,
|
70
|
+
"descendingLabel" : null,
|
71
|
+
"fieldNameOrPath" : "Id",
|
72
|
+
"hidden" : true,
|
73
|
+
"label" : "Account ID",
|
74
|
+
"selectListItem" : "Id",
|
75
|
+
"sortDirection" : null,
|
76
|
+
"sortIndex" : null,
|
77
|
+
"sortable" : false,
|
78
|
+
"type" : "id"
|
79
|
+
}, {
|
80
|
+
"ascendingLabel" : null,
|
81
|
+
"descendingLabel" : null,
|
82
|
+
"fieldNameOrPath" : "CreatedDate",
|
83
|
+
"hidden" : true,
|
84
|
+
"label" : "Created Date",
|
85
|
+
"selectListItem" : "CreatedDate",
|
86
|
+
"sortDirection" : null,
|
87
|
+
"sortIndex" : null,
|
88
|
+
"sortable" : false,
|
89
|
+
"type" : "datetime"
|
90
|
+
}, {
|
91
|
+
"ascendingLabel" : null,
|
92
|
+
"descendingLabel" : null,
|
93
|
+
"fieldNameOrPath" : "LastModifiedDate",
|
94
|
+
"hidden" : true,
|
95
|
+
"label" : "Last Modified Date",
|
96
|
+
"selectListItem" : "LastModifiedDate",
|
97
|
+
"sortDirection" : null,
|
98
|
+
"sortIndex" : null,
|
99
|
+
"sortable" : false,
|
100
|
+
"type" : "datetime"
|
101
|
+
}, {
|
102
|
+
"ascendingLabel" : null,
|
103
|
+
"descendingLabel" : null,
|
104
|
+
"fieldNameOrPath" : "SystemModstamp",
|
105
|
+
"hidden" : true,
|
106
|
+
"label" : "System Modstamp",
|
107
|
+
"selectListItem" : "SystemModstamp",
|
108
|
+
"sortDirection" : null,
|
109
|
+
"sortIndex" : null,
|
110
|
+
"sortable" : false,
|
111
|
+
"type" : "datetime"
|
112
|
+
} ],
|
113
|
+
"developerName" : "MyAccounts",
|
114
|
+
"done" : true,
|
115
|
+
"id" : "00BD0000005WcCN",
|
116
|
+
"label" : "My Accounts",
|
117
|
+
"records" : [ {
|
118
|
+
"columns" : [ {
|
119
|
+
"fieldNameOrPath" : "Name",
|
120
|
+
"value" : "Burlington Textiles Corp of America"
|
121
|
+
}, {
|
122
|
+
"fieldNameOrPath" : "Site",
|
123
|
+
"value" : null
|
124
|
+
}, {
|
125
|
+
"fieldNameOrPath" : "BillingState",
|
126
|
+
"value" : "NC"
|
127
|
+
}, {
|
128
|
+
"fieldNameOrPath" : "Phone",
|
129
|
+
"value" : "(336) 222-7000"
|
130
|
+
}, {
|
131
|
+
"fieldNameOrPath" : "Type",
|
132
|
+
"value" : "Customer - Direct"
|
133
|
+
}, {
|
134
|
+
"fieldNameOrPath" : "Owner.Alias",
|
135
|
+
"value" : "TUser"
|
136
|
+
}, {
|
137
|
+
"fieldNameOrPath" : "Id",
|
138
|
+
"value" : "001D000000JliSTIAZ"
|
139
|
+
}, {
|
140
|
+
"fieldNameOrPath" : "CreatedDate",
|
141
|
+
"value" : "Fri Aug 01 21:15:46 GMT 2014"
|
142
|
+
}, {
|
143
|
+
"fieldNameOrPath" : "LastModifiedDate",
|
144
|
+
"value" : "Fri Aug 01 21:15:46 GMT 2014"
|
145
|
+
}, {
|
146
|
+
"fieldNameOrPath" : "SystemModstamp",
|
147
|
+
"value" : "Fri Aug 01 21:15:46 GMT 2014"
|
148
|
+
} ]
|
149
|
+
} ],
|
150
|
+
"size" : 1
|
151
|
+
}
|
@@ -63,6 +63,24 @@ describe Restforce::Collection do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
describe '#size' do
|
67
|
+
subject(:size) do
|
68
|
+
described_class.new(JSON.parse(fixture(sobject_fixture)), client).size
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'when the query response contains a totalSize field' do
|
72
|
+
let(:sobject_fixture) { 'sobject/query_success_response' }
|
73
|
+
|
74
|
+
it { should eq 1 }
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when the query response contains a size field' do
|
78
|
+
let(:sobject_fixture) { 'sobject/list_view_results_success_response' }
|
79
|
+
|
80
|
+
it { should eq 1 }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
66
84
|
describe '#empty?' do
|
67
85
|
subject(:empty?) do
|
68
86
|
described_class.new(JSON.parse(fixture(sobject_fixture)), client).empty?
|
@@ -128,7 +128,7 @@ describe Restforce::Concerns::CompositeAPI do
|
|
128
128
|
describe '#composite' do
|
129
129
|
let(:method) { :composite }
|
130
130
|
let(:all_or_none) { false }
|
131
|
-
let(:response) { double('Faraday::Response', body: { '
|
131
|
+
let(:response) { double('Faraday::Response', body: { 'compositeResponse' => [] }) }
|
132
132
|
it_behaves_like 'composite requests'
|
133
133
|
end
|
134
134
|
|
@@ -136,7 +136,7 @@ describe Restforce::Concerns::CompositeAPI do
|
|
136
136
|
let(:method) { :composite! }
|
137
137
|
let(:all_or_none) { true }
|
138
138
|
let(:response) do
|
139
|
-
double('Faraday::Response', body: { '
|
139
|
+
double('Faraday::Response', body: { 'compositeResponse' => [] })
|
140
140
|
end
|
141
141
|
it_behaves_like 'composite requests'
|
142
142
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Rogers
|
@@ -9,15 +9,15 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "<"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 1.9.0
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 0.9.0
|
@@ -25,9 +25,9 @@ dependencies:
|
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
-
- - "
|
28
|
+
- - "<"
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
30
|
+
version: 1.9.0
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.9.0
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- spec/fixtures/sobject/get_deleted_success_response.json
|
171
171
|
- spec/fixtures/sobject/get_updated_success_response.json
|
172
172
|
- spec/fixtures/sobject/list_sobjects_success_response.json
|
173
|
+
- spec/fixtures/sobject/list_view_results_success_response.json
|
173
174
|
- spec/fixtures/sobject/org_query_response.json
|
174
175
|
- spec/fixtures/sobject/query_aggregate_success_response.json
|
175
176
|
- spec/fixtures/sobject/query_empty_response.json
|
@@ -254,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
255
|
- !ruby/object:Gem::Version
|
255
256
|
version: '0'
|
256
257
|
requirements: []
|
257
|
-
rubygems_version: 3.
|
258
|
+
rubygems_version: 3.3.3
|
258
259
|
signing_key:
|
259
260
|
specification_version: 4
|
260
261
|
summary: A lightweight Ruby client for the Salesforce REST API
|
@@ -273,6 +274,7 @@ test_files:
|
|
273
274
|
- spec/fixtures/sobject/get_deleted_success_response.json
|
274
275
|
- spec/fixtures/sobject/get_updated_success_response.json
|
275
276
|
- spec/fixtures/sobject/list_sobjects_success_response.json
|
277
|
+
- spec/fixtures/sobject/list_view_results_success_response.json
|
276
278
|
- spec/fixtures/sobject/org_query_response.json
|
277
279
|
- spec/fixtures/sobject/query_aggregate_success_response.json
|
278
280
|
- spec/fixtures/sobject/query_empty_response.json
|