databasedotcom 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +8 -8
- data/lib/databasedotcom/client.rb +16 -1
- data/lib/databasedotcom/version.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -17,7 +17,7 @@ Source is available at github[http://github.com/heroku/databasedotcom]
|
|
17
17
|
|
18
18
|
= Usage
|
19
19
|
== Initialization
|
20
|
-
When you create a Databasedotcom::Client object, you need to configure it with a client id and client secret that corresponds to one of the Remote Access Applications configured within your
|
20
|
+
When you create a Databasedotcom::Client object, you need to configure it with a client id and client secret that corresponds to one of the Remote Access Applications configured within your Salesforce instance. The Salesforce UI refers to the client id as "Consumer Key", and to the client secret as "Consumer Secret".
|
21
21
|
|
22
22
|
You can configure your Client object with a client id and client secret in one of several different ways:
|
23
23
|
=== Configuration from the environment
|
@@ -79,25 +79,25 @@ Then, when you create your client like:
|
|
79
79
|
it will use the configuration information that you set with <tt>heroku config:add</tt>.
|
80
80
|
|
81
81
|
== Authentication
|
82
|
-
The first thing you need to do with the new Client is to authenticate with
|
82
|
+
The first thing you need to do with the new Client is to authenticate with Salesforce. You can do this in one of several ways:
|
83
83
|
|
84
84
|
=== Authentication via an externally-acquired OAuth access token
|
85
|
-
If you have acquired an OAuth access token for your
|
85
|
+
If you have acquired an OAuth access token for your Salesforce instance through some external means, you can use it. Note that you have to pass both the token and your Salesforce instance URL to the <tt>authenticate</tt> method:
|
86
86
|
|
87
87
|
client.authenticate :token => "my-oauth-token", :instance_url => "http://na1.salesforce.com" #=> "my-oauth-token"
|
88
88
|
|
89
89
|
=== Authentication via Omniauth
|
90
|
-
If you are using the gem within the context of a web application, and your web app is using Omniauth to do OAuth with
|
90
|
+
If you are using the gem within the context of a web application, and your web app is using Omniauth to do OAuth with Salesforce, you can authentication the Client direction via the Hash that Omniauth passes to your OAuth callback method, like so:
|
91
91
|
|
92
92
|
client.authenticate request.env['omniauth.auth'] #=> "the-oauth-token"
|
93
93
|
|
94
94
|
=== Authentication via username and password
|
95
|
-
You can authenticate your Client directly with
|
95
|
+
You can authenticate your Client directly with Salesforce with a valid username and password for a user in your Salesforce instance. Note that, if access to your Salesforce instance requires a {security token}[http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_concepts_security.htm], the value that you pass for <tt>:password</tt> must be the password for the user concatenated with her security token.
|
96
96
|
|
97
97
|
client.authenticate :username => "foo@bar.com", :password => "ThePasswordTheSecurityToken" #=> "the-oauth-token"
|
98
98
|
|
99
99
|
== Accessing the Sobject API
|
100
|
-
You can retrieve a list of Sobject defined in your
|
100
|
+
You can retrieve a list of Sobject defined in your Salesforce instance like so:
|
101
101
|
|
102
102
|
client.list_sobjects #=> ['User', 'Group', 'Contact']
|
103
103
|
|
@@ -125,7 +125,7 @@ Materialized Sobject classes behave much like ActiveRecord classes:
|
|
125
125
|
"Phone" => "4156543210" #=> change several attributes at once and save them
|
126
126
|
contact.delete #=> delete the contact from the database
|
127
127
|
|
128
|
-
See the documentation for full details.
|
128
|
+
See the documentation[http://rubydoc.info/github/heroku/databasedotcom/master/frames] for full details.
|
129
129
|
|
130
130
|
== Accessing the Chatter API
|
131
131
|
You can easily access Chatter feeds, group, conversations, etc.:
|
@@ -147,7 +147,7 @@ You can easily access Chatter feeds, group, conversations, etc.:
|
|
147
147
|
you = Databasedotcom::Chatter::User.find(client, "your-user-id")
|
148
148
|
me.follow(you) #=> start following a user
|
149
149
|
|
150
|
-
See the documentation for full details.
|
150
|
+
See the documentation[http://rubydoc.info/github/heroku/databasedotcom/master/frames] for full details.
|
151
151
|
|
152
152
|
= License
|
153
153
|
|
@@ -31,6 +31,10 @@ module Databasedotcom
|
|
31
31
|
attr_accessor :password
|
32
32
|
# The SalesForce organization id for the authenticated user's Salesforce instance
|
33
33
|
attr_reader :org_id
|
34
|
+
# The CA file configured for this instance, if any
|
35
|
+
attr_accessor :ca_file
|
36
|
+
# The SSL verify mode configured for this instance, if any
|
37
|
+
attr_accessor :verify_mode
|
34
38
|
|
35
39
|
# Returns a new client object. _options_ can be one of the following
|
36
40
|
#
|
@@ -42,6 +46,8 @@ module Databasedotcom
|
|
42
46
|
# debugging: true
|
43
47
|
# version: 23.0
|
44
48
|
# sobject_module: My::Module
|
49
|
+
# ca_file: some/ca/file.cert
|
50
|
+
# verify_mode:
|
45
51
|
# * A Hash containing the following keys:
|
46
52
|
# client_id
|
47
53
|
# client_secret
|
@@ -55,6 +61,7 @@ module Databasedotcom
|
|
55
61
|
def initialize(options = {})
|
56
62
|
if options.is_a?(String)
|
57
63
|
@options = YAML.load_file(options)
|
64
|
+
@options["verify_mode"] = @options["verify_mode"].constantize if @options["verify_mode"] && @options["verify_mode"].is_a?(String)
|
58
65
|
else
|
59
66
|
@options = options
|
60
67
|
end
|
@@ -73,10 +80,14 @@ module Databasedotcom
|
|
73
80
|
self.client_secret = ENV['DATABASEDOTCOM_CLIENT_SECRET'] || @options[:client_secret]
|
74
81
|
self.host = ENV['DATABASEDOTCOM_HOST'] || @options[:host] || "login.salesforce.com"
|
75
82
|
end
|
83
|
+
|
76
84
|
self.debugging = ENV['DATABASEDOTCOM_DEBUGGING'] || @options[:debugging]
|
77
85
|
self.version = ENV['DATABASEDOTCOM_VERSION'] || @options[:version]
|
78
86
|
self.version = self.version.to_s if self.version
|
79
87
|
self.sobject_module = ENV['DATABASEDOTCOM_SOBJECT_MODULE'] || @options[:sobject_module]
|
88
|
+
self.ca_file = ENV['DATABASEDOTCOM_CA_FILE'] || @options[:ca_file]
|
89
|
+
self.verify_mode = ENV['DATABASEDOTCOM_VERIFY_MODE'] || @options[:verify_mode]
|
90
|
+
self.verify_mode = self.verify_mode.to_i if self.verify_mode
|
80
91
|
end
|
81
92
|
|
82
93
|
# Authenticate to the Force.com API. _options_ is a Hash, interpreted as follows:
|
@@ -366,7 +377,11 @@ module Databasedotcom
|
|
366
377
|
end
|
367
378
|
|
368
379
|
def https_request(host=nil)
|
369
|
-
Net::HTTP.new(host || URI.parse(self.instance_url).host, 443).tap
|
380
|
+
Net::HTTP.new(host || URI.parse(self.instance_url).host, 443).tap do |http|
|
381
|
+
http.use_ssl = true
|
382
|
+
http.ca_file = self.ca_file if self.ca_file
|
383
|
+
http.verify_mode = self.verify_mode if self.verify_mode
|
384
|
+
end
|
370
385
|
end
|
371
386
|
|
372
387
|
def encode_path_with_params(path, parameters={})
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: databasedotcom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.2.
|
5
|
+
version: 1.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Glenn Gillen, Danny Burkes & Richard Zhao
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-24 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multipart-post
|
@@ -40,9 +40,9 @@ dependencies:
|
|
40
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: "
|
45
|
+
version: "2.6"
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id003
|
48
48
|
- !ruby/object:Gem::Dependency
|