restforce 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of restforce might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f155672fa355a4c60e63fa1f66ef16692a16e886
4
- data.tar.gz: aa39f74eda4066a8a8addce8907423e9cb536bd7
3
+ metadata.gz: 55b1c7df7f025b501b8b56290e75934efdc400c8
4
+ data.tar.gz: 49759852d78eb73a8a305d04cc8d951dbd1ba5a1
5
5
  SHA512:
6
- metadata.gz: e081ce4d5954161f172634639c36e8a7646f5500934830f1a2795ca40ae49b6e706a16109f19e6998a0082284061e469a09ff55252aa6ae7e8432485dfd281d3
7
- data.tar.gz: 17dd0fe6fb064e1e05f312a3ac6edcaf10dfafbec79c422db8de824dc1b98bfacfa3a9c29f0a3eb885e27a97f40cfff05b82c408c941fbbdc077ad7075a4ef5a
6
+ metadata.gz: c6ed3ca069f40e557f566da9cb4da84f87c2640e3569afbd60484160cde66fc6fc1e1812f49d7589394aa17050e76700ca25af2cdccd58f30db3b7e13fc3a614
7
+ data.tar.gz: f1bad005c4550aa56465c5f20a86c78d621ee6932bb4c485a177845c94e1d7af70fab109478f9aaaf6f1e47d21426423e5502f9d34f2d9a022ea4f66f495e22d
data/README.md CHANGED
@@ -174,6 +174,18 @@ client.find('Account', '1234', 'Some_External_Id_Field__c')
174
174
  # => #<Restforce::SObject Id="001D000000INjVe" Name="Test" LastModifiedBy="005G0000002f8FHIAY" ... >
175
175
  ```
176
176
 
177
+ ### select
178
+
179
+ ```ruby
180
+ client.select('Account', '001D000000INjVe', ["Id"])
181
+ # => {"attributes" : {"type" : "Account","url" : "/services/data/v20.0/sobjects/Account/001D000000INjVe"},
182
+ # "Id" : "001D000000INjVe"}
183
+
184
+ client.select('Account', '001D000000INjVe', ["Id"], 'Some_External_Id_Field__c')
185
+ # => {"attributes" : {"type" : "Account","url" : "/services/data/v20.0/sobjects/Account/Some_External_Id_Field__c/001D000000INjVe"},
186
+ # "Id" : "003F000000BGIn3"}
187
+ ```
188
+
177
189
  ### search
178
190
 
179
191
  ```ruby
@@ -297,7 +309,7 @@ client.create 'Document', FolderId: '00lE0000000FJ6H',
297
309
  Body: Base64::encode64(File.read('image.jpg'))
298
310
  ```
299
311
 
300
- _See also: http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm_
312
+ _See also: [Inserting or updating blob data](http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm)_
301
313
 
302
314
  * * *
303
315
 
@@ -379,7 +391,7 @@ EM.run {
379
391
  Boom, you're now receiving push notifications when Accounts are
380
392
  created/updated.
381
393
 
382
- _See also: http://www.salesforce.com/us/developer/docs/api_streaming/index.htm_
394
+ _See also: [Force.com Streaming API docs](http://www.salesforce.com/us/developer/docs/api_streaming/index.htm)_
383
395
 
384
396
  * * *
385
397
 
@@ -300,6 +300,23 @@ module Restforce
300
300
  api_get(field ? "sobjects/#{sobject}/#{field}/#{id}" : "sobjects/#{sobject}/#{id}").body
301
301
  end
302
302
 
303
+ # Public: Finds a single record and returns select fields.
304
+ #
305
+ # sobject - The String name of the sobject.
306
+ # id - The id of the record. If field is specified, id should be the id
307
+ # of the external field.
308
+ # select - A String array denoting the fields to select. If nil or empty array
309
+ # is passed, all fields are selected.
310
+ # field - External ID field to use (default: nil).
311
+ #
312
+ def select(sobject, id, select, field=nil)
313
+ path = field ? "sobjects/#{sobject}/#{field}/#{id}" : "sobjects/#{sobject}/#{id}"
314
+ path << "?fields=#{select.join(",")}" if select && select.any?
315
+
316
+ api_get(path).body
317
+ end
318
+
319
+
303
320
  private
304
321
 
305
322
  # Internal: Returns a path to an api endpoint
@@ -1,3 +1,3 @@
1
1
  module Restforce
2
- VERSION = '1.4.2'
2
+ VERSION = '1.4.3'
3
3
  end
@@ -0,0 +1,8 @@
1
+ {
2
+ "attributes" : {
3
+ "type" : "Whizbang",
4
+ "url" : "/services/data/v20.0/sobjects/Whizbang/23foo"
5
+ },
6
+ "External_Field__c" : "1234",
7
+ "Id" : "23foo"
8
+ }
@@ -202,6 +202,43 @@ shared_examples_for Restforce::AbstractClient do
202
202
  end
203
203
  end
204
204
 
205
+ describe '.select' do
206
+ context 'when no external id is specified' do
207
+ context 'when no select list is specified' do
208
+ requests 'sobjects/Account/1234',
209
+ :fixture => 'sobject/sobject_select_success_response'
210
+
211
+ subject { client.select('Account', '1234', nil, nil) }
212
+ it { should be_a Hash }
213
+ end
214
+ context 'when select list is specified' do
215
+ requests 'sobjects/Account/1234\?fields=External_Field__c',
216
+ :fixture => 'sobject/sobject_select_success_response'
217
+
218
+ subject { client.select('Account', '1234', ['External_Field__c']) }
219
+ it { should be_a Hash }
220
+ end
221
+ end
222
+
223
+ context 'when an external id is specified' do
224
+ context 'when no select list is specified' do
225
+ requests 'sobjects/Account/External_Field__c/1234',
226
+ :fixture => 'sobject/sobject_select_success_response'
227
+
228
+ subject { client.select('Account', '1234', nil, 'External_Field__c') }
229
+ it { should be_a Hash }
230
+ end
231
+
232
+ context 'when select list is specified' do
233
+ requests 'sobjects/Account/External_Field__c/1234\?fields=External_Field__c',
234
+ :fixture => 'sobject/sobject_select_success_response'
235
+
236
+ subject { client.select('Account', '1234', ['External_Field__c'], 'External_Field__c') }
237
+ it { should be_a Hash }
238
+ end
239
+ end
240
+ end
241
+
205
242
  describe '.authenticate!' do
206
243
  subject(:authenticate!) { client.authenticate! }
207
244
 
@@ -62,7 +62,7 @@ shared_examples_for Restforce::Data::Client do
62
62
  end
63
63
  end
64
64
 
65
- describe '.subcribe', :event_machine => true do
65
+ describe '.subscribe', :event_machine => true do
66
66
  context 'when given a single pushtopic' do
67
67
  it 'subscribes to the pushtopic' do
68
68
  client.faye.should_receive(:subscribe).with(['/topic/PushTopic'])
@@ -241,4 +241,53 @@ describe Restforce::Concerns::API do
241
241
  end
242
242
  end
243
243
  end
244
- end
244
+
245
+ describe '.select' do
246
+ let(:sobject) { 'Whizbang' }
247
+ let(:id) { '1234' }
248
+ let(:field) { nil }
249
+ let(:select) { nil }
250
+ subject(:result) { client.select(sobject, id, select, field) }
251
+
252
+ context 'when no external id is specified' do
253
+ context 'when no select list is specified' do
254
+ it 'returns the full representation of the object' do
255
+ client.should_receive(:api_get).
256
+ with('sobjects/Whizbang/1234').
257
+ and_return(response)
258
+ expect(result).to eq response.body
259
+ end
260
+ end
261
+ context 'when select list is specified' do
262
+ let(:select) { [:External_ID__c] }
263
+ it 'returns the full representation of the object' do
264
+ client.should_receive(:api_get).
265
+ with('sobjects/Whizbang/1234?fields=External_ID__c').
266
+ and_return(response)
267
+ expect(result).to eq response.body
268
+ end
269
+ end
270
+ end
271
+
272
+ context 'when an external id is specified' do
273
+ let(:field) { :External_ID__c }
274
+ context 'when no select list is specified' do
275
+ it 'returns the full representation of the object' do
276
+ client.should_receive(:api_get).
277
+ with('sobjects/Whizbang/External_ID__c/1234').
278
+ and_return(response)
279
+ expect(result).to eq response.body
280
+ end
281
+ end
282
+ context 'when select list is specified' do
283
+ let(:select) { [:External_ID__c] }
284
+ it 'returns the full representation of the object' do
285
+ client.should_receive(:api_get).
286
+ with('sobjects/Whizbang/External_ID__c/1234?fields=External_ID__c').
287
+ and_return(response)
288
+ expect(result).to eq response.body
289
+ end
290
+ end
291
+ end
292
+ end
293
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric J. Holmes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-16 00:00:00.000000000 Z
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -211,6 +211,7 @@ files:
211
211
  - spec/fixtures/sobject/sobject_describe_success_response.json
212
212
  - spec/fixtures/sobject/sobject_find_error_response.json
213
213
  - spec/fixtures/sobject/sobject_find_success_response.json
214
+ - spec/fixtures/sobject/sobject_select_success_response.json
214
215
  - spec/fixtures/sobject/upsert_created_success_response.json
215
216
  - spec/fixtures/sobject/upsert_error_response.json
216
217
  - spec/fixtures/sobject/upsert_multiple_error_response.json
@@ -269,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
270
  version: '0'
270
271
  requirements: []
271
272
  rubyforge_project:
272
- rubygems_version: 2.0.3
273
+ rubygems_version: 2.0.14
273
274
  signing_key:
274
275
  specification_version: 4
275
276
  summary: A lightweight ruby client for the Salesforce REST api.
@@ -300,6 +301,7 @@ test_files:
300
301
  - spec/fixtures/sobject/sobject_describe_success_response.json
301
302
  - spec/fixtures/sobject/sobject_find_error_response.json
302
303
  - spec/fixtures/sobject/sobject_find_success_response.json
304
+ - spec/fixtures/sobject/sobject_select_success_response.json
303
305
  - spec/fixtures/sobject/upsert_created_success_response.json
304
306
  - spec/fixtures/sobject/upsert_error_response.json
305
307
  - spec/fixtures/sobject/upsert_multiple_error_response.json