restforce 2.1.2 → 2.1.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +31 -10
- data/lib/restforce.rb +1 -0
- data/lib/restforce/middleware/authentication.rb +3 -1
- data/lib/restforce/middleware/raise_error.rb +1 -1
- data/lib/restforce/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6856a7534599d3903698a710a379d2af99866a80
|
4
|
+
data.tar.gz: 1d888bc1f8d088abd95361718b131b2111f7c693
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98686516419562bc5ac3c2ca2748197d642373c5a508fc937921a00cfbec34ab835af2813acce8d95bd0595a8228a3b9fe26374d116f179bc0c9bfc70058f2db
|
7
|
+
data.tar.gz: d67b50a3bc94beed337823ea61abb4e196ce0cd0eaa1c57818ff1e6791cb78737ac4554e28e16e6628d80dfec84c4732bba6e590b08d0ffb9d6f5afecf8cffea
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 2.1.3 (Mar 9, 2016)
|
2
|
+
|
3
|
+
* Raise a `Restforce::ServerError` when Salesforce responds with a `500` due to an internal error (@greysteil)
|
4
|
+
* Improving handling of response body in errors (@kuono)
|
5
|
+
|
6
|
+
## 2.1.2 (Nov 2, 2015)
|
7
|
+
|
8
|
+
* Always parse the JSON response before errors are raised to improve exceptions (@kouno)
|
9
|
+
|
1
10
|
## 2.1.1 (Aug 20, 2015)
|
2
11
|
|
3
12
|
* Added support for `get_updated` call (@web-connect)
|
data/README.md
CHANGED
@@ -61,21 +61,41 @@ It is also important to note that the client object should not be reused across
|
|
61
61
|
#### OAuth token authentication
|
62
62
|
|
63
63
|
```ruby
|
64
|
-
client = Restforce.new :oauth_token => '
|
64
|
+
client = Restforce.new :oauth_token => 'access_token',
|
65
65
|
:instance_url => 'instance url'
|
66
66
|
```
|
67
67
|
|
68
|
-
Although the above will work, you'll probably want to take advantage of the
|
69
|
-
(re)authentication middleware by specifying a `refresh_token`, `client_id` and `client_secret`:
|
68
|
+
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`:
|
70
69
|
|
71
70
|
```ruby
|
72
|
-
client = Restforce.new :oauth_token => '
|
73
|
-
:refresh_token
|
74
|
-
:instance_url
|
75
|
-
:client_id
|
76
|
-
:client_secret
|
71
|
+
client = Restforce.new :oauth_token => 'access_token',
|
72
|
+
:refresh_token => 'refresh token',
|
73
|
+
:instance_url => 'instance url',
|
74
|
+
:client_id => 'client_id',
|
75
|
+
:client_secret => 'client_secret',
|
76
|
+
:authentication_callback => Proc.new {|x| Rails.logger.debug x.to_s}
|
77
77
|
```
|
78
78
|
|
79
|
+
The middleware will use the `refresh_token` automatically to acquire a new `access_token` if the existing `access_token` is invalid.
|
80
|
+
|
81
|
+
`authentication_callback` is a proc that handles the response from Salesforce when the `refresh_token` is used to obtain a new `access_token`. This allows the `access_token` to be saved for re-use later, otherwise subsequent API calls will continue the cycle of "auth failure/issue new access_token/auth success".
|
82
|
+
|
83
|
+
The proc is passed one argument, a `Hashie::Mash` of the response from the [Salesforce API](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_refresh_token_oauth.htm):
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
{
|
87
|
+
"access_token" => "00Dx0000000BV7z!AR8AQP0jITN80ESEsj5EbaZTFG0RNBaT1cyWk7T5rqoDjoNIWQ2ME_sTZzBjfmOE6zMHq6y8PIW4eWze9JksNEkWUl.Cju7m4",
|
88
|
+
"signature" => "SSSbLO/gBhmmyNUvN18ODBDFYHzakxOMgqYtu+hDPsc=",
|
89
|
+
"scope" => "refresh_token full",
|
90
|
+
"instance_url" => "https://na1.salesforce.com",
|
91
|
+
"id" => "https://login.salesforce.com/id/00Dx0000000BV7z/005x00000012Q9P",
|
92
|
+
"token_type" => "Bearer",
|
93
|
+
"issued_at" => "1278448384422"
|
94
|
+
}
|
95
|
+
```
|
96
|
+
|
97
|
+
The `id` field can be used to [uniquely identify](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_refresh_token_oauth.htm) the user that the `access_token` and `refresh_token` belong to.
|
98
|
+
|
79
99
|
#### Username/Password authentication
|
80
100
|
|
81
101
|
If you prefer to use a username and password to authenticate:
|
@@ -116,7 +136,7 @@ client = Restforce.new :username => 'foo',
|
|
116
136
|
:proxy_uri => 'http://proxy.example.com:123'
|
117
137
|
```
|
118
138
|
|
119
|
-
You may specify a username and password for the proxy with a URL along the lines of 'http://user@
|
139
|
+
You may specify a username and password for the proxy with a URL along the lines of 'http://user:password@proxy.example.com:123'.
|
120
140
|
|
121
141
|
#### Sandbox Orgs
|
122
142
|
|
@@ -199,6 +219,7 @@ account.destroy
|
|
199
219
|
```ruby
|
200
220
|
accounts = client.query_all("select Id, Something__c from Account where isDeleted = true")
|
201
221
|
# => #<Restforce::Collection >
|
222
|
+
```
|
202
223
|
|
203
224
|
query_all allows you to include results from your query that Salesforce hides in the default "query" method. These include soft-deleted records and archived records (e.g. Task and Event records which are usually archived automatically after they are a year old).
|
204
225
|
|
@@ -353,7 +374,7 @@ Retrieves the list of individual record IDs that have been updated (added or cha
|
|
353
374
|
|
354
375
|
```ruby
|
355
376
|
# Get the ids of all accounts which have been updated in the last day
|
356
|
-
client.get_updated('Account', Time.local(2015,8,18) Time.local(2015,8,19))
|
377
|
+
client.get_updated('Account', Time.local(2015,8,18), Time.local(2015,8,19))
|
357
378
|
# => { ... }
|
358
379
|
```
|
359
380
|
|
data/lib/restforce.rb
CHANGED
@@ -22,7 +22,9 @@ module Restforce
|
|
22
22
|
req.body = encode_www_form(params)
|
23
23
|
end
|
24
24
|
|
25
|
-
if response.status
|
25
|
+
if response.status >= 500
|
26
|
+
raise Restforce::ServerError, error_message(response)
|
27
|
+
elsif response.status != 200
|
26
28
|
raise Restforce::AuthenticationError, error_message(response)
|
27
29
|
end
|
28
30
|
|
data/lib/restforce/version.rb
CHANGED
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.1.
|
4
|
+
version: 2.1.3
|
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:
|
12
|
+
date: 2016-03-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|