aq1018-rforce 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.gitignore +3 -0
  2. data/History.txt +38 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +49 -0
  5. data/Rakefile +56 -0
  6. data/VERSION +1 -0
  7. data/aq1018-rforce.gemspec +101 -0
  8. data/bugs/issue-09d998dc3f9d6e8928598fd5d9c6627102dedd65.yaml +18 -0
  9. data/bugs/issue-1b668248120eb4fd055f0ea6b75ff807f6955936.yaml +22 -0
  10. data/bugs/issue-3ef7a7c5c7e38fb76e1f53e1b67f45559e21b104.yaml +18 -0
  11. data/bugs/issue-a7a87cb98d29943a49d1608adb68475838ad2e65.yaml +22 -0
  12. data/bugs/issue-c92d34e10038ba6b9acfd7e3dfb2b154e463baba.yaml +29 -0
  13. data/bugs/project.yaml +16 -0
  14. data/lib/rforce.rb +88 -0
  15. data/lib/rforce/binding.rb +261 -0
  16. data/lib/rforce/method_keys.rb +14 -0
  17. data/lib/rforce/soap_pullable.rb +93 -0
  18. data/lib/rforce/soap_response.rb +7 -0
  19. data/lib/rforce/soap_response_expat.rb +35 -0
  20. data/lib/rforce/soap_response_hpricot.rb +75 -0
  21. data/lib/rforce/soap_response_nokogiri.rb +64 -0
  22. data/lib/rforce/soap_response_rexml.rb +34 -0
  23. data/lib/rforce/version.rb +3 -0
  24. data/spec/rforce_spec.rb +105 -0
  25. data/spec/soap-response.xml +5928 -0
  26. data/spec/spec.opts +1 -0
  27. data/spec/spec_helper.rb +66 -0
  28. data/tasks/timing.rake +21 -0
  29. data/test/oauth_tests.rb +42 -0
  30. data/wsdl/README.html +23 -0
  31. data/wsdl/README.txt +22 -0
  32. data/wsdl/ca.pem +36 -0
  33. data/wsdl/default.rb +1627 -0
  34. data/wsdl/defaultDriver.rb +179 -0
  35. data/wsdl/orderedhash.rb +254 -0
  36. data/wsdl/partner.wsdl.xml +3104 -0
  37. data/wsdl/partner.wsdl.xml.old +1858 -0
  38. data/wsdl/sample/create.rb +37 -0
  39. data/wsdl/sample/describeGlobal.rb +28 -0
  40. data/wsdl/sample/describeSObjects.rb +34 -0
  41. data/wsdl/sample/getServerTimestamp.rb +27 -0
  42. data/wsdl/sample/query.rb +31 -0
  43. data/wsdl/sample/queryMore.rb +32 -0
  44. data/wsdl/sample/retrieve.rb +32 -0
  45. data/wsdl/sforceDriver.rb +43 -0
  46. data/wsdl/soap/property +1 -0
  47. data/wsdl/wsdl.rb +121 -0
  48. metadata +172 -0
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby
2
+ # vim: set tw=72 ai sw=2:
3
+
4
+ ### User Configurable Constants ###
5
+
6
+ DefaultUser = 'changeme@salesforce.com'
7
+ DefaultPasswd = 'changemetoo'
8
+
9
+ ###################################
10
+
11
+ require 'wsdl'
12
+ require 'pp'
13
+
14
+ user = ENV['RFORCE_USER'] || DefaultUser
15
+ passwd = ENV['RFORCE_PASS'] || DefaultPasswd
16
+
17
+
18
+ # Open a connection and login
19
+
20
+ if $DEBUG
21
+ drv = RForce::WSDL.new(user, passwd, $DEBUG,
22
+ "http://na1-api.salesforce.com/services/Soap/u/6.0")
23
+ else
24
+ drv = RForce::WSDL.new(user, passwd)
25
+ end
26
+
27
+ #result = drv.describeSObjects(["Contact"])
28
+ #pp result
29
+
30
+
31
+ sobj = RForce::makeSObject("Contact",
32
+ :LastName => "Blow",
33
+ :FirstName => "Joe",
34
+ :Salutation => "Mr.",
35
+ :Phone => "555-555-1212")
36
+
37
+ pp drv.create([sobj])
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby
2
+ # vim: set tw=72 ai sw=2:
3
+
4
+ ### User Configurable Constants ###
5
+
6
+ DefaultUser = 'changeme@salesforce.com'
7
+ DefaultPasswd = 'changemetoo'
8
+
9
+ ###################################
10
+
11
+ require 'wsdl'
12
+ require 'pp'
13
+
14
+ user = ENV['RFORCE_USER'] || DefaultUser
15
+ passwd = ENV['RFORCE_PASS'] || DefaultPasswd
16
+
17
+
18
+ # Open a connection and login
19
+
20
+ if $DEBUG
21
+ drv = RForce::WSDL.new(user, passwd, $DEBUG,
22
+ "http://na1-api.salesforce.com/services/Soap/c/6.0")
23
+ else
24
+ drv = RForce::WSDL.new(user, passwd)
25
+ end
26
+
27
+ puts "Your login can access the following objects:"
28
+ puts drv.types.join(", ")
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby
2
+ # vim: set tw=72 ai sw=2:
3
+
4
+ ### User Configurable Constants ###
5
+
6
+ DefaultUser = 'changeme@salesforce.com'
7
+ DefaultPasswd = 'changemetoo'
8
+
9
+ ###################################
10
+
11
+ require 'wsdl'
12
+ require 'pp'
13
+
14
+ user = ENV['RFORCE_USER'] || DefaultUser
15
+ passwd = ENV['RFORCE_PASS'] || DefaultPasswd
16
+
17
+
18
+ # Open a connection and login
19
+
20
+ if $DEBUG
21
+ drv = RForce::WSDL.new(user, passwd, $DEBUG,
22
+ "http://na1-api.salesforce.com/services/Soap/c/6.0")
23
+ else
24
+ drv = RForce::WSDL.new(user, passwd)
25
+ end
26
+
27
+ result = drv.describeSObjects(["SelfServiceUser", "Contact"])
28
+
29
+ puts "The SelfServiceUser object has the following fields:"
30
+ result[0].fields.each { |field| print "#{field.name}, " }
31
+
32
+ puts "\n\nThe Contact object has the following fields:"
33
+ result[1].fields.each { |field| print "#{field.name}, " }
34
+
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby
2
+ # vim: set tw=72 ai sw=2:
3
+
4
+ ### User Configurable Constants ###
5
+
6
+ DefaultUser = 'changeme@salesforce.com'
7
+ DefaultPasswd = 'changemetoo'
8
+
9
+ ###################################
10
+
11
+ require 'wsdl'
12
+ require 'pp'
13
+
14
+ user = ENV['RFORCE_USER'] || DefaultUser
15
+ passwd = ENV['RFORCE_PASS'] || DefaultPasswd
16
+
17
+
18
+ # Open a connection and login
19
+
20
+ if $DEBUG
21
+ drv = RForce::WSDL.new(user, passwd, $DEBUG,
22
+ "http://na1-api.salesforce.com/services/Soap/c/6.0")
23
+ else
24
+ drv = RForce::WSDL.new(user, passwd)
25
+ end
26
+
27
+ puts "Server time is : #{drv.getServerTimestamp.asctime}"
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby
2
+ # vim: set tw=72 ai sw=2:
3
+
4
+ ### User Configurable Constants ###
5
+
6
+ DefaultUser = 'changeme@salesforce.com'
7
+ DefaultPasswd = 'changemetoo'
8
+
9
+ ###################################
10
+
11
+ require 'wsdl'
12
+ require 'pp'
13
+
14
+ user = ENV['RFORCE_USER'] || DefaultUser
15
+ passwd = ENV['RFORCE_PASS'] || DefaultPasswd
16
+
17
+
18
+ # Open a connection and login
19
+
20
+ if $DEBUG
21
+ drv = RForce::WSDL.new(user, passwd, $DEBUG,
22
+ "http://na1-api.salesforce.com/services/Soap/c/6.0")
23
+ else
24
+ drv = RForce::WSDL.new(user, passwd)
25
+ end
26
+
27
+ query_rslt = drv.query("select Id, Name, SerialNumber from Asset where SerialNumber like '%04BM%'")
28
+
29
+ query_rslt.records.each do |rec|
30
+ puts "Id: #{rec.id}\tName: #{rec.name}\tSN: #{rec.serialNumber}"
31
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby
2
+ # vim: set tw=72 ai sw=2:
3
+
4
+ ### User Configurable Constants ###
5
+
6
+ DefaultUser = 'changeme@salesforce.com'
7
+ DefaultPasswd = 'changemetoo'
8
+
9
+ ###################################
10
+
11
+ require 'wsdl'
12
+ require 'pp'
13
+
14
+ user = ENV['RFORCE_USER'] || DefaultUser
15
+ passwd = ENV['RFORCE_PASS'] || DefaultPasswd
16
+
17
+
18
+ # Open a connection and login
19
+
20
+ if $DEBUG
21
+ drv = RForce::WSDL.new(user, passwd, $DEBUG,
22
+ "http://na1-api.salesforce.com/services/Soap/c/6.0")
23
+ else
24
+ drv = RForce::WSDL.new(user, passwd)
25
+ end
26
+
27
+ query_rslt = drv.query("select LastName from Contact")
28
+ puts "Size: #{query_rslt.size}\t Done: #{query_rslt.done}\tLoc: #{query_rslt.queryLocator}"
29
+
30
+ query_rslt = drv.queryMore(query_rslt.queryLocator)
31
+ puts "Size: #{query_rslt.size}\t Done: #{query_rslt.done}\tLoc: #{query_rslt.queryLocator}"
32
+
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby
2
+ # vim: set tw=72 ai sw=2:
3
+
4
+ ### User Configurable Constants ###
5
+
6
+ DefaultUser = 'changeme@salesforce.com'
7
+ DefaultPasswd = 'changemetoo'
8
+
9
+ ###################################
10
+
11
+ require 'wsdl'
12
+ require 'pp'
13
+
14
+ user = ENV['RFORCE_USER'] || DefaultUser
15
+ passwd = ENV['RFORCE_PASS'] || DefaultPasswd
16
+
17
+
18
+ # Open a connection and login
19
+
20
+ if $DEBUG
21
+ drv = RForce::WSDL.new(user, passwd, $DEBUG,
22
+ "http://na1-api.salesforce.com/services/Soap/c/6.0")
23
+ else
24
+ drv = RForce::WSDL.new(user, passwd)
25
+ end
26
+
27
+ query_results = drv.query("select Id from Asset where SerialNumber like '%04BM%'")
28
+ ids = query_results.records.map { |rslt| rslt.id }
29
+
30
+ drv.retrieve("Name, SerialNumber, SE__c", "Asset", ids).each do |obj|
31
+ puts "Name: #{obj.name}\tSN: #{obj.serialNumber}\tSE: #{obj.sE__c}"
32
+ end
@@ -0,0 +1,43 @@
1
+ require 'defaultDriver.rb'
2
+ require 'soap/header/simplehandler'
3
+ require 'orderedhash'
4
+
5
+ class SessionHeaderHandler < SOAP::Header::SimpleHandler
6
+
7
+ HeaderName = XSD::QName.new('urn:partner.soap.sforce.com', 'SessionHeader')
8
+
9
+ attr_accessor :sessionid
10
+
11
+ def initialize
12
+ super(HeaderName)
13
+ @sessionid = nil
14
+ end
15
+
16
+ def on_simple_outbound
17
+ if @sessionid
18
+ {'sessionId' => @sessionid}
19
+ else
20
+ nil # no header
21
+ end
22
+ end
23
+ end
24
+
25
+ class CallOptionsHandler < SOAP::Header::SimpleHandler
26
+
27
+ HeaderName = XSD::QName.new('urn:partner.soap.sforce.com', 'CallOptions')
28
+
29
+ attr_accessor :client
30
+
31
+ def initialize
32
+ super(HeaderName)
33
+ @client = nil
34
+ end
35
+
36
+ def on_simple_outbound
37
+ if @client
38
+ {'client' => @client}
39
+ else
40
+ nil # no header
41
+ end
42
+ end
43
+ end
@@ -0,0 +1 @@
1
+ client.protocol.http.ssl_config.ca_file = ca.pem
data/wsdl/wsdl.rb ADDED
@@ -0,0 +1,121 @@
1
+ # vim: set tw=72 ai sw=2:
2
+
3
+ require 'defaultDriver.rb'
4
+ require 'sforceDriver.rb'
5
+
6
+ # RForce module for using the Salesforce.com "SForce" API
7
+ module RForce
8
+
9
+ # This is the WSDL interface rather than "raw" XML interface
10
+ class WSDL
11
+
12
+ # The underlying SOAP binding
13
+ attr_reader :soap
14
+
15
+ # Specifies how an organization's data is encoded, such as UTF-8 or
16
+ # ISO8859/1
17
+ attr_reader :encoding
18
+
19
+ # Maximum number of records allowed in a create, update, or delete
20
+ # call
21
+ attr_reader :maxBatchSize
22
+
23
+ # Array of available objects for your organization.
24
+ attr_reader :types
25
+
26
+ # Create a new rforce object, handling the resetting of the endpoint
27
+ # URL and sessionId
28
+ def initialize(user, password, wiredump=false, endpoint=nil)
29
+
30
+ @fields = {}
31
+ @soap = Soap.new(endpoint)
32
+
33
+ sessionid_handler = SessionHeaderHandler.new
34
+ calloptions_handler = CallOptionsHandler.new
35
+
36
+
37
+ @soap.headerhandler << sessionid_handler
38
+ @soap.headerhandler << calloptions_handler
39
+
40
+ @soap.wiredump_dev = STDERR if wiredump
41
+
42
+ params = Login.new(user, password)
43
+ login_result = @soap.login(params).result
44
+
45
+ sessionid_handler.sessionid = login_result.sessionId
46
+ calloptions_handler.client = 'client'
47
+
48
+ @soap.endpoint_url = login_result.serverUrl unless endpoint
49
+
50
+ #result = soap.describeGlobal(DescribeGlobal.new).result
51
+ result = describeGlobal
52
+
53
+ @encoding = result.encoding
54
+ @maxBatchSize = result.maxBatchSize
55
+ @types = result.types
56
+
57
+ end
58
+
59
+ # Return the server timestamp
60
+ def getServerTimestamp
61
+ soap.getServerTimestamp(GetServerTimestamp.new).result.timestamp
62
+ end
63
+
64
+ # Retrieve a list of available SObjects for this login
65
+ def describeGlobal
66
+ soap.describeGlobal(DescribeGlobal.new).result
67
+ end
68
+
69
+ # Describe a list of SObjects (what fields, etc.)
70
+ # [Note: should really cache the results]
71
+ def describeSObjects(list)
72
+ soap.describeSObjects(DescribeSObjects.new(list)).result
73
+ end
74
+
75
+ # Perform a SOQL query
76
+ def query(querystr)
77
+ soap.query(Query.new(querystr)).result
78
+ end
79
+
80
+ # Continue a SOQL query
81
+ def queryMore(locator)
82
+ soap.queryMore(QueryMore.new(locator)).result
83
+ end
84
+
85
+ # Retrieve a list of specific objects
86
+ def retrieve(fieldList, from, ids)
87
+ soap.retrieve(Retrieve.new(fieldList, from, ids)).result
88
+ end
89
+
90
+ # Create an SObject
91
+ def RForce.makeSObject(type, params)
92
+ sobj = OrderedHash.new
93
+ sobj[XSD::QName.new('urn:sobject.partner.soap.sforce.com', 'type')] = type
94
+ params.keys.collect { |key| sobj[key] = params[key] }
95
+ sobj
96
+ end
97
+
98
+ def create(sobjects)
99
+ soap.create(:sObjects => sobjects).result
100
+ end
101
+
102
+ end
103
+
104
+ class SObject
105
+ attr_accessor :type, :id, :fieldsToNull, :any
106
+
107
+ def initialize(type, id, fieldsToNull, any)
108
+ @type = type
109
+ @id = id
110
+ @fieldsToNull = fieldsToNull
111
+ @any = any
112
+
113
+ sobj = OrderedHash.new
114
+ sobj[XSD::QName.new('urn:sobject.partner.soap.sforce.com', 'type')] = type
115
+ any.keys.collect { |key| sobj[key] = any[key] }
116
+ sobj
117
+ end
118
+
119
+ end
120
+
121
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aq1018-rforce
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 5
8
+ - 1
9
+ version: 0.5.1
10
+ platform: ruby
11
+ authors:
12
+ - Ian Dees
13
+ - Logan (henriquez)
14
+ - Aaron Qian
15
+ - Moritz Heidkamp
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2010-12-02 00:00:00 -08:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: builder
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ segments:
32
+ - 2
33
+ - 0
34
+ - 0
35
+ version: 2.0.0
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: nokogiri
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ segments:
47
+ - 1
48
+ - 4
49
+ - 4
50
+ version: 1.4.4
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: oauth
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: rspec
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 1
76
+ - 3
77
+ version: "1.3"
78
+ type: :development
79
+ version_requirements: *id004
80
+ description: Rather than enforcing adherence to the sforce.com schema, RForce assumes you are familiar with the API. Ruby method names become SOAP method names. Nested Ruby hashes become nested XML elements.
81
+ email: aq1018@gmail.com
82
+ executables: []
83
+
84
+ extensions: []
85
+
86
+ extra_rdoc_files:
87
+ - LICENSE
88
+ - README.rdoc
89
+ files:
90
+ - .gitignore
91
+ - History.txt
92
+ - LICENSE
93
+ - README.rdoc
94
+ - Rakefile
95
+ - VERSION
96
+ - aq1018-rforce.gemspec
97
+ - bugs/issue-09d998dc3f9d6e8928598fd5d9c6627102dedd65.yaml
98
+ - bugs/issue-1b668248120eb4fd055f0ea6b75ff807f6955936.yaml
99
+ - bugs/issue-3ef7a7c5c7e38fb76e1f53e1b67f45559e21b104.yaml
100
+ - bugs/issue-a7a87cb98d29943a49d1608adb68475838ad2e65.yaml
101
+ - bugs/issue-c92d34e10038ba6b9acfd7e3dfb2b154e463baba.yaml
102
+ - bugs/project.yaml
103
+ - lib/rforce.rb
104
+ - lib/rforce/binding.rb
105
+ - lib/rforce/method_keys.rb
106
+ - lib/rforce/soap_pullable.rb
107
+ - lib/rforce/soap_response.rb
108
+ - lib/rforce/soap_response_expat.rb
109
+ - lib/rforce/soap_response_hpricot.rb
110
+ - lib/rforce/soap_response_nokogiri.rb
111
+ - lib/rforce/soap_response_rexml.rb
112
+ - lib/rforce/version.rb
113
+ - spec/rforce_spec.rb
114
+ - spec/soap-response.xml
115
+ - spec/spec.opts
116
+ - spec/spec_helper.rb
117
+ - tasks/timing.rake
118
+ - test/oauth_tests.rb
119
+ - wsdl/README.html
120
+ - wsdl/README.txt
121
+ - wsdl/ca.pem
122
+ - wsdl/default.rb
123
+ - wsdl/defaultDriver.rb
124
+ - wsdl/orderedhash.rb
125
+ - wsdl/partner.wsdl.xml
126
+ - wsdl/partner.wsdl.xml.old
127
+ - wsdl/sample/create.rb
128
+ - wsdl/sample/describeGlobal.rb
129
+ - wsdl/sample/describeSObjects.rb
130
+ - wsdl/sample/getServerTimestamp.rb
131
+ - wsdl/sample/query.rb
132
+ - wsdl/sample/queryMore.rb
133
+ - wsdl/sample/retrieve.rb
134
+ - wsdl/sforceDriver.rb
135
+ - wsdl/soap/property
136
+ - wsdl/wsdl.rb
137
+ has_rdoc: true
138
+ homepage: http://github.com/aq1018/rforce
139
+ licenses: []
140
+
141
+ post_install_message:
142
+ rdoc_options:
143
+ - --charset=UTF-8
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ segments:
152
+ - 0
153
+ version: "0"
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ segments:
160
+ - 0
161
+ version: "0"
162
+ requirements: []
163
+
164
+ rubyforge_project:
165
+ rubygems_version: 1.3.7
166
+ signing_key:
167
+ specification_version: 3
168
+ summary: A simple, usable binding to the SalesForce API.
169
+ test_files:
170
+ - spec/rforce_spec.rb
171
+ - spec/spec_helper.rb
172
+ - test/oauth_tests.rb