sfdc 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/sfdc.rb +46 -16
- data/lib/sfdc/abstract_client.rb +9 -0
- data/lib/sfdc/client.rb +1 -96
- data/lib/sfdc/{client → concerns}/api.rb +15 -26
- data/lib/sfdc/{client → concerns}/authentication.rb +9 -9
- data/lib/sfdc/concerns/base.rb +58 -0
- data/lib/sfdc/{client → concerns}/caching.rb +4 -4
- data/lib/sfdc/concerns/canvas.rb +12 -0
- data/lib/sfdc/{client → concerns}/connection.rb +12 -12
- data/lib/sfdc/{client → concerns}/picklists.rb +1 -1
- data/lib/sfdc/{client → concerns}/streaming.rb +3 -3
- data/lib/sfdc/{client → concerns}/verbs.rb +3 -3
- data/lib/sfdc/config.rb +1 -1
- data/lib/sfdc/data/client.rb +18 -0
- data/lib/sfdc/mash.rb +1 -1
- data/lib/sfdc/middleware/authentication.rb +1 -1
- data/lib/sfdc/middleware/authentication/password.rb +1 -1
- data/lib/sfdc/middleware/authentication/token.rb +1 -1
- data/lib/sfdc/middleware/authorization.rb +1 -1
- data/lib/sfdc/middleware/instance_url.rb +1 -1
- data/lib/sfdc/middleware/mashify.rb +1 -1
- data/lib/sfdc/signed_request.rb +1 -1
- data/lib/sfdc/sobject.rb +1 -1
- data/lib/sfdc/tooling/client.rb +13 -0
- data/lib/sfdc/version.rb +1 -1
- metadata +14 -10
- data/lib/sfdc/client/canvas.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b069e7a4c283823fd8d6c1cb4d91655843aeb825
|
4
|
+
data.tar.gz: 5f4ee6acdefbea239435a03d000e3ff2f5fbfdb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b8ce424aa1aee8e13e61a8b3d79c90f0db1adde39258ff722492d49bc65afcb884352ec617b95db3245399ad238605d1145aed17f6dda7e5b1ec66379ced844
|
7
|
+
data.tar.gz: 476893d58baba2e78b4bbfb2ab111ae92fd756cef72115c712dbcdc29baed9844e5156261030085e1a65cbc322601b4ef5d69b004c668dabcfe7fe6c679d874b
|
data/README.md
CHANGED
@@ -422,6 +422,16 @@ end
|
|
422
422
|
|
423
423
|
You can use Sfdc to decode signed requests from Salesforce. See [the example app](https://gist.github.com/4052312).
|
424
424
|
|
425
|
+
## Tooling API
|
426
|
+
|
427
|
+
To use the [Tooling API](http://www.salesforce.com/us/developer/docs/api_toolingpre/api_tooling.pdf),
|
428
|
+
call `Sfdc.tooling` instead of `Sfdc.new`:
|
429
|
+
|
430
|
+
```ruby
|
431
|
+
client = Sfdc.tooling(...)
|
432
|
+
```
|
433
|
+
|
434
|
+
|
425
435
|
## Contributing
|
426
436
|
|
427
437
|
1. Fork it
|
data/lib/sfdc.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "sfdc/version"
|
2
|
-
|
3
1
|
require 'faraday'
|
4
2
|
require 'faraday_middleware'
|
5
3
|
require 'json'
|
@@ -8,22 +6,54 @@ require 'sfdc/version'
|
|
8
6
|
require 'sfdc/config'
|
9
7
|
|
10
8
|
module Sfdc
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
18
|
-
autoload :
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
autoload :AbstractClient, 'sfdc/abstract_client'
|
10
|
+
autoload :SignedRequest, 'sfdc/signed_request'
|
11
|
+
autoload :Collection, 'sfdc/collection'
|
12
|
+
autoload :Middleware, 'sfdc/middleware'
|
13
|
+
autoload :Attachment, 'sfdc/attachment'
|
14
|
+
autoload :UploadIO, 'sfdc/upload_io'
|
15
|
+
autoload :SObject, 'sfdc/sobject'
|
16
|
+
autoload :Client, 'sfdc/client'
|
17
|
+
autoload :Mash, 'sfdc/mash'
|
18
|
+
|
19
|
+
module Concerns
|
20
|
+
autoload :Authentication, 'sfdc/concerns/authentication'
|
21
|
+
autoload :Connection, 'sfdc/concerns/connection'
|
22
|
+
autoload :Picklists, 'sfdc/concerns/picklists'
|
23
|
+
autoload :Streaming, 'sfdc/concerns/streaming'
|
24
|
+
autoload :Caching, 'sfdc/concerns/caching'
|
25
|
+
autoload :Canvas, 'sfdc/concerns/canvas'
|
26
|
+
autoload :Verbs, 'sfdc/concerns/verbs'
|
27
|
+
autoload :Base, 'sfdc/concerns/base'
|
28
|
+
autoload :API, 'sfdc/concerns/api'
|
29
|
+
end
|
30
|
+
|
31
|
+
module Data
|
32
|
+
autoload :Client, 'sfdc/data/client'
|
33
|
+
end
|
34
|
+
|
35
|
+
module Tooling
|
36
|
+
autoload :Client, 'sfdc/tooling/client'
|
37
|
+
end
|
38
|
+
|
39
|
+
Error = Class.new(StandardError)
|
40
|
+
AuthenticationError = Class.new(Error)
|
41
|
+
UnauthorizedError = Class.new(Error)
|
22
42
|
|
23
43
|
class << self
|
24
|
-
# Alias for Sfdc::Client.new
|
25
|
-
|
26
|
-
|
44
|
+
# Alias for Sfdc::Data::Client.new
|
45
|
+
#
|
46
|
+
# Shamelessly pulled from https://github.com/pengwynn/octokit/blob/master/lib/octokit.rb
|
47
|
+
def new(*args)
|
48
|
+
data(*args)
|
49
|
+
end
|
50
|
+
|
51
|
+
def data(*args)
|
52
|
+
Sfdc::Data::Client.new(*args)
|
53
|
+
end
|
54
|
+
|
55
|
+
def tooling(*args)
|
56
|
+
Sfdc::Tooling::Client.new(*args)
|
27
57
|
end
|
28
58
|
|
29
59
|
# Helper for decoding signed requests.
|
data/lib/sfdc/client.rb
CHANGED
@@ -1,98 +1,3 @@
|
|
1
|
-
require 'sfdc/client/connection'
|
2
|
-
require 'sfdc/client/authentication'
|
3
|
-
require 'sfdc/client/streaming'
|
4
|
-
require 'sfdc/client/picklists'
|
5
|
-
require 'sfdc/client/caching'
|
6
|
-
require 'sfdc/client/canvas'
|
7
|
-
require 'sfdc/client/api'
|
8
|
-
|
9
1
|
module Sfdc
|
10
|
-
|
11
|
-
include Sfdc::Client::Connection
|
12
|
-
include Sfdc::Client::Authentication
|
13
|
-
include Sfdc::Client::Streaming
|
14
|
-
include Sfdc::Client::Picklists
|
15
|
-
include Sfdc::Client::Caching
|
16
|
-
include Sfdc::Client::Canvas
|
17
|
-
include Sfdc::Client::API
|
18
|
-
|
19
|
-
# Public: Creates a new client instance
|
20
|
-
#
|
21
|
-
# opts - A hash of options to be passed in (default: {}).
|
22
|
-
# :username - The String username to use (required for password authentication).
|
23
|
-
# :password - The String password to use (required for password authentication).
|
24
|
-
# :security_token - The String security token to use (required for password authentication).
|
25
|
-
#
|
26
|
-
# :oauth_token - The String oauth access token to authenticate api
|
27
|
-
# calls (required unless password
|
28
|
-
# authentication is used).
|
29
|
-
# :refresh_token - The String refresh token to obtain fresh
|
30
|
-
# oauth access tokens (required if oauth
|
31
|
-
# authentication is used).
|
32
|
-
# :instance_url - The String base url for all api requests
|
33
|
-
# (required if oauth authentication is used).
|
34
|
-
#
|
35
|
-
# :client_id - The oauth client id to use. Needed for both
|
36
|
-
# password and oauth authentication
|
37
|
-
# :client_secret - The oauth client secret to use.
|
38
|
-
#
|
39
|
-
# :host - The String hostname to use during
|
40
|
-
# authentication requests (default: 'login.salesforce.com').
|
41
|
-
#
|
42
|
-
# :api_version - The String REST api version to use (default: '24.0')
|
43
|
-
#
|
44
|
-
# :authentication_retries - The number of times that client
|
45
|
-
# should attempt to reauthenticate
|
46
|
-
# before raising an exception (default: 3).
|
47
|
-
#
|
48
|
-
# :compress - Set to true to have Salesforce compress the response (default: false).
|
49
|
-
# :timeout - Faraday connection request read/open timeout. (default: nil).
|
50
|
-
#
|
51
|
-
# :proxy_uri - Proxy URI: 'http://proxy.example.com:port' or 'http://user@pass:proxy.example.com:port'
|
52
|
-
#
|
53
|
-
# Examples
|
54
|
-
#
|
55
|
-
# # Initialize a new client using password authentication:
|
56
|
-
# Sfdc::Client.new :username => 'user',
|
57
|
-
# :password => 'pass',
|
58
|
-
# :security_token => 'security token',
|
59
|
-
# :client_id => 'client id',
|
60
|
-
# :client_secret => 'client secret'
|
61
|
-
#
|
62
|
-
# # Initialize a new client using oauth authentication:
|
63
|
-
# Sfdc::Client.new :oauth_token => 'access token',
|
64
|
-
# :refresh_token => 'refresh token',
|
65
|
-
# :instance_url => 'https://na1.salesforce.com',
|
66
|
-
# :client_id => 'client id',
|
67
|
-
# :client_secret => 'client secret'
|
68
|
-
#
|
69
|
-
# # Initialize a new client without using any authentication middleware:
|
70
|
-
# Sfdc::Client.new :oauth_token => 'access token',
|
71
|
-
# :instance_url => 'https://na1.salesforce.com'
|
72
|
-
#
|
73
|
-
def initialize(opts = {})
|
74
|
-
raise 'Please specify a hash of options' unless opts.is_a?(Hash)
|
75
|
-
@options = Hash[Sfdc.configuration.options.map { |option| [option, Sfdc.configuration.send(option)] }]
|
76
|
-
@options.merge! opts
|
77
|
-
yield builder if block_given?
|
78
|
-
end
|
79
|
-
|
80
|
-
def instance_url
|
81
|
-
authenticate! unless @options[:instance_url]
|
82
|
-
@options[:instance_url]
|
83
|
-
end
|
84
|
-
|
85
|
-
# Public: Returns a url to the resource.
|
86
|
-
#
|
87
|
-
# resource - A record that responds to to_sparam or a String/Fixnum.
|
88
|
-
#
|
89
|
-
# Returns the url to the resource.
|
90
|
-
def url(resource)
|
91
|
-
"#{instance_url}/#{(resource.respond_to?(:to_sparam) ? resource.to_sparam : resource)}"
|
92
|
-
end
|
93
|
-
|
94
|
-
def inspect
|
95
|
-
"#<#{self.class} @options=#{@options.inspect}>"
|
96
|
-
end
|
97
|
-
end
|
2
|
+
Client = Data::Client
|
98
3
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'sfdc/
|
1
|
+
require 'sfdc/concerns/verbs'
|
2
2
|
|
3
3
|
module Sfdc
|
4
|
-
|
4
|
+
module Concerns
|
5
5
|
module API
|
6
|
-
extend Sfdc::
|
6
|
+
extend Sfdc::Concerns::Verbs
|
7
7
|
|
8
8
|
# Public: Helper methods for performing arbitrary actions against the API using
|
9
9
|
# various HTTP verbs.
|
@@ -77,15 +77,6 @@ module Sfdc
|
|
77
77
|
query('select id from Organization').first['Id']
|
78
78
|
end
|
79
79
|
|
80
|
-
# Public: Get the current user's Id.
|
81
|
-
# client.user_id
|
82
|
-
def user_id
|
83
|
-
response = authenticate!
|
84
|
-
info = get(response.id).body
|
85
|
-
user_id = info.user_id
|
86
|
-
return user_id
|
87
|
-
end
|
88
|
-
|
89
80
|
# Public: Executs a SOQL query and returns the result.
|
90
81
|
#
|
91
82
|
# soql - A SOQL expression.
|
@@ -103,16 +94,6 @@ module Sfdc
|
|
103
94
|
mashify? ? response.body : response.body['records']
|
104
95
|
end
|
105
96
|
|
106
|
-
# Returns SFDC recent items Id.
|
107
|
-
# Returns Sfdc::SObject
|
108
|
-
# client.recent.each do |r|
|
109
|
-
# puts r.Name + ' ' + r.Id
|
110
|
-
# end
|
111
|
-
def recent
|
112
|
-
response = api_get 'recent'
|
113
|
-
mashify? ? response.body : response.body['records']
|
114
|
-
end
|
115
|
-
|
116
97
|
# Public: Perform a SOSL search
|
117
98
|
#
|
118
99
|
# sosl - A SOSL expression.
|
@@ -203,7 +184,7 @@ module Sfdc
|
|
203
184
|
# Raises an exception if an error is returned from Salesforce.
|
204
185
|
def update!(sobject, attrs)
|
205
186
|
id = attrs.delete(attrs.keys.find { |k| k.to_s.downcase == 'id' })
|
206
|
-
raise 'Id field missing.' unless id
|
187
|
+
raise ArgumentError, 'Id field missing from attrs.' unless id
|
207
188
|
api_patch "sobjects/#{sobject}/#{id}", attrs
|
208
189
|
true
|
209
190
|
end
|
@@ -294,8 +275,16 @@ module Sfdc
|
|
294
275
|
def find(sobject, id, field=nil)
|
295
276
|
api_get(field ? "sobjects/#{sobject}/#{field}/#{id}" : "sobjects/#{sobject}/#{id}").body
|
296
277
|
end
|
297
|
-
|
298
|
-
|
278
|
+
|
279
|
+
# Public: Get the current user's Id.
|
280
|
+
# client.user_id
|
281
|
+
def user_id
|
282
|
+
response = authenticate!
|
283
|
+
info = get(response.id).body
|
284
|
+
user_id = info.user_id
|
285
|
+
return user_id
|
286
|
+
end
|
287
|
+
|
299
288
|
#################### Chatter items ############################
|
300
289
|
# @client.feeds.each do |f|
|
301
290
|
# puts f.to_hash['id']
|
@@ -316,7 +305,7 @@ module Sfdc
|
|
316
305
|
# api_path('sobjects')
|
317
306
|
# # => '/services/data/v24.0/sobjects'
|
318
307
|
def api_path(path)
|
319
|
-
"/services/data/v#{
|
308
|
+
"/services/data/v#{options[:api_version]}/#{path}"
|
320
309
|
end
|
321
310
|
|
322
311
|
# Internal: Errors that should be rescued from in non-bang methods
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Sfdc
|
2
|
-
|
2
|
+
module Concerns
|
3
3
|
module Authentication
|
4
4
|
|
5
5
|
# Public: Force an authentication
|
6
6
|
def authenticate!
|
7
7
|
raise AuthenticationError, 'No authentication middleware present' unless authentication_middleware
|
8
|
-
middleware = authentication_middleware.new nil, self,
|
8
|
+
middleware = authentication_middleware.new nil, self, options
|
9
9
|
middleware.authenticate!
|
10
10
|
end
|
11
11
|
|
@@ -21,18 +21,18 @@ module Sfdc
|
|
21
21
|
# Internal: Returns true if username/password (autonomous) flow should be used for
|
22
22
|
# authentication.
|
23
23
|
def username_password?
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
options[:username] &&
|
25
|
+
options[:password] &&
|
26
|
+
options[:client_id] &&
|
27
|
+
options[:client_secret]
|
28
28
|
end
|
29
29
|
|
30
30
|
# Internal: Returns true if oauth token refresh flow should be used for
|
31
31
|
# authentication.
|
32
32
|
def oauth_refresh?
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
options[:refresh_token] &&
|
34
|
+
options[:client_id] &&
|
35
|
+
options[:client_secret]
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Sfdc
|
2
|
+
module Concerns
|
3
|
+
module Base
|
4
|
+
|
5
|
+
attr_reader :options
|
6
|
+
|
7
|
+
# Public: Creates a new client instance
|
8
|
+
#
|
9
|
+
# opts - A hash of options to be passed in (default: {}).
|
10
|
+
# :username - The String username to use (required for password authentication).
|
11
|
+
# :password - The String password to use (required for password authentication).
|
12
|
+
# :security_token - The String security token to use (required for password authentication).
|
13
|
+
#
|
14
|
+
# :oauth_token - The String oauth access token to authenticate api
|
15
|
+
# calls (required unless password
|
16
|
+
# authentication is used).
|
17
|
+
# :refresh_token - The String refresh token to obtain fresh
|
18
|
+
# oauth access tokens (required if oauth
|
19
|
+
# authentication is used).
|
20
|
+
# :instance_url - The String base url for all api requests
|
21
|
+
# (required if oauth authentication is used).
|
22
|
+
#
|
23
|
+
# :client_id - The oauth client id to use. Needed for both
|
24
|
+
# password and oauth authentication
|
25
|
+
# :client_secret - The oauth client secret to use.
|
26
|
+
#
|
27
|
+
# :host - The String hostname to use during
|
28
|
+
# authentication requests (default: 'login.salesforce.com').
|
29
|
+
#
|
30
|
+
# :api_version - The String REST api version to use (default: '24.0')
|
31
|
+
#
|
32
|
+
# :authentication_retries - The number of times that client
|
33
|
+
# should attempt to reauthenticate
|
34
|
+
# before raising an exception (default: 3).
|
35
|
+
#
|
36
|
+
# :compress - Set to true to have Salesforce compress the response (default: false).
|
37
|
+
# :timeout - Faraday connection request read/open timeout. (default: nil).
|
38
|
+
#
|
39
|
+
# :proxy_uri - Proxy URI: 'http://proxy.example.com:port' or 'http://user@pass:proxy.example.com:port'
|
40
|
+
def initialize(opts = {})
|
41
|
+
raise ArgumentError, 'Please specify a hash of options' unless opts.is_a?(Hash)
|
42
|
+
@options = Hash[Sfdc.configuration.options.map { |option| [option, Sfdc.configuration.send(option)] }]
|
43
|
+
@options.merge! opts
|
44
|
+
yield builder if block_given?
|
45
|
+
end
|
46
|
+
|
47
|
+
def instance_url
|
48
|
+
authenticate! unless options[:instance_url]
|
49
|
+
options[:instance_url]
|
50
|
+
end
|
51
|
+
|
52
|
+
def inspect
|
53
|
+
"#<#{self.class} @options=#{@options.inspect}>"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Sfdc
|
2
|
-
|
2
|
+
module Concerns
|
3
3
|
module Caching
|
4
4
|
|
5
5
|
# Public: Runs the block with caching disabled.
|
@@ -8,17 +8,17 @@ module Sfdc
|
|
8
8
|
#
|
9
9
|
# Returns the result of the block
|
10
10
|
def without_caching(&block)
|
11
|
-
|
11
|
+
options[:use_cache] = false
|
12
12
|
block.call
|
13
13
|
ensure
|
14
|
-
|
14
|
+
options.delete(:use_cache)
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
19
|
# Internal: Cache to use for the caching middleware
|
20
20
|
def cache
|
21
|
-
|
21
|
+
options[:cache]
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Sfdc
|
2
|
-
|
2
|
+
module Concerns
|
3
3
|
module Connection
|
4
4
|
|
5
5
|
# Public: The Faraday::Builder instance used for the middleware stack. This
|
@@ -20,31 +20,31 @@ module Sfdc
|
|
20
20
|
|
21
21
|
# Internal: Internal faraday connection where all requests go through
|
22
22
|
def connection
|
23
|
-
@connection ||= Faraday.new(
|
23
|
+
@connection ||= Faraday.new(options[:instance_url], connection_options) do |builder|
|
24
24
|
# Parses JSON into Hashie::Mash structures.
|
25
|
-
builder.use Sfdc::Middleware::Mashify, self,
|
25
|
+
builder.use Sfdc::Middleware::Mashify, self, options
|
26
26
|
# Handles multipart file uploads for blobs.
|
27
27
|
builder.use Sfdc::Middleware::Multipart
|
28
28
|
# Converts the request into JSON.
|
29
29
|
builder.request :json
|
30
30
|
# Handles reauthentication for 403 responses.
|
31
|
-
builder.use authentication_middleware, self,
|
31
|
+
builder.use authentication_middleware, self, options if authentication_middleware
|
32
32
|
# Sets the oauth token in the headers.
|
33
|
-
builder.use Sfdc::Middleware::Authorization, self,
|
33
|
+
builder.use Sfdc::Middleware::Authorization, self, options
|
34
34
|
# Ensures the instance url is set.
|
35
|
-
builder.use Sfdc::Middleware::InstanceURL, self,
|
35
|
+
builder.use Sfdc::Middleware::InstanceURL, self, options
|
36
36
|
# Parses returned JSON response into a hash.
|
37
37
|
builder.response :json, :content_type => /\bjson$/
|
38
38
|
# Caches GET requests.
|
39
|
-
builder.use Sfdc::Middleware::Caching, cache,
|
39
|
+
builder.use Sfdc::Middleware::Caching, cache, options if cache
|
40
40
|
# Follows 30x redirects.
|
41
41
|
builder.use FaradayMiddleware::FollowRedirects
|
42
42
|
# Raises errors for 40x responses.
|
43
43
|
builder.use Sfdc::Middleware::RaiseError
|
44
44
|
# Log request/responses
|
45
|
-
builder.use Sfdc::Middleware::Logger, Sfdc.configuration.logger,
|
45
|
+
builder.use Sfdc::Middleware::Logger, Sfdc.configuration.logger, options if Sfdc.log?
|
46
46
|
# Compress/Decompress the request/response
|
47
|
-
builder.use Sfdc::Middleware::Gzip, self,
|
47
|
+
builder.use Sfdc::Middleware::Gzip, self, options
|
48
48
|
|
49
49
|
builder.adapter adapter
|
50
50
|
end
|
@@ -57,9 +57,9 @@ module Sfdc
|
|
57
57
|
# Internal: Faraday Connection options
|
58
58
|
def connection_options
|
59
59
|
{ :request => {
|
60
|
-
:timeout =>
|
61
|
-
:open_timeout =>
|
62
|
-
:proxy =>
|
60
|
+
:timeout => options[:timeout],
|
61
|
+
:open_timeout => options[:timeout] },
|
62
|
+
:proxy => options[:proxy_uri]
|
63
63
|
}
|
64
64
|
end
|
65
65
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Sfdc
|
2
|
-
|
2
|
+
module Concerns
|
3
3
|
module Streaming
|
4
4
|
|
5
5
|
# Public: Subscribe to a PushTopic
|
@@ -14,8 +14,8 @@ module Sfdc
|
|
14
14
|
|
15
15
|
# Public: Faye client to use for subscribing to PushTopics
|
16
16
|
def faye
|
17
|
-
raise 'Instance URL missing. Call .authenticate! first.' unless
|
18
|
-
@faye ||= Faye::Client.new("#{
|
17
|
+
raise 'Instance URL missing. Call .authenticate! first.' unless options[:instance_url]
|
18
|
+
@faye ||= Faye::Client.new("#{options[:instance_url]}/cometd/#{options[:api_version]}").tap do |client|
|
19
19
|
client.bind 'transport:down' do
|
20
20
|
Sfdc.log "[COMETD DOWN]"
|
21
21
|
client.set_header 'Authorization', "OAuth #{authenticate!.access_token}"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Sfdc
|
2
|
-
|
2
|
+
module Concerns
|
3
3
|
module Verbs
|
4
4
|
|
5
5
|
# Internal: Define methods to handle a verb.
|
@@ -31,13 +31,13 @@ module Sfdc
|
|
31
31
|
# Returns nil.
|
32
32
|
def define_verb(verb)
|
33
33
|
define_method verb do |*args, &block|
|
34
|
-
retries =
|
34
|
+
retries = options[:authentication_retries]
|
35
35
|
begin
|
36
36
|
connection.send(verb, *args, &block)
|
37
37
|
rescue Sfdc::UnauthorizedError
|
38
38
|
if retries > 0
|
39
39
|
retries -= 1
|
40
|
-
connection.url_prefix =
|
40
|
+
connection.url_prefix = options[:instance_url]
|
41
41
|
retry
|
42
42
|
end
|
43
43
|
raise
|
data/lib/sfdc/config.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Sfdc
|
2
|
+
module Data
|
3
|
+
class Client < AbstractClient
|
4
|
+
include Sfdc::Concerns::Streaming
|
5
|
+
include Sfdc::Concerns::Picklists
|
6
|
+
include Sfdc::Concerns::Canvas
|
7
|
+
|
8
|
+
# Public: Returns a url to the resource.
|
9
|
+
#
|
10
|
+
# resource - A record that responds to to_sparam or a String/Fixnum.
|
11
|
+
#
|
12
|
+
# Returns the url to the resource.
|
13
|
+
def url(resource)
|
14
|
+
"#{instance_url}/#{(resource.respond_to?(:to_sparam) ? resource.to_sparam : resource)}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/sfdc/mash.rb
CHANGED
data/lib/sfdc/signed_request.rb
CHANGED
data/lib/sfdc/sobject.rb
CHANGED
data/lib/sfdc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfdc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruce Yue
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir:
|
10
10
|
- bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -116,18 +116,21 @@ executables: []
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- lib/sfdc/abstract_client.rb
|
119
120
|
- lib/sfdc/attachment.rb
|
120
|
-
- lib/sfdc/client/api.rb
|
121
|
-
- lib/sfdc/client/authentication.rb
|
122
|
-
- lib/sfdc/client/caching.rb
|
123
|
-
- lib/sfdc/client/canvas.rb
|
124
|
-
- lib/sfdc/client/connection.rb
|
125
|
-
- lib/sfdc/client/picklists.rb
|
126
|
-
- lib/sfdc/client/streaming.rb
|
127
|
-
- lib/sfdc/client/verbs.rb
|
128
121
|
- lib/sfdc/client.rb
|
129
122
|
- lib/sfdc/collection.rb
|
123
|
+
- lib/sfdc/concerns/api.rb
|
124
|
+
- lib/sfdc/concerns/authentication.rb
|
125
|
+
- lib/sfdc/concerns/base.rb
|
126
|
+
- lib/sfdc/concerns/caching.rb
|
127
|
+
- lib/sfdc/concerns/canvas.rb
|
128
|
+
- lib/sfdc/concerns/connection.rb
|
129
|
+
- lib/sfdc/concerns/picklists.rb
|
130
|
+
- lib/sfdc/concerns/streaming.rb
|
131
|
+
- lib/sfdc/concerns/verbs.rb
|
130
132
|
- lib/sfdc/config.rb
|
133
|
+
- lib/sfdc/data/client.rb
|
131
134
|
- lib/sfdc/mash.rb
|
132
135
|
- lib/sfdc/middleware/authentication/password.rb
|
133
136
|
- lib/sfdc/middleware/authentication/token.rb
|
@@ -143,6 +146,7 @@ files:
|
|
143
146
|
- lib/sfdc/middleware.rb
|
144
147
|
- lib/sfdc/signed_request.rb
|
145
148
|
- lib/sfdc/sobject.rb
|
149
|
+
- lib/sfdc/tooling/client.rb
|
146
150
|
- lib/sfdc/upload_io.rb
|
147
151
|
- lib/sfdc/version.rb
|
148
152
|
- lib/sfdc.rb
|
data/lib/sfdc/client/canvas.rb
DELETED