restforce 2.5.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +56 -0
  3. data/.rubocop.yml +18 -3
  4. data/.rubocop_todo.yml +8 -8
  5. data/CHANGELOG.md +12 -3
  6. data/CONTRIBUTING.md +3 -3
  7. data/Gemfile +4 -2
  8. data/Guardfile +3 -1
  9. data/LICENSE +1 -1
  10. data/README.md +22 -16
  11. data/Rakefile +2 -1
  12. data/lib/restforce.rb +2 -0
  13. data/lib/restforce/abstract_client.rb +2 -0
  14. data/lib/restforce/attachment.rb +2 -0
  15. data/lib/restforce/client.rb +2 -0
  16. data/lib/restforce/collection.rb +3 -1
  17. data/lib/restforce/concerns/api.rb +11 -8
  18. data/lib/restforce/concerns/authentication.rb +2 -0
  19. data/lib/restforce/concerns/base.rb +2 -0
  20. data/lib/restforce/concerns/caching.rb +4 -2
  21. data/lib/restforce/concerns/canvas.rb +2 -0
  22. data/lib/restforce/concerns/connection.rb +26 -20
  23. data/lib/restforce/concerns/picklists.rb +7 -5
  24. data/lib/restforce/concerns/streaming.rb +2 -0
  25. data/lib/restforce/concerns/verbs.rb +3 -1
  26. data/lib/restforce/config.rb +3 -1
  27. data/lib/restforce/data/client.rb +2 -0
  28. data/lib/restforce/document.rb +2 -0
  29. data/lib/restforce/mash.rb +2 -0
  30. data/lib/restforce/middleware.rb +2 -0
  31. data/lib/restforce/middleware/authentication.rb +8 -6
  32. data/lib/restforce/middleware/authentication/password.rb +2 -0
  33. data/lib/restforce/middleware/authentication/token.rb +2 -0
  34. data/lib/restforce/middleware/authorization.rb +3 -1
  35. data/lib/restforce/middleware/caching.rb +3 -1
  36. data/lib/restforce/middleware/custom_headers.rb +2 -0
  37. data/lib/restforce/middleware/gzip.rb +5 -3
  38. data/lib/restforce/middleware/instance_url.rb +7 -3
  39. data/lib/restforce/middleware/logger.rb +2 -0
  40. data/lib/restforce/middleware/mashify.rb +2 -0
  41. data/lib/restforce/middleware/multipart.rb +7 -4
  42. data/lib/restforce/middleware/raise_error.rb +2 -0
  43. data/lib/restforce/patches/parts.rb +2 -0
  44. data/lib/restforce/signed_request.rb +2 -0
  45. data/lib/restforce/sobject.rb +2 -0
  46. data/lib/restforce/tooling/client.rb +2 -0
  47. data/lib/restforce/upload_io.rb +2 -0
  48. data/lib/restforce/version.rb +3 -1
  49. data/restforce.gemspec +17 -10
  50. data/spec/fixtures/sobject/sobject_describe_success_response.json +48 -1
  51. data/spec/integration/abstract_client_spec.rb +9 -6
  52. data/spec/integration/data/client_spec.rb +24 -5
  53. data/spec/spec_helper.rb +2 -0
  54. data/spec/support/client_integration.rb +2 -0
  55. data/spec/support/concerns.rb +2 -0
  56. data/spec/support/event_machine.rb +2 -0
  57. data/spec/support/fixture_helpers.rb +2 -0
  58. data/spec/support/matchers.rb +2 -0
  59. data/spec/support/middleware.rb +3 -1
  60. data/spec/support/mock_cache.rb +4 -2
  61. data/spec/unit/abstract_client_spec.rb +2 -0
  62. data/spec/unit/attachment_spec.rb +2 -0
  63. data/spec/unit/collection_spec.rb +5 -3
  64. data/spec/unit/concerns/api_spec.rb +30 -11
  65. data/spec/unit/concerns/authentication_spec.rb +4 -2
  66. data/spec/unit/concerns/base_spec.rb +2 -0
  67. data/spec/unit/concerns/caching_spec.rb +2 -0
  68. data/spec/unit/concerns/canvas_spec.rb +3 -1
  69. data/spec/unit/concerns/connection_spec.rb +5 -3
  70. data/spec/unit/concerns/streaming_spec.rb +3 -1
  71. data/spec/unit/config_spec.rb +10 -8
  72. data/spec/unit/data/client_spec.rb +2 -0
  73. data/spec/unit/document_spec.rb +2 -0
  74. data/spec/unit/mash_spec.rb +3 -1
  75. data/spec/unit/middleware/authentication/password_spec.rb +2 -0
  76. data/spec/unit/middleware/authentication/token_spec.rb +2 -0
  77. data/spec/unit/middleware/authentication_spec.rb +3 -1
  78. data/spec/unit/middleware/authorization_spec.rb +2 -0
  79. data/spec/unit/middleware/custom_headers_spec.rb +3 -1
  80. data/spec/unit/middleware/gzip_spec.rb +4 -2
  81. data/spec/unit/middleware/instance_url_spec.rb +2 -0
  82. data/spec/unit/middleware/logger_spec.rb +2 -0
  83. data/spec/unit/middleware/mashify_spec.rb +3 -1
  84. data/spec/unit/middleware/raise_error_spec.rb +2 -0
  85. data/spec/unit/signed_request_spec.rb +2 -0
  86. data/spec/unit/sobject_spec.rb +5 -3
  87. data/spec/unit/tooling/client_spec.rb +2 -0
  88. metadata +35 -19
  89. data/.travis.yml +0 -16
  90. data/Gemfile.travis +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 1b60a2cf872111bbd40293801c0f6754f74ccfec611b07a8010db4762b8f7e0b
4
- data.tar.gz: d3764b52e9344cbdda35fa956599ee339d4fd80ec33db8b52714572be49bb649
2
+ SHA1:
3
+ metadata.gz: a6f15b3e19ea1b3b90368ade66b38fafbe055997
4
+ data.tar.gz: d30a34bf7ea9ca49efe0edbf1034d60080f5b837
5
5
  SHA512:
6
- metadata.gz: 3ffefa209de00f2be7134324d1c04820e99790b87fb20afe3d60ff6f43cfb790ae964e94dd8a482f8e32803e1dcfc109140905c2ffb14cf9feba7f26de0693fd
7
- data.tar.gz: 7a6f11af9e118ab23cd606da4e1943107aca180470178df3ac50beea7e5c22e30d394736e2720609d81a7d7275edbe9cc7ec14079d0b9a3d6f8346807a845a57
6
+ metadata.gz: 97ddd07dbcf2415d01d7940002221d473a81343365abafdde740dc1597c4581850bdbfb571c2a747df94a586d79ce7814a76f1784e97dc9b9136bbb44be6e718
7
+ data.tar.gz: 9a91f9b00c0cce33da5593b3c12dd106f7a48dd8ab5005f27255b14f6f0cd93500975571413b570ea154201ef6a86f1b44785cb8261934bcd91c7ac64c2e800a
@@ -0,0 +1,56 @@
1
+ version: 2
2
+
3
+ references:
4
+ steps: &steps
5
+ - checkout
6
+
7
+ - run:
8
+ name: Update Bundler
9
+ command: gem install bundler
10
+
11
+ - run:
12
+ name: Install dependencies from .gemspec
13
+ command: bundle install --jobs=4 --retry=3 --path vendor/bundle
14
+
15
+ - run:
16
+ name: Run RSpec tests
17
+ command: |
18
+ mkdir /tmp/test-results
19
+
20
+ bundle exec rspec --format progress \
21
+ --format RspecJunitFormatter \
22
+ --out /tmp/test-results/rspec.xml \
23
+ --format progress \
24
+ spec/**/*_spec.rb
25
+
26
+ - run:
27
+ name: Check code style with Rubocop
28
+ command: bundle exec rubocop
29
+
30
+ - store_test_results:
31
+ path: /tmp/test-results
32
+ - store_artifacts:
33
+ path: /tmp/test-results
34
+ destination: test-results
35
+
36
+ jobs:
37
+ build-ruby251:
38
+ docker:
39
+ - image: circleci/ruby:2.5.1
40
+ steps: *steps
41
+ build-ruby244:
42
+ docker:
43
+ - image: circleci/ruby:2.4.4
44
+ steps: *steps
45
+ build-ruby237:
46
+ docker:
47
+ - image: circleci/ruby:2.3.7
48
+ steps: *steps
49
+
50
+ workflows:
51
+ version: 2
52
+ tests:
53
+ jobs:
54
+ - build-ruby251
55
+ - build-ruby244
56
+ - build-ruby237
@@ -3,11 +3,13 @@
3
3
  inherit_from: .rubocop_todo.yml
4
4
 
5
5
  AllCops:
6
- RunRailsCops: false
6
+ DisplayCopNames: true
7
7
  Include:
8
8
  - Rakefile
9
9
  Exclude:
10
10
  - .*/**/*
11
+ - vendor/**/*
12
+ TargetRubyVersion: 2.3
11
13
 
12
14
  # Limit lines to 80 characters.
13
15
  LineLength:
@@ -48,7 +50,7 @@ Style/SignalException:
48
50
  EnforcedStyle: 'only_raise'
49
51
 
50
52
  # Use trailing rather than leading dots on multi-line call chains
51
- Style/DotPosition:
53
+ Layout/DotPosition:
52
54
  EnforcedStyle: trailing
53
55
 
54
56
  # Allow non-ASCII characters (e.g. £) in comments
@@ -56,5 +58,18 @@ Style/AsciiComments:
56
58
  Enabled: false
57
59
 
58
60
  # Allow method names beginning with capital letters to match Salesforce conventions
59
- Style/MethodName:
61
+ Naming/MethodName:
60
62
  Enabled: false
63
+
64
+ Metrics/BlockLength:
65
+ Exclude:
66
+ - spec/**/*
67
+ - restforce.gemspec
68
+
69
+ Naming/FileName:
70
+ Exclude:
71
+ - Gemfile
72
+ - Guardfile
73
+
74
+ Lint/UriEscapeUnescape:
75
+ Enabled: false
@@ -23,13 +23,13 @@ Metrics/PerceivedComplexity:
23
23
  Max: 10
24
24
 
25
25
  # Offense count: 12
26
- Style/AccessorMethodName:
26
+ Naming/AccessorMethodName:
27
27
  Enabled: false
28
28
 
29
29
  # Offense count: 164
30
30
  # Cop supports --auto-correct.
31
31
  # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
32
- Style/AlignHash:
32
+ Layout/AlignHash:
33
33
  Enabled: false
34
34
 
35
35
  # Offense count: 3
@@ -45,7 +45,7 @@ Style/ClassAndModuleChildren:
45
45
 
46
46
  # Offense count: 21
47
47
  # Cop supports --auto-correct.
48
- Style/ClosingParenthesisIndentation:
48
+ Layout/ClosingParenthesisIndentation:
49
49
  Enabled: false
50
50
 
51
51
  # Offense count: 13
@@ -70,7 +70,7 @@ Style/GuardClause:
70
70
  # Offense count: 48
71
71
  # Cop supports --auto-correct.
72
72
  # Configuration parameters: EnforcedStyle, SupportedStyles.
73
- Style/IndentHash:
73
+ Layout/IndentHash:
74
74
  Enabled: false
75
75
 
76
76
  # Offense count: 70
@@ -81,12 +81,12 @@ Style/Lambda:
81
81
  # Offense count: 577
82
82
  # Cop supports --auto-correct.
83
83
  # Configuration parameters: EnforcedStyle, SupportedStyles.
84
- Style/MultilineOperationIndentation:
84
+ Layout/MultilineOperationIndentation:
85
85
  Enabled: false
86
86
 
87
87
  # Offense count: 21
88
88
  # Configuration parameters: NamePrefix, NamePrefixBlacklist.
89
- Style/PredicateName:
89
+ Naming/PredicateName:
90
90
  Enabled: false
91
91
 
92
92
  # Offense count: 4
@@ -101,13 +101,13 @@ Style/RedundantSelf:
101
101
 
102
102
  # Offense count: 28
103
103
  # Cop supports --auto-correct.
104
- Style/SingleSpaceBeforeFirstArg:
104
+ Layout/SpaceBeforeFirstArg:
105
105
  Enabled: false
106
106
 
107
107
  # Offense count: 3
108
108
  # Cop supports --auto-correct.
109
109
  # Configuration parameters: MultiSpaceAllowedForOperators.
110
- Style/SpaceAroundOperators:
110
+ Layout/SpaceAroundOperators:
111
111
  Enabled: false
112
112
 
113
113
  # Offense count: 5
@@ -1,14 +1,23 @@
1
- ## 2.5.3 (April 25, 2017)
1
+ ## 3.0.0 (Aug 2, 2018)
2
+
3
+ * __Deprecate support for Ruby 2.0, 2.1 and 2.2__, since [even Ruby 2.2 reached its end-of-life](https://www.ruby-lang.org/en/news/2018/06/20/support-of-ruby-2-2-has-ended/) in June 2018. (This is the only breaking change included in this version.)
4
+ * Fix `NoMethodError` when trying to upsert a record using a `Fixnum` as the external ID (@AlexandruCD)
5
+ * Escape record IDs passed in to the client to identify records to find, delete, etc. (@jmdx)
6
+ * Stop relying on our middleware for Gzip compression if you're using `httpclient`, since Faraday enables this automatically using `httpclient`'s built-in support (@shivanshgaur)
7
+ * Fix `get_updated` and `get_deleted` API calls by removing the erroneous leading forward slash from the path (@scottolsen)
8
+ * Fix unpacking of dependent picklist options (@parkm)
9
+
10
+ ## 2.5.3 (Apr 25, 2017)
2
11
 
3
12
  * Raise an error where a custom external ID field name is supplied to `upsert` and `upsert!`, but it is missing from the provided attributes (@velveret)
4
13
  * Use the Restforce client's configured SSL options for authentication requests (@jvdp)
5
- * Fix bug where `upsert` and `upsert!` mutate the provided attributes, previously fixed in [v1.5.3](https://github.com/ejholmes/restforce/blob/master/CHANGELOG.md#153-jun-26-2015) (@velveret)
14
+ * Fix bug where `upsert` and `upsert!` mutate the provided attributes, previously fixed in [v1.5.3](https://github.com/restforce/restforce/blob/master/CHANGELOG.md#153-jun-26-2015) (@velveret)
6
15
 
7
16
 
8
17
  ## 2.5.2 (Apr 3, 2017)
9
18
 
10
19
  * Ensure `Restforce::Middleware::Logger` is the last Faraday middleware to be called so everything is properly logged (including the effects of the `Gzip` and `CustomHeaders` middlewares which were previously running after it) (@jonnymacs)
11
- * Suppress [Hashie](https://github.com/intridea/hashie) warnings when using Hashie v3.5.0 or later (see [#295](https://github.com/ejholmes/restforce/pull/295) for details) (@janraasch)
20
+ * Suppress [Hashie](https://github.com/intridea/hashie) warnings when using Hashie v3.5.0 or later (see [#295](https://github.com/restforce/restforce/pull/295) for details) (@janraasch)
12
21
 
13
22
  ## 2.5.1 (Mar 16, 2017)
14
23
 
@@ -1,11 +1,11 @@
1
1
  # Contributing
2
2
 
3
3
  We love pull requests from everyone. By participating in this project, you
4
- agree to abide by our [code of conduct](https://github.com/ejholmes/restforce/blob/master/CODE_OF_CONDUCT.md).
4
+ agree to abide by our [code of conduct](https://github.com/restforce/restforce/blob/master/CODE_OF_CONDUCT.md).
5
5
 
6
6
  Fork, then clone the repo:
7
7
 
8
- git clone git@github.com:ejholmes/restforce.git
8
+ git clone git@github.com:restforce/restforce.git
9
9
 
10
10
  Set up your machine:
11
11
 
@@ -23,7 +23,7 @@ Make your change. Add tests for your change. Make the tests pass:
23
23
 
24
24
  script/test
25
25
 
26
- Push to your fork and [submit a pull request](https://github.com/ejholmes/restforce/compare/).
26
+ Push to your fork and [submit a pull request](https://github.com/restforce/restforce/compare/).
27
27
 
28
28
  At this point you're waiting on us. We like to at least comment on pull requests
29
29
  within a few days. We may suggest
data/Gemfile CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  gemspec
3
5
 
6
+ gem 'faraday', '~> 0.15.0'
7
+ gem 'jruby-openssl', platforms: :jruby
4
8
  gem 'rake'
5
- gem 'jruby-openssl', :platforms => :jruby
6
- gem 'faraday', '~> 0.11.0'
7
9
 
8
10
  group :development do
9
11
  gem 'guard-rspec'
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  guard 'rspec', cmd: 'bundle exec rspec', all_on_start: false, all_after_pass: false do
2
4
  watch(%r{^spec/.+_spec\.rb$})
3
5
  watch('spec/spec_helper.rb') { "spec" }
@@ -8,6 +10,6 @@ guard 'rspec', cmd: 'bundle exec rspec', all_on_start: false, all_after_pass: fa
8
10
  end
9
11
 
10
12
  guard :rubocop, all_on_start: false do
11
- watch(%r{.+\.rb$})
13
+ watch(/.+\.rb$/)
12
14
  watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
13
15
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Eric J. Holmes
1
+ Copyright (c) 2018 Eric J. Holmes and Tim Rogers
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Restforce
2
2
 
3
- [![travis-ci](https://travis-ci.org/ejholmes/restforce.png?branch=master)](https://travis-ci.org/ejholmes/restforce) [![Code Climate](https://codeclimate.com/github/ejholmes/restforce.png)](https://codeclimate.com/github/ejholmes/restforce) [![Dependency Status](https://gemnasium.com/ejholmes/restforce.png)](https://gemnasium.com/ejholmes/restforce)
3
+ [![CircleCI](https://circleci.com/gh/restforce/restforce.svg?style=svg)](https://circleci.com/gh/restforce/restforce) [![Code Climate](https://codeclimate.com/github/restforce/restforce.png)](https://codeclimate.com/github/restforce/restforce) [![Dependency Status](https://gemnasium.com/restforce/restforce.png)](https://gemnasium.com/restforce/restforce)
4
4
  ![](https://img.shields.io/gem/dt/restforce.svg)
5
5
 
6
6
  Restforce is a ruby gem for the [Salesforce REST api](http://www.salesforce.com/us/developer/docs/api_rest/index.htm).
@@ -19,13 +19,13 @@ Features include:
19
19
  * Support for dependent picklists.
20
20
  * Support for decoding [Force.com Canvas](http://www.salesforce.com/us/developer/docs/platform_connectpre/canvas_framework.pdf) signed requests. (NEW!)
21
21
 
22
- [Official Website](http://restforce.org/) | [Documentation](http://rubydoc.info/gems/restforce/frames) | [Changelog](https://github.com/ejholmes/restforce/tree/master/CHANGELOG.md)
22
+ [Official Website](http://restforce.org/) | [Documentation](http://rubydoc.info/gems/restforce/frames) | [Changelog](https://github.com/restforce/restforce/tree/master/CHANGELOG.md)
23
23
 
24
24
  ## Installation
25
25
 
26
26
  Add this line to your application's Gemfile:
27
27
 
28
- gem 'restforce', '~> 2.5.3'
28
+ gem 'restforce', '~> 3.0.0'
29
29
 
30
30
  And then execute:
31
31
 
@@ -35,9 +35,9 @@ Or install it yourself as:
35
35
 
36
36
  $ gem install restforce
37
37
 
38
- __As of [version 2.5.0](https://github.com/ejholmes/restforce/blob/master/CHANGELOG.md#250-dec-5-2016), this gem is only compatible with Ruby 2.0.0 and later.__ To use Ruby 1.9.3, you'll need to manually specify that you wish to use version 2.4.2, or 1.5.3 for Ruby 1.9.2 support.
38
+ __As of [version 3.0.0](https://github.com/restforce/restforce/blob/master/CHANGELOG.md#300-aug-2-2018), this gem is only compatible with Ruby 2.3.0 and later.__ You'll need to use version 2.5.3 or earlier if you're running on Ruby 2.2, 2.1 or 2.0. For Ruby 1.9.3, you'll need to manually specify that you wish to use version 2.4.2.
39
39
 
40
- 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.
40
+ 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 3.1.0 to 4.0.0 would be allowed to include incompatible API changes). See the [changelog](https://github.com/restforce/restforce/tree/master/CHANGELOG.md) for details on what has changed in each version.
41
41
 
42
42
  ## Usage
43
43
 
@@ -63,7 +63,7 @@ It is also important to note that the client object should not be reused across
63
63
  ```ruby
64
64
  client = Restforce.new(oauth_token: 'access_token',
65
65
  instance_url: 'instance url',
66
- api_version: '38.0')
66
+ api_version: '41.0')
67
67
  ```
68
68
 
69
69
  Although the above will work, you'll probably want to take advantage of the (re)authentication middleware by specifying `refresh_token`, `client_id`, `client_secret`, and `authentication_callback`:
@@ -75,7 +75,7 @@ client = Restforce.new(oauth_token: 'access_token',
75
75
  client_id: 'client_id',
76
76
  client_secret: 'client_secret',
77
77
  authentication_callback: Proc.new { |x| Rails.logger.debug x.to_s },
78
- api_version: '38.0')
78
+ api_version: '41.0')
79
79
  ```
80
80
 
81
81
  The middleware will use the `refresh_token` automatically to acquire a new `access_token` if the existing `access_token` is invalid.
@@ -108,7 +108,7 @@ client = Restforce.new(username: 'foo',
108
108
  security_token: 'security token',
109
109
  client_id: 'client_id',
110
110
  client_secret: 'client_secret',
111
- api_version: '38.0')
111
+ api_version: '41.0')
112
112
  ```
113
113
 
114
114
  You can also set the username, password, security token, client ID, client
@@ -120,7 +120,7 @@ export SALESFORCE_PASSWORD="password"
120
120
  export SALESFORCE_SECURITY_TOKEN="security token"
121
121
  export SALESFORCE_CLIENT_ID="client id"
122
122
  export SALESFORCE_CLIENT_SECRET="client secret"
123
- export SALESFORCE_API_VERSION="38.0"
123
+ export SALESFORCE_API_VERSION="41.0"
124
124
  ```
125
125
 
126
126
  ```ruby
@@ -138,7 +138,7 @@ client = Restforce.new(username: 'foo',
138
138
  client_id: 'client_id',
139
139
  client_secret: 'client_secret',
140
140
  proxy_uri: 'http://proxy.example.com:123',
141
- api_version: '38.0')
141
+ api_version: '41.0')
142
142
  ```
143
143
 
144
144
  You may specify a username and password for the proxy with a URL along the lines of 'http://user:password@proxy.example.com:123'.
@@ -168,19 +168,19 @@ end
168
168
 
169
169
  By default, the gem defaults to using Version 26.0 (Winter '13) of the Salesforce API. This maintains backwards compatibility for existing users.
170
170
 
171
- __We strongly suggest configuring Restforce to use the most recent API version, currently Version 38.0 (Winter '17) to get the best Salesforce API experience__ - for example, some more recently-added API endpoints will not be available without moving to a more recent
171
+ __We strongly suggest configuring Restforce to use the most recent API version, currently Version 41.0 (Winter '18) to get the best Salesforce API experience__ - for example, some more recently-added API endpoints will not be available without moving to a more recent
172
172
  version. If you're trying to use a method that is unavailable with your API version,
173
173
  Restforce will raise an `APIVersionError`.
174
174
 
175
175
  There are three ways to set the API version:
176
176
 
177
- * Passing in an `api_version` option when instantiating `Restforce` (i.e. `Restforce.new(api_version: '38.0')`)
178
- * Setting the `SALESFORCE_API_VERSION` environment variable (i.e. `export SALESFORCE_API_VERSION="38.0"`)
177
+ * Passing in an `api_version` option when instantiating `Restforce` (i.e. `Restforce.new(api_version: '41.0')`)
178
+ * Setting the `SALESFORCE_API_VERSION` environment variable (i.e. `export SALESFORCE_API_VERSION="41.0"`)
179
179
  * Configuring the version globally with `Restforce.configure`:
180
180
 
181
181
  ```ruby
182
182
  Restforce.configure do |config|
183
- config.api_version = '38.0'
183
+ config.api_version = '41.0'
184
184
  # ...
185
185
  end
186
186
  ```
@@ -206,7 +206,7 @@ to include the `sforce-auto-assign` header in all client HTTP requests:
206
206
  ```ruby
207
207
  client = Restforce.new(oauth_token: 'access_token',
208
208
  instance_url: 'instance url',
209
- api_version: '38.0',
209
+ api_version: '41.0',
210
210
  request_headers: { 'sforce-auto-assign' => 'FALSE' })
211
211
 
212
212
  ```
@@ -473,6 +473,12 @@ document = client.query('select Id, Name, Body from Document').first
473
473
  File.open(document.Name, 'wb') { |f| f.write(document.Body) }
474
474
  ```
475
475
 
476
+ **Note:** The example above is only applicable if your SOQL query returns a single Document record. If more than one record is returned,
477
+ the Body field contains an URL to retrieve the BLOB content for the first 2000 records returned. Subsequent records contain the BLOB content
478
+ in the Body field. This is confusing and hard to debug. See notes in [Issue #301](https://github.com/restforce/restforce/issues/301#issuecomment-298972959) explaining this detail.
479
+ **Executive Summary:** Don't retrieve the Body field in a SOQL query; instead, use the BLOB retrieval URL documented
480
+ in [SObject BLOB Retrieve](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_blob_retrieve.htm)
481
+
476
482
  * * *
477
483
 
478
484
  ### Custom Apex REST endpoints
@@ -645,7 +651,7 @@ Callbacks.
645
651
 
646
652
  We welcome all contributions - they help us make Restforce the best gem possible.
647
653
 
648
- See our [CONTRIBUTING.md](https://github.com/ejholmes/restforce/blob/master/CONTRIBUTING.md) file for help with getting set up to work on the project locally.
654
+ See our [CONTRIBUTING.md](https://github.com/restforce/restforce/blob/master/CONTRIBUTING.md) file for help with getting set up to work on the project locally.
649
655
 
650
656
  1. Fork it
651
657
  2. Create your feature branch (`git checkout -b my-new-feature`)
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env rake
1
+ # frozen_string_literal: true
2
+
2
3
  require "bundler/gem_tasks"
3
4
 
4
5
  task default: [:spec]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'faraday_middleware'
3
5
  require 'json'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Restforce
2
4
  class AbstractClient
3
5
  include Restforce::Concerns::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Restforce
2
4
  class Attachment < Restforce::SObject
3
5
  # Public: Returns the body of the attachment.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Restforce
2
4
  Client = Data::Client
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Restforce
2
4
  class Collection
3
5
  include Enumerable
@@ -29,7 +31,7 @@ module Restforce
29
31
  def size
30
32
  @raw_page['totalSize']
31
33
  end
32
- alias_method :length, :size
34
+ alias length size
33
35
 
34
36
  # Return array of the elements on the current page
35
37
  def current_page
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
  require 'restforce/concerns/verbs'
3
5
 
@@ -81,7 +83,7 @@ module Restforce
81
83
  def get_updated(sobject, start_time, end_time)
82
84
  start_time = start_time.utc.iso8601
83
85
  end_time = end_time.utc.iso8601
84
- url = "/sobjects/#{sobject}/updated/?start=#{start_time}&end=#{end_time}"
86
+ url = "sobjects/#{sobject}/updated/?start=#{start_time}&end=#{end_time}"
85
87
  api_get(url).body
86
88
  end
87
89
 
@@ -101,7 +103,7 @@ module Restforce
101
103
  def get_deleted(sobject, start_time, end_time)
102
104
  start_time = start_time.utc.iso8601
103
105
  end_time = end_time.utc.iso8601
104
- url = "/sobjects/#{sobject}/deleted/?start=#{start_time}&end=#{end_time}"
106
+ url = "sobjects/#{sobject}/deleted/?start=#{start_time}&end=#{end_time}"
105
107
  api_get(url).body
106
108
  end
107
109
 
@@ -265,7 +267,7 @@ module Restforce
265
267
  rescue *exceptions
266
268
  false
267
269
  end
268
- alias_method :insert, :create
270
+ alias insert create
269
271
 
270
272
  # Public: Insert a new record.
271
273
  #
@@ -283,7 +285,7 @@ module Restforce
283
285
  def create!(sobject, attrs)
284
286
  api_post("sobjects/#{sobject}", attrs).body['id']
285
287
  end
286
- alias_method :insert!, :create!
288
+ alias insert! create!
287
289
 
288
290
  # Public: Update a record.
289
291
  #
@@ -316,7 +318,7 @@ module Restforce
316
318
  # Returns true if the sobject was successfully updated.
317
319
  # Raises an exception if an error is returned from Salesforce.
318
320
  def update!(sobject, attrs)
319
- id = attrs.fetch(attrs.keys.find { |k, v| k.to_s.downcase == 'id' }, nil)
321
+ id = attrs.fetch(attrs.keys.find { |k, v| k.to_s.casecmp('id').zero? }, nil)
320
322
  raise ArgumentError, 'ID field missing from provided attributes' unless id
321
323
  attrs_without_id = attrs.reject { |k, v| k.to_s.casecmp("id").zero? }
322
324
  api_patch "sobjects/#{sobject}/#{CGI.escape(id)}", attrs_without_id
@@ -363,7 +365,7 @@ module Restforce
363
365
  def upsert!(sobject, field, attrs)
364
366
  attrs = attrs.dup
365
367
  external_id =
366
- extract_case_insensitive_string_or_symbol_key_from_hash!(attrs, field)
368
+ extract_case_insensitive_string_or_symbol_key_from_hash!(attrs, field).to_s
367
369
  if field.to_s != "Id" && (external_id.nil? || external_id.strip.empty?)
368
370
  raise ArgumentError, 'Specified external ID field missing from provided ' \
369
371
  'attributes'
@@ -378,7 +380,7 @@ module Restforce
378
380
  api_patch "sobjects/#{sobject}/#{field}/#{CGI.escape(external_id)}", attrs
379
381
  end
380
382
 
381
- (response.body && response.body['id']) ? response.body['id'] : true
383
+ response&.body&.fetch('id', nil) ? response.body['id'] : true
382
384
  end
383
385
 
384
386
  # Public: Delete a record.
@@ -448,7 +450,8 @@ module Restforce
448
450
  else
449
451
  "sobjects/#{sobject}/#{CGI.escape(id)}"
450
452
  end
451
- path << "?fields=#{select.join(',')}" if select && select.any?
453
+
454
+ path = "#{path}?fields=#{select.join(',')}" if select&.any?
452
455
 
453
456
  api_get(path).body
454
457
  end