restforce 2.2.1 → 2.3.0

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: ffde6a2ff06c51931a6bab34f4d1f65cca529dab
4
- data.tar.gz: fe9a373b83dbfef51434a2045c4dfa698094d0fb
3
+ metadata.gz: 88a93138f74a67b4da1371232281d45950539b18
4
+ data.tar.gz: f3603bbb017e9864ce6873524c4206ddf4142b61
5
5
  SHA512:
6
- metadata.gz: d2215c530292416152291284e81842411a02cc9e19a29b1e08ce745a63d53abb9fd68cea37f13b52138849e537c57aa255c80562c6a0a78062469541e3b74e2d
7
- data.tar.gz: 09a8ae9879b0dca63e789f6bdb8ffdd9d2c92f9a297fcbafe051f240ff5c0a01c58108cf796d2b11791025b8922e34f53c4d61d4350d082d3a91a549b051ae73
6
+ metadata.gz: 14cbc34c3bc5bd7b766cfc71c3ecae01fbb370be79b4c02078493949c21f3ad8df4679422f574b587e15344f9388b09c311214f1a6935d5c0dfe364556dc164f
7
+ data.tar.gz: 47fce31a67fe328abe6a992b2c9030dd01b190d719526571f4e7ef98cd4e5a337b28749a1cd460d7ec019cb5ae52c7ffe63c1d228befb4ada31fa16db88d3157
@@ -4,6 +4,7 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1
6
6
  - 2.2
7
+ - 2.3.1
7
8
  - jruby-19mode
8
9
  - rbx-2
9
10
  gemfile:
@@ -1,7 +1,13 @@
1
+ # 2.3.0 (Jul 15, 2016)
2
+
3
+ * Allow the Salesforce API version to be specified with a `SALESFORCE_API_VERSION` environment variable (@jhelbig)
4
+
1
5
  ## 2.2.1 (Jun 6, 2016)
2
6
 
3
7
  * Added support for `get_deleted` call (@adambird)
4
8
 
9
+ *(This should have been a minor version rather than a patch version, following format MAJOR.MINOR.PATCH, since we use [Semantic Versioning](http://semver.org/) and this adds functionality. Sorry! @timrogers)*
10
+
5
11
  ## 2.2.0 (Mar 16, 2016)
6
12
 
7
13
  * Raise a `Faraday::Error::ClientError` for `300` responses triggered by a conflicting external ID, providing access to the response, which contains an array of the conflicting IDs (@timrogers, @michaelminter)
@@ -2,4 +2,5 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  gem 'rake'
5
+ gem 'rack', '~> 1.6.4'
5
6
  gem 'jruby-openssl', :platforms => :jruby
data/README.md CHANGED
@@ -39,6 +39,8 @@ Or install it yourself as:
39
39
 
40
40
  __As of [version 2.0.0](https://github.com/ejholmes/restforce/blob/master/CHANGELOG.md#200-jun-27-2015), this gem is only compatible with Ruby 1.9.3 and later.__ To use Ruby 1.9.2 and below, you'll need to manually specify that you wish to use version 1.5.3.
41
41
 
42
+ This gem is versioned using [Semantic Versioning](http://semver.org/), so you can be confident when updating that there will not be breaking changes outside of a major version (following format MAJOR.MINOR.PATCH, so for instance moving from 2.3.0 to 3.0.0 would be allowed to include incompatible API changes). See the [changelog](https://github.com/ejholmes/restforce/tree/master/CHANGELOG.md) for details on what has changed in each version.
43
+
42
44
  ## Usage
43
45
 
44
46
  Restforce is designed with flexibility and ease of use in mind. By default, all API calls will
@@ -108,8 +110,8 @@ client = Restforce.new :username => 'foo',
108
110
  :client_secret => 'client_secret'
109
111
  ```
110
112
 
111
- You can also set the username, password, security token, client ID and client
112
- secret in environment variables:
113
+ You can also set the username, password, security token, client ID, client
114
+ secret and API version in environment variables:
113
115
 
114
116
  ```bash
115
117
  export SALESFORCE_USERNAME="username"
@@ -117,6 +119,7 @@ export SALESFORCE_PASSWORD="password"
117
119
  export SALESFORCE_SECURITY_TOKEN="security token"
118
120
  export SALESFORCE_CLIENT_ID="client id"
119
121
  export SALESFORCE_CLIENT_SECRET="client secret"
122
+ export SALESFORCE_API_VERSION="37.0"
120
123
  ```
121
124
 
122
125
  ```ruby
@@ -1,3 +1,4 @@
1
+ require 'uri'
1
2
  require 'restforce/concerns/verbs'
2
3
 
3
4
  module Restforce
@@ -364,7 +365,7 @@ module Restforce
364
365
  fetch(attrs.keys.find { |k, v| k.to_s.downcase == field.to_s.downcase }, nil)
365
366
  attrs_without_field = attrs.
366
367
  reject { |k, v| k.to_s.downcase == field.to_s.downcase }
367
- response = api_patch "sobjects/#{sobject}/#{field}/#{external_id}",
368
+ response = api_patch "sobjects/#{sobject}/#{field}/#{URI.encode(external_id)}",
368
369
  attrs_without_field
369
370
 
370
371
  (response.body && response.body['id']) ? response.body['id'] : true
@@ -414,7 +415,11 @@ module Restforce
414
415
  #
415
416
  # Returns the Restforce::SObject sobject record.
416
417
  def find(sobject, id, field = nil)
417
- url = field ? "sobjects/#{sobject}/#{field}/#{id}" : "sobjects/#{sobject}/#{id}"
418
+ if field
419
+ url = "sobjects/#{sobject}/#{field}/#{URI.encode(id)}"
420
+ else
421
+ url = "sobjects/#{sobject}/#{id}"
422
+ end
418
423
  api_get(url).body
419
424
  end
420
425
 
@@ -428,7 +433,11 @@ module Restforce
428
433
  # field - External ID field to use (default: nil).
429
434
  #
430
435
  def select(sobject, id, select, field = nil)
431
- path = field ? "sobjects/#{sobject}/#{field}/#{id}" : "sobjects/#{sobject}/#{id}"
436
+ if field
437
+ path = "sobjects/#{sobject}/#{field}/#{URI.encode(id)}"
438
+ else
439
+ path = "sobjects/#{sobject}/#{id}"
440
+ end
432
441
  path << "?fields=#{select.join(',')}" if select && select.any?
433
442
 
434
443
  api_get(path).body
@@ -88,7 +88,7 @@ module Restforce
88
88
  end
89
89
  end
90
90
 
91
- option :api_version, default: '26.0'
91
+ option :api_version, default: lambda { ENV['SALESFORCE_API_VERSION'] || '26.0' }
92
92
 
93
93
  # The username to use during login.
94
94
  option :username, default: lambda { ENV['SALESFORCE_USERNAME'] }
@@ -1,3 +1,3 @@
1
1
  module Restforce
2
- VERSION = '2.2.1'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -344,6 +344,23 @@ describe Restforce::Concerns::API do
344
344
  end
345
345
  end
346
346
 
347
+ describe '.upsert! with multi bytes character' do
348
+ let(:sobject) { 'Whizbang' }
349
+ let(:field) { :External_ID__c }
350
+ let(:attrs) { { 'External_ID__c' => "\u{3042}" } }
351
+ subject(:result) { client.upsert!(sobject, field, attrs) }
352
+
353
+ context 'when the record is found and updated' do
354
+ it 'returns true' do
355
+ response.body.stub :[]
356
+ client.should_receive(:api_patch).
357
+ with('sobjects/Whizbang/External_ID__c/%E3%81%82', {}).
358
+ and_return(response)
359
+ expect(result).to be_true
360
+ end
361
+ end
362
+ end
363
+
347
364
  describe '.destroy!' do
348
365
  let(:id) { '1234' }
349
366
  let(:sobject) { 'Whizbang' }
@@ -381,6 +398,17 @@ describe Restforce::Concerns::API do
381
398
  expect(result).to eq response.body
382
399
  end
383
400
  end
401
+
402
+ context 'when an external id which contains multibyte characters is specified' do
403
+ let(:field) { :External_ID__c }
404
+ let(:id) { "\u{3042}" }
405
+ it 'returns the full representation of the object' do
406
+ client.should_receive(:api_get).
407
+ with('sobjects/Whizbang/External_ID__c/%E3%81%82').
408
+ and_return(response)
409
+ expect(result).to eq response.body
410
+ end
411
+ end
384
412
  end
385
413
 
386
414
  describe '.select' do
@@ -430,6 +458,28 @@ describe Restforce::Concerns::API do
430
458
  end
431
459
  end
432
460
  end
461
+
462
+ context 'when an external id which contains multibyte characters is specified' do
463
+ let(:field) { :External_ID__c }
464
+ let(:id) { "\u{3042}" }
465
+ context 'when no select list is specified' do
466
+ it 'returns the full representation of the object' do
467
+ client.should_receive(:api_get).
468
+ with('sobjects/Whizbang/External_ID__c/%E3%81%82').
469
+ and_return(response)
470
+ expect(result).to eq response.body
471
+ end
472
+ end
473
+ context 'when select list is specified' do
474
+ let(:select) { [:External_ID__c] }
475
+ it 'returns the full representation of the object' do
476
+ client.should_receive(:api_get).
477
+ with('sobjects/Whizbang/External_ID__c/%E3%81%82?fields=External_ID__c').
478
+ and_return(response)
479
+ expect(result).to eq response.body
480
+ end
481
+ end
482
+ end
433
483
  end
434
484
 
435
485
  describe "#recent" do
@@ -7,6 +7,7 @@ describe Restforce do
7
7
  ENV['SALESFORCE_SECURITY_TOKEN'] = nil
8
8
  ENV['SALESFORCE_CLIENT_ID'] = nil
9
9
  ENV['SALESFORCE_CLIENT_SECRET'] = nil
10
+ ENV['SALESFORCE_API_VERSION'] = nil
10
11
  end
11
12
 
12
13
  after do
@@ -39,7 +40,8 @@ describe Restforce do
39
40
  'SALESFORCE_CLIENT_ID' => 'client id',
40
41
  'SALESFORCE_CLIENT_SECRET' => 'client secret',
41
42
  'SALESFORCE_PROXY_URI' => 'proxy',
42
- 'SALESFORCE_HOST' => 'test.host.com' }.
43
+ 'SALESFORCE_HOST' => 'test.host.com',
44
+ 'SALESFORCE_API_VERSION' => '37.0' }.
43
45
  each { |var, value| ENV.stub(:[]).with(var).and_return(value) }
44
46
  end
45
47
 
@@ -50,6 +52,7 @@ describe Restforce do
50
52
  its(:client_secret) { should eq 'client secret' }
51
53
  its(:proxy_uri) { should eq 'proxy' }
52
54
  its(:host) { should eq 'test.host.com' }
55
+ its(:api_version) { should eq '37.0' }
53
56
  end
54
57
  end
55
58
 
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: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric J. Holmes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-06 00:00:00.000000000 Z
12
+ date: 2016-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday