databasedotcom 1.3.0 → 1.3.1
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.
- data/README.rdoc +5 -0
- data/lib/databasedotcom/client.rb +13 -8
- data/lib/databasedotcom/sobject/sobject.rb +9 -2
- data/lib/databasedotcom/version.rb +1 -1
- metadata +59 -96
data/README.rdoc
CHANGED
@@ -85,6 +85,11 @@ Then, when you create your client like:
|
|
85
85
|
|
86
86
|
it will use the configuration information that you set with <tt>heroku config:add</tt>.
|
87
87
|
|
88
|
+
=== Connect to a SalesForce sandbox account
|
89
|
+
Specify the <tt>:host</tt> option when creating your Client, e.g,
|
90
|
+
|
91
|
+
Databasedotcom::Client.new :host => "test.salesforce.com", ...
|
92
|
+
|
88
93
|
== Authentication
|
89
94
|
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:
|
90
95
|
|
@@ -59,7 +59,7 @@ module Databasedotcom
|
|
59
59
|
# ca_file
|
60
60
|
# verify_mode
|
61
61
|
# If the environment variables DATABASEDOTCOM_CLIENT_ID, DATABASEDOTCOM_CLIENT_SECRET, DATABASEDOTCOM_HOST,
|
62
|
-
# DATABASEDOTCOM_DEBUGGING, DATABASEDOTCOM_VERSION, DATABASEDOTCOM_SOBJECT_MODULE, DATABASEDOTCOM_CA_FILE, and/or
|
62
|
+
# DATABASEDOTCOM_DEBUGGING, DATABASEDOTCOM_VERSION, DATABASEDOTCOM_SOBJECT_MODULE, DATABASEDOTCOM_CA_FILE, and/or
|
63
63
|
# DATABASEDOTCOM_VERIFY_MODE are present, they override any other values provided
|
64
64
|
def initialize(options = {})
|
65
65
|
if options.is_a?(String)
|
@@ -83,7 +83,7 @@ module Databasedotcom
|
|
83
83
|
self.client_secret = ENV['DATABASEDOTCOM_CLIENT_SECRET'] || @options[:client_secret]
|
84
84
|
self.host = ENV['DATABASEDOTCOM_HOST'] || @options[:host] || "login.salesforce.com"
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
self.debugging = ENV['DATABASEDOTCOM_DEBUGGING'] || @options[:debugging]
|
88
88
|
self.version = ENV['DATABASEDOTCOM_VERSION'] || @options[:version]
|
89
89
|
self.version = self.version.to_s if self.version
|
@@ -91,7 +91,7 @@ module Databasedotcom
|
|
91
91
|
self.ca_file = ENV['DATABASEDOTCOM_CA_FILE'] || @options[:ca_file]
|
92
92
|
self.verify_mode = ENV['DATABASEDOTCOM_VERIFY_MODE'] || @options[:verify_mode]
|
93
93
|
self.verify_mode = self.verify_mode.to_i if self.verify_mode
|
94
|
-
|
94
|
+
end
|
95
95
|
|
96
96
|
# Authenticate to the Force.com API. _options_ is a Hash, interpreted as follows:
|
97
97
|
#
|
@@ -105,7 +105,7 @@ module Databasedotcom
|
|
105
105
|
req = https_request(self.host)
|
106
106
|
user = self.username || options[:username]
|
107
107
|
pass = self.password || options[:password]
|
108
|
-
path =
|
108
|
+
path = encode_path_with_params('/services/oauth2/token', :grant_type => 'password', :client_id => self.client_id, :client_secret => self.client_secret, :username => user, :password => pass)
|
109
109
|
log_request("https://#{self.host}/#{path}")
|
110
110
|
result = req.post(path, "")
|
111
111
|
log_response(result)
|
@@ -380,8 +380,8 @@ module Databasedotcom
|
|
380
380
|
end
|
381
381
|
|
382
382
|
def https_request(host=nil)
|
383
|
-
Net::HTTP.new(host || URI.parse(self.instance_url).host, 443).tap do |http|
|
384
|
-
http.use_ssl = true
|
383
|
+
Net::HTTP.new(host || URI.parse(self.instance_url).host, 443).tap do |http|
|
384
|
+
http.use_ssl = true
|
385
385
|
http.ca_file = self.ca_file if self.ca_file
|
386
386
|
http.verify_mode = self.verify_mode if self.verify_mode
|
387
387
|
end
|
@@ -494,11 +494,16 @@ module Databasedotcom
|
|
494
494
|
if attrs.is_a?(Hash)
|
495
495
|
coerced_attrs = {}
|
496
496
|
attrs.keys.each do |key|
|
497
|
-
case clazz.field_type(key)
|
497
|
+
case clazz.field_type(key.to_s)
|
498
498
|
when "multipicklist"
|
499
499
|
coerced_attrs[key] = (attrs[key] || []).join(';')
|
500
500
|
when "datetime"
|
501
|
-
|
501
|
+
begin
|
502
|
+
attrs[key] = DateTime.parse(attrs[key]) if attrs[key].is_a?(String)
|
503
|
+
coerced_attrs[key] = attrs[key].strftime(RUBY_VERSION.match(/^1.8/) ? "%Y-%m-%dT%H:%M:%S.000%z" : "%Y-%m-%dT%H:%M:%S.%L%z")
|
504
|
+
rescue
|
505
|
+
nil
|
506
|
+
end
|
502
507
|
when "date"
|
503
508
|
if attrs[key]
|
504
509
|
coerced_attrs[key] = attrs[key].respond_to?(:strftime) ? attrs[key].strftime("%Y-%m-%d") : attrs[key]
|
@@ -14,7 +14,13 @@ module Databasedotcom
|
|
14
14
|
def initialize(attrs = {})
|
15
15
|
super()
|
16
16
|
self.class.description["fields"].each do |field|
|
17
|
-
|
17
|
+
if field['type'] =~ /(picklist|multipicklist)/ && picklist_option = field['picklistValues'].find { |p| p['defaultValue'] }
|
18
|
+
self.send("#{field["name"]}=", picklist_option["value"])
|
19
|
+
elsif field['type'] =~ /boolean/
|
20
|
+
self.send("#{field["name"]}=", field["defaultValue"])
|
21
|
+
else
|
22
|
+
self.send("#{field["name"]}=", field["defaultValueFormula"])
|
23
|
+
end
|
18
24
|
end
|
19
25
|
self.attributes=(attrs)
|
20
26
|
end
|
@@ -22,7 +28,7 @@ module Databasedotcom
|
|
22
28
|
# Returns a hash representing the state of this object
|
23
29
|
def attributes
|
24
30
|
self.class.attributes.inject({}) do |hash, attr|
|
25
|
-
hash[attr] = self.send(attr.to_sym)
|
31
|
+
hash[attr] = self.send(attr.to_sym) if self.respond_to?(attr.to_sym)
|
26
32
|
hash
|
27
33
|
end
|
28
34
|
end
|
@@ -314,6 +320,7 @@ module Databasedotcom
|
|
314
320
|
when "boolean"
|
315
321
|
params[attr] = value.is_a?(String) ? value.to_i != 0 : value
|
316
322
|
when "currency", "percent", "double"
|
323
|
+
value = value.gsub(/[^-0-9.0-9]/, '').to_f if value.respond_to?(:gsub)
|
317
324
|
params[attr] = value.to_f
|
318
325
|
when "date"
|
319
326
|
params[attr] = Date.parse(value) rescue Date.today
|
metadata
CHANGED
@@ -1,106 +1,78 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: databasedotcom
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 1.3.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Glenn Gillen, Danny Burkes & Richard Zhao
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-06-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: multipart-post
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70124183107340 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 1
|
32
|
-
version: "1.1"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: json
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *70124183107340
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: json
|
27
|
+
requirement: &70124183106920 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
47
33
|
type: :runtime
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rspec
|
51
34
|
prerelease: false
|
52
|
-
|
35
|
+
version_requirements: *70124183106920
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70124183106380 !ruby/object:Gem::Requirement
|
53
39
|
none: false
|
54
|
-
requirements:
|
40
|
+
requirements:
|
55
41
|
- - ~>
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
segments:
|
59
|
-
- 2
|
60
|
-
- 6
|
61
|
-
version: "2.6"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.6'
|
62
44
|
type: :development
|
63
|
-
version_requirements: *id003
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: webmock
|
66
45
|
prerelease: false
|
67
|
-
|
46
|
+
version_requirements: *70124183106380
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: webmock
|
49
|
+
requirement: &70124183105960 !ruby/object:Gem::Requirement
|
68
50
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
segments:
|
74
|
-
- 0
|
75
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
76
55
|
type: :development
|
77
|
-
version_requirements: *id004
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rake
|
80
56
|
prerelease: false
|
81
|
-
|
57
|
+
version_requirements: *70124183105960
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: &70124183105340 !ruby/object:Gem::Requirement
|
82
61
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
hash: 51
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
- 8
|
90
|
-
- 6
|
62
|
+
requirements:
|
63
|
+
- - =
|
64
|
+
- !ruby/object:Gem::Version
|
91
65
|
version: 0.8.6
|
92
66
|
type: :development
|
93
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70124183105340
|
94
69
|
description: A ruby wrapper for the Force.com REST API
|
95
|
-
email:
|
70
|
+
email:
|
96
71
|
- me@glenngillen.com
|
97
72
|
executables: []
|
98
|
-
|
99
73
|
extensions: []
|
100
|
-
|
101
74
|
extra_rdoc_files: []
|
102
|
-
|
103
|
-
files:
|
75
|
+
files:
|
104
76
|
- README.rdoc
|
105
77
|
- MIT-LICENSE
|
106
78
|
- lib/databasedotcom/chatter/comment.rb
|
@@ -129,38 +101,29 @@ files:
|
|
129
101
|
- lib/databasedotcom/sobject.rb
|
130
102
|
- lib/databasedotcom/version.rb
|
131
103
|
- lib/databasedotcom.rb
|
132
|
-
homepage:
|
104
|
+
homepage: ''
|
133
105
|
licenses: []
|
134
|
-
|
135
106
|
post_install_message:
|
136
107
|
rdoc_options: []
|
137
|
-
|
138
|
-
require_paths:
|
108
|
+
require_paths:
|
139
109
|
- lib
|
140
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
111
|
none: false
|
142
|
-
requirements:
|
143
|
-
- -
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
|
146
|
-
|
147
|
-
- 0
|
148
|
-
version: "0"
|
149
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
117
|
none: false
|
151
|
-
requirements:
|
152
|
-
- -
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
|
155
|
-
segments:
|
156
|
-
- 0
|
157
|
-
version: "0"
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
158
122
|
requirements: []
|
159
|
-
|
160
123
|
rubyforge_project: databasedotcom
|
161
|
-
rubygems_version: 1.8.
|
124
|
+
rubygems_version: 1.8.11
|
162
125
|
signing_key:
|
163
126
|
specification_version: 3
|
164
127
|
summary: A ruby wrapper for the Force.com REST API
|
165
128
|
test_files: []
|
166
|
-
|
129
|
+
has_rdoc:
|