soapforce 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTk2ZjA2ZjNkY2IzMzI0ZWRiNmY5ZTNhYmRhNzlmN2Q2ZWM5NjllOA==
5
+ data.tar.gz: !binary |-
6
+ ZGQyZTNhZjdkMzU0MDVmZDNjNWJiMTQ3NjhkNzYyYzgxZTg5ODc3NQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZWVmMzlmZGUxNTFmZWY4ZDlmNGFjN2ZhOTcyYzM0YjNhYTU2YjE2ZTA1NzQ0
10
+ MjIyM2YyZWFkOTkzZTU0ODk5N2UwYWZkNWFmZjFkY2YzZDBjNTI0NDlhMTky
11
+ ODg5Yjk5MDViNTg1YmQ3YjFmYTVkNWM5OWMxNThkNzRmZTUzNmM=
12
+ data.tar.gz: !binary |-
13
+ NDFhMTRmYjE1MTQ0NzNkM2QzM2Q2ZGYyMjdjOWE0ZmQ2MDBkMzBkODdhZTI1
14
+ Mjk0ZGQ5MTc5YmIwN2MyY2VkNGQ0YTBjNGM1MDI0NWMwZDE1MzU5NTUwNzEz
15
+ ZDhiYmNjY2QwODJhMTRlNzRjOTQ0MzE3ZTJhMGYyYTg4OWYyZGQ=
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/README.md CHANGED
@@ -28,7 +28,7 @@ Or install it yourself as:
28
28
 
29
29
  ## Usage
30
30
 
31
- For ISV Partners you can specify your client_id in a configuration block which will get included in the CallOptions header of every request.
31
+ For ISV Partners you can specify your client_id in a configuration block which will get included in the CallOptions header of every request.
32
32
 
33
33
  # config/initializers/soapforce.rb
34
34
  # This is your ISV Partner Client ID.
@@ -37,6 +37,21 @@ For ISV Partners you can specify your client_id in a configuration block which w
37
37
  config.client_id = "ParterName/SomeValue/"
38
38
  end
39
39
 
40
+ ### Sandbox Orgs
41
+
42
+ You can connect to sandbox orgs by specifying a host. The default host is 'login.salesforce.com':
43
+
44
+ ```ruby
45
+ client = Soapforce::Client.new(:host => 'test.salesforce.com')
46
+ ```
47
+
48
+ ### Logging
49
+
50
+ You can specify a logger by passing a logger. Logging is disabled by default.
51
+
52
+ ```ruby
53
+ client = Soapforce::Client.new(:logger => 'test.salesforce.com')
54
+ ```
40
55
 
41
56
  #### Username/Password authentication
42
57
 
@@ -130,6 +145,18 @@ client.describe(['Account', 'Opportunity'])
130
145
  # => [{ ... },{ ... }]
131
146
  ```
132
147
 
148
+ ### describe_layout
149
+
150
+ ```ruby
151
+ # get layouts for an sobject type
152
+ client.describe_layout('Account')
153
+ # => { ... }
154
+
155
+ # get the details for a specific layout
156
+ client.describe_layout('Account', '012000000000000AAA')
157
+ # => { ... }
158
+ ```
159
+
133
160
  ### logout
134
161
 
135
162
  ```ruby
@@ -3,26 +3,38 @@ module Soapforce
3
3
 
4
4
  attr_reader :client
5
5
  attr_reader :headers
6
+ attr_accessor :logger
6
7
 
7
8
  # The partner.wsdl is used by default but can be changed by passing in a new :wsdl option.
8
- # A client_id can be
9
+ # A client_id can be
9
10
  def initialize(options={})
10
11
  @describe_cache = {}
12
+ @describe_layout_cache = {}
11
13
  @headers = {}
14
+
12
15
  @wsdl = options[:wsdl] || File.dirname(__FILE__) + "/../../resources/partner.wsdl.xml"
13
16
 
14
- # If a client_id is provided then it needs to be included
17
+ # If a client_id is provided then it needs to be included
15
18
  # in the header for every request. This allows ISV Partners
16
19
  # to make SOAP calls in Professional/Group Edition organizations.
17
20
 
18
21
  client_id = options[:client_id] || Soapforce.configuration.client_id
19
22
  @headers = {"tns:CallOptions" => {"tns:client" => client_id}} if client_id
20
23
 
24
+ @version = options[:version] || Soapforce.configuration.version || 28.0
25
+ @host = options[:host] || "login.salesforce.com"
26
+ @login_url = "https://#{@host}/services/Soap/u/#{@version}"
27
+
28
+ @logger = options[:logger] || false
29
+
21
30
  @client = Savon.client(
22
31
  wsdl: @wsdl,
23
32
  soap_header: @headers,
24
33
  convert_request_keys_to: :none,
25
- pretty_print_xml: true
34
+ pretty_print_xml: true,
35
+ logger: @logger,
36
+ log: (@logger != false),
37
+ endpoint: @login_url
26
38
  )
27
39
  end
28
40
 
@@ -70,6 +82,8 @@ module Soapforce
70
82
  wsdl: @wsdl,
71
83
  soap_header: @headers,
72
84
  convert_request_keys_to: :none,
85
+ logger: @logger,
86
+ log: (@logger != false),
73
87
  endpoint: @server_url
74
88
  )
75
89
 
@@ -129,7 +143,7 @@ module Soapforce
129
143
  def describe(sobject_type)
130
144
  if sobject_type.is_a?(Array)
131
145
  list = sobject_type.map do |type|
132
- {:sObjectType => type}
146
+ {:sObjectType => type}
133
147
  end
134
148
  response = call_soap_api(:describe_s_objects, :sObjectType => sobject_type)
135
149
  else
@@ -145,6 +159,36 @@ module Soapforce
145
159
  response
146
160
  end
147
161
 
162
+ # Public: Returns the layout for the specified object
163
+ #
164
+ # sobject - String name of the sobject.
165
+ #
166
+ # Examples
167
+ #
168
+ # # get layouts for an sobject type
169
+ # client.describe_layout('Account')
170
+ # # => { ... }
171
+ #
172
+ # # get layouts for an sobject type
173
+ # client.describe_layout('Account', '012000000000000AAA')
174
+ # # => { ... }
175
+ #
176
+ # Returns the Hash representation of the describe call.
177
+ def describe_layout(sobject_type, layout_id=nil)
178
+ # Cache objects to avoid repeat lookups.
179
+ @describe_layout_cache[sobject_type] ||={}
180
+
181
+ # nil key is for full object.
182
+ if @describe_layout_cache[sobject_type][layout_id].nil?
183
+ response = call_soap_api(:describe_layout, :sObjectType => sobject_type, :recordTypeIds => layout_id)
184
+ @describe_layout_cache[sobject_type][layout_id] = response
185
+ else
186
+ response = @describe_layout_cache[sobject_type][layout_id]
187
+ end
188
+
189
+ response
190
+ end
191
+
148
192
  def query(soql)
149
193
  result = call_soap_api(:query, {:queryString => soql})
150
194
  QueryResult.new(result)
@@ -1,6 +1,7 @@
1
1
  module Soapforce
2
2
  class Configuration
3
3
  attr_accessor :client_id
4
+ attr_accessor :version
4
5
 
5
6
  def initialize
6
7
  @client_id = nil
@@ -9,7 +10,7 @@ module Soapforce
9
10
 
10
11
  class << self
11
12
  def configuration
12
- @configuration ||= Configuration.new
13
+ @configuration ||= Configuration.new
13
14
  end
14
15
 
15
16
  def configure
@@ -1,3 +1,3 @@
1
1
  module Soapforce
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
data/soapforce.gemspec CHANGED
@@ -3,32 +3,24 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'soapforce/version'
5
5
 
6
- Gem::Specification.new do |gem|
7
- gem.name = "soapforce"
8
- gem.version = Soapforce::VERSION
9
- gem.authors = ["Joe Heth"]
10
- gem.email = ["joeheth@gmail.com"]
11
- gem.description = %q{A ruby client for the Salesforce SOAP API based on Savon.}
12
- gem.summary = %q{Wraps Savon with helper methods and custom types for interacting with the Salesforce SOAP API.}
13
- gem.homepage = "https://github.com/TinderBox/soapforce"
14
- gem.license = 'MIT'
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "soapforce"
8
+ spec.version = Soapforce::VERSION
9
+ spec.authors = ["Joe Heth"]
10
+ spec.email = ["joeheth@gmail.com"]
11
+ spec.description = %q{A ruby client for the Salesforce SOAP API based on Savon.}
12
+ spec.summary = %q{Wraps Savon with helper methods and custom types for interacting with the Salesforce SOAP API.}
13
+ spec.homepage = "https://github.com/TinderBox/soapforce"
14
+ spec.license = 'MIT'
15
15
 
16
- ignores = File.readlines('.gitignore').grep(/\S+/).map(&:chomp)
17
- dotfiles = %w[.gitignore .travis.yml]
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
18
20
 
19
- all_files_without_ignores = Dir['**/*'].reject { |f|
20
- File.directory?(f) || ignores.any? { |i| File.fnmatch(i, f) }
21
- }
21
+ spec.add_runtime_dependency "savon", "~>2.3.0", '>= 2.3.0'
22
22
 
23
- gem.files = (all_files_without_ignores + dotfiles).sort
24
-
25
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
26
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
27
- gem.require_paths = ["lib"]
28
-
29
- gem.add_dependency("savon", "~>2.3.0")
30
-
31
- gem.add_development_dependency 'rspec', '~> 2.14.0'
32
- gem.add_development_dependency 'webmock', '~> 1.13.0'
33
- gem.add_development_dependency 'simplecov', '~> 0.7.1'
23
+ spec.add_development_dependency 'rspec', '~> 2.14.0', '>= 2.14.0'
24
+ spec.add_development_dependency 'webmock', '~> 1.17.0', '>= 1.17.0'
25
+ spec.add_development_dependency 'simplecov', '~> 0.9.0', '>= 0.9.0'
34
26
  end
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soapenv:Envelope xmlns="urn:partner.soap.sforce.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <soapenv:Body>
4
+ <describeLayoutResponse>
5
+ <result>
6
+ <!-- Lots of layout data here -->
7
+ </result>
8
+ </describeLayoutResponse>
9
+ </soapenv:Body>
10
+ </soapenv:Envelope>
@@ -83,6 +83,28 @@ describe Soapforce::Client do
83
83
  end
84
84
  end
85
85
 
86
+ describe "#descibeLayout" do
87
+
88
+ it "gets layouts for an sobject type" do
89
+
90
+ body = %Q{<tns:describeLayout><tns:sObjectType>Account</tns:sObjectType><tns:recordTypeIds xsi:nil="true"/></tns:describeLayout>}
91
+ stub = stub_api_request(endpoint, {with_body: body, fixture: 'describe_layout_response'})
92
+
93
+ subject.describe_layout("Account")
94
+
95
+ # Hit cache.
96
+ subject.describe_layout("Account")
97
+ end
98
+
99
+ it "get the details for a specific layout" do
100
+
101
+ body = %Q{<tns:describeLayout><tns:sObjectType>Account</tns:sObjectType><tns:recordTypeIds>012000000000000AAA</tns:recordTypeIds></tns:describeLayout>}
102
+ stub = stub_api_request(endpoint, {with_body: body, fixture: 'describe_layout_response'})
103
+
104
+ subject.describe_layout('Account', '012000000000000AAA')
105
+ end
106
+ end
107
+
86
108
  describe "#retrieve" do
87
109
 
88
110
  it "should retrieve object by id" do
metadata CHANGED
@@ -1,80 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Joe Heth
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-25 00:00:00.000000000 Z
11
+ date: 2014-11-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: savon
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.3.0
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 2.3.0
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 2.3.0
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.3.0
30
33
  - !ruby/object:Gem::Dependency
31
34
  name: rspec
32
35
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
36
  requirements:
35
37
  - - ~>
36
38
  - !ruby/object:Gem::Version
37
39
  version: 2.14.0
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: 2.14.0
38
43
  type: :development
39
44
  prerelease: false
40
45
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
46
  requirements:
43
47
  - - ~>
44
48
  - !ruby/object:Gem::Version
45
49
  version: 2.14.0
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: 2.14.0
46
53
  - !ruby/object:Gem::Dependency
47
54
  name: webmock
48
55
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
56
  requirements:
51
57
  - - ~>
52
58
  - !ruby/object:Gem::Version
53
- version: 1.13.0
59
+ version: 1.17.0
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.17.0
54
63
  type: :development
55
64
  prerelease: false
56
65
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
61
- version: 1.13.0
69
+ version: 1.17.0
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: 1.17.0
62
73
  - !ruby/object:Gem::Dependency
63
74
  name: simplecov
64
75
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
76
  requirements:
67
77
  - - ~>
68
78
  - !ruby/object:Gem::Version
69
- version: 0.7.1
79
+ version: 0.9.0
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.0
70
83
  type: :development
71
84
  prerelease: false
72
85
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
86
  requirements:
75
87
  - - ~>
76
88
  - !ruby/object:Gem::Version
77
- version: 0.7.1
89
+ version: 0.9.0
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: 0.9.0
78
93
  description: A ruby client for the Salesforce SOAP API based on Savon.
79
94
  email:
80
95
  - joeheth@gmail.com
@@ -83,13 +98,13 @@ extensions: []
83
98
  extra_rdoc_files: []
84
99
  files:
85
100
  - .gitignore
101
+ - .rspec
86
102
  - .travis.yml
87
103
  - Gemfile
88
104
  - LICENSE.txt
89
105
  - README.md
90
106
  - Rakefile
91
107
  - lib/soapforce.rb
92
- - lib/soapforce/actions
93
108
  - lib/soapforce/client.rb
94
109
  - lib/soapforce/configuration.rb
95
110
  - lib/soapforce/query_result.rb
@@ -102,6 +117,7 @@ files:
102
117
  - spec/fixtures/delete_response.xml
103
118
  - spec/fixtures/delete_response_failure.xml
104
119
  - spec/fixtures/describe_global_response.xml
120
+ - spec/fixtures/describe_layout_response.xml
105
121
  - spec/fixtures/describe_s_object_response.xml
106
122
  - spec/fixtures/describe_s_objects_response.xml
107
123
  - spec/fixtures/get_user_info_response.xml
@@ -123,31 +139,29 @@ files:
123
139
  - spec/lib/sobject_spec.rb
124
140
  - spec/spec_helper.rb
125
141
  - spec/support/fixture_helpers.rb
126
- - test.rb
127
142
  homepage: https://github.com/TinderBox/soapforce
128
143
  licenses:
129
144
  - MIT
145
+ metadata: {}
130
146
  post_install_message:
131
147
  rdoc_options: []
132
148
  require_paths:
133
149
  - lib
134
150
  required_ruby_version: !ruby/object:Gem::Requirement
135
- none: false
136
151
  requirements:
137
152
  - - ! '>='
138
153
  - !ruby/object:Gem::Version
139
154
  version: '0'
140
155
  required_rubygems_version: !ruby/object:Gem::Requirement
141
- none: false
142
156
  requirements:
143
157
  - - ! '>='
144
158
  - !ruby/object:Gem::Version
145
159
  version: '0'
146
160
  requirements: []
147
161
  rubyforge_project:
148
- rubygems_version: 1.8.24
162
+ rubygems_version: 2.2.2
149
163
  signing_key:
150
- specification_version: 3
164
+ specification_version: 4
151
165
  summary: Wraps Savon with helper methods and custom types for interacting with the
152
166
  Salesforce SOAP API.
153
167
  test_files:
@@ -156,6 +170,7 @@ test_files:
156
170
  - spec/fixtures/delete_response.xml
157
171
  - spec/fixtures/delete_response_failure.xml
158
172
  - spec/fixtures/describe_global_response.xml
173
+ - spec/fixtures/describe_layout_response.xml
159
174
  - spec/fixtures/describe_s_object_response.xml
160
175
  - spec/fixtures/describe_s_objects_response.xml
161
176
  - spec/fixtures/get_user_info_response.xml
@@ -1,38 +0,0 @@
1
- login
2
- describe_s_object
3
- describe_s_objects
4
- describe_global
5
- describe_data_category_groups
6
- describe_data_category_group_structures
7
- describe_layout
8
- describe_softphone_layout
9
- describe_search_layouts
10
- describe_search_scope_order
11
- describe_tabs
12
- create
13
- update
14
- upsert
15
- merge
16
- delete
17
- undelete
18
- empty_recycle_bin
19
- retrieve
20
- process
21
- convert_lead
22
- logout
23
- invalidate_sessions
24
- get_deleted
25
- get_updated
26
- query
27
- query_all
28
- query_more
29
- search
30
- get_server_timestamp
31
- set_password
32
- reset_password
33
- get_user_info
34
- send_email_message
35
- send_email
36
- perform_quick_actions
37
- describe_quick_actions
38
- describe_available_quick_actions
data/test.rb DELETED
@@ -1,58 +0,0 @@
1
- require 'soapforce'
2
-
3
- Soapforce.configure do |config|
4
- config.client_id = "TinderBox/TinderBox/"
5
- end
6
-
7
- client = Soapforce::Client.new
8
- puts client.operations
9
-
10
- user_result = client.login(username: "joe.heth@gettinderbox.com", password: "t1nd3rb0x1uzAgNZt8mT7G0MZlIr1Zq0oG") # 1Qn2uKB1DGZBF8WNGMFz1CS42s")
11
-
12
- client.invalidate_sessions
13
-
14
- exit
15
- #ap client.get_user_info
16
-
17
- #ap client.list_sobjects
18
- #ap client.org_id
19
- #ap client.field_list("Opportunity")
20
- #ap client.field_details("Opportunity", "Name")
21
- #ap client.find_by_field("Opportunity", "006A000000LbkT5IAJ", "Id")
22
-
23
- #ap client.find_where("Opportunity", {Id: "006A000000LbkT5IAJ", Amount: nil}).first
24
- ap client.retrieve("Opportunity", "006A000000LbkT5IAJ")
25
-
26
- exit
27
-
28
- opp = client.describe("Opportunity")
29
- ap opp
30
-
31
- objects = client.describe(["Account", "Contact"])
32
- ap objects.first
33
- ap objects.last
34
-
35
- result = client.query("Select Id, Name, StageName From Opportunity WHERE Id = '006A000000LZhwN' OR Id = '006A000000LaF4x'")
36
- result.each do |opp|
37
- ap opp
38
- end
39
-
40
- #result = client.search("FIND {Name} IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead")
41
- #ap result
42
-
43
- ap client.create("Opportunity", {
44
- Name: "SOAPForce Opportunity",
45
- CloseDate: Date.today,
46
- StageName: 'Prospecting'
47
- })
48
-
49
- =begin
50
- ap client.update("Opportunity", {
51
- Id: "006A000000LbiizIAB",
52
- tinderbox__OrderNumber__c: "12345",
53
- tinderbox__TrackingNumber__c: "ABCDEF",
54
- Amount: 12.50
55
- })
56
-
57
- ap client.delete("006A000000LbiizIAB")
58
- =end