ryandotsmith-asf-soap-adapter 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +125 -0
- data/Rakefile +63 -0
- data/VERSION +1 -0
- data/asf-soap-adapter.gemspec +300 -0
- data/asf-soap-adapter.pptx +0 -0
- data/deploy +6 -0
- data/lib/active_record/connection_adapters/activesalesforce.rb +36 -0
- data/lib/active_record/connection_adapters/activesalesforce_adapter.rb +919 -0
- data/lib/active_record/connection_adapters/asf_active_record.rb +40 -0
- data/lib/active_record/connection_adapters/boxcar_command.rb +66 -0
- data/lib/active_record/connection_adapters/column_definition.rb +95 -0
- data/lib/active_record/connection_adapters/entity_definition.rb +59 -0
- data/lib/active_record/connection_adapters/id_resolver.rb +84 -0
- data/lib/active_record/connection_adapters/recording_binding.rb +93 -0
- data/lib/active_record/connection_adapters/relationship_definition.rb +81 -0
- data/lib/active_record/connection_adapters/result_array.rb +31 -0
- data/lib/active_record/connection_adapters/sid_authentication_filter.rb +57 -0
- data/lib/activerecord-activesalesforce-adapter.rb +1 -0
- data/lib/asf-soap-adapter.rb +34 -0
- data/lib/salesforce/account.rb +28 -0
- data/lib/salesforce/account_feed.rb +27 -0
- data/lib/salesforce/apex_log.rb +28 -0
- data/lib/salesforce/asset.rb +27 -0
- data/lib/salesforce/asset_feed.rb +27 -0
- data/lib/salesforce/campaign.rb +27 -0
- data/lib/salesforce/campaign_feed.rb +27 -0
- data/lib/salesforce/case.rb +27 -0
- data/lib/salesforce/case_feed.rb +27 -0
- data/lib/salesforce/case_team_member.rb +28 -0
- data/lib/salesforce/case_team_role.rb +28 -0
- data/lib/salesforce/chatter_feed.rb +291 -0
- data/lib/salesforce/contact.rb +27 -0
- data/lib/salesforce/contact_feed.rb +29 -0
- data/lib/salesforce/contract.rb +27 -0
- data/lib/salesforce/contract_feed.rb +27 -0
- data/lib/salesforce/entity_subscription.rb +27 -0
- data/lib/salesforce/feed_comment.rb +27 -0
- data/lib/salesforce/feed_post.rb +27 -0
- data/lib/salesforce/feed_tracked_change.rb +27 -0
- data/lib/salesforce/file_writer.rb +61 -0
- data/lib/salesforce/group.rb +28 -0
- data/lib/salesforce/group_member.rb +28 -0
- data/lib/salesforce/lead.rb +27 -0
- data/lib/salesforce/lead_feed.rb +27 -0
- data/lib/salesforce/news_feed.rb +27 -0
- data/lib/salesforce/opportunity.rb +27 -0
- data/lib/salesforce/opportunity_feed.rb +27 -0
- data/lib/salesforce/organization.rb +27 -0
- data/lib/salesforce/product2.rb +27 -0
- data/lib/salesforce/product2_feed.rb +27 -0
- data/lib/salesforce/sf_base.rb +94 -0
- data/lib/salesforce/sf_utility.rb +214 -0
- data/lib/salesforce/solution.rb +27 -0
- data/lib/salesforce/solution_feed.rb +27 -0
- data/lib/salesforce/solution_history.rb +28 -0
- data/lib/salesforce/task.rb +28 -0
- data/lib/salesforce/task_feed.rb +28 -0
- data/lib/salesforce/user.rb +27 -0
- data/lib/salesforce/user_feed.rb +27 -0
- data/lib/salesforce/user_profile_feed.rb +27 -0
- data/lib/salesforce/user_role.rb +28 -0
- data/ryandotsmith-asf-soap-adapter.gemspec +301 -0
- data/test/asf-soap-adapter-rails-app/README +243 -0
- data/test/asf-soap-adapter-rails-app/Rakefile +10 -0
- data/test/asf-soap-adapter-rails-app/app/controllers/adapter_homes_controller.rb +83 -0
- data/test/asf-soap-adapter-rails-app/app/controllers/application_controller.rb +10 -0
- data/test/asf-soap-adapter-rails-app/app/helpers/adapter_homes_helper.rb +2 -0
- data/test/asf-soap-adapter-rails-app/app/helpers/application_helper.rb +3 -0
- data/test/asf-soap-adapter-rails-app/app/models/adapter_home.rb +2 -0
- data/test/asf-soap-adapter-rails-app/app/views/adapter_homes/edit.html.erb +24 -0
- data/test/asf-soap-adapter-rails-app/app/views/adapter_homes/index.html.erb +24 -0
- data/test/asf-soap-adapter-rails-app/app/views/adapter_homes/new.html.erb +23 -0
- data/test/asf-soap-adapter-rails-app/app/views/adapter_homes/show.html.erb +18 -0
- data/test/asf-soap-adapter-rails-app/app/views/layouts/adapter_homes.html.erb +17 -0
- data/test/asf-soap-adapter-rails-app/config/boot.rb +110 -0
- data/test/asf-soap-adapter-rails-app/config/database.yml +30 -0
- data/test/asf-soap-adapter-rails-app/config/environment.rb +44 -0
- data/test/asf-soap-adapter-rails-app/config/environments/development.rb +17 -0
- data/test/asf-soap-adapter-rails-app/config/environments/production.rb +28 -0
- data/test/asf-soap-adapter-rails-app/config/environments/salesforce-default-realm.rb +30 -0
- data/test/asf-soap-adapter-rails-app/config/environments/test.rb +28 -0
- data/test/asf-soap-adapter-rails-app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/asf-soap-adapter-rails-app/config/initializers/cookie_verification_secret.rb +7 -0
- data/test/asf-soap-adapter-rails-app/config/initializers/inflections.rb +10 -0
- data/test/asf-soap-adapter-rails-app/config/initializers/mime_types.rb +5 -0
- data/test/asf-soap-adapter-rails-app/config/initializers/new_rails_defaults.rb +21 -0
- data/test/asf-soap-adapter-rails-app/config/initializers/session_store.rb +15 -0
- data/test/asf-soap-adapter-rails-app/config/locales/en.yml +5 -0
- data/test/asf-soap-adapter-rails-app/config/routes.rb +46 -0
- data/test/asf-soap-adapter-rails-app/db/development.sqlite3 +0 -0
- data/test/asf-soap-adapter-rails-app/db/migrate/20101107202112_create_adapter_homes.rb +15 -0
- data/test/asf-soap-adapter-rails-app/db/schema.rb +22 -0
- data/test/asf-soap-adapter-rails-app/db/seeds.rb +7 -0
- data/test/asf-soap-adapter-rails-app/db/test.sqlite3 +0 -0
- data/test/asf-soap-adapter-rails-app/log/development.log +51 -0
- data/test/asf-soap-adapter-rails-app/log/salesforce-default-realm.log +928 -0
- data/test/asf-soap-adapter-rails-app/nbproject/private/config.properties +0 -0
- data/test/asf-soap-adapter-rails-app/nbproject/private/private.properties +3 -0
- data/test/asf-soap-adapter-rails-app/nbproject/private/private.xml +4 -0
- data/test/asf-soap-adapter-rails-app/nbproject/private/rake-d.txt +94 -0
- data/test/asf-soap-adapter-rails-app/nbproject/project.properties +5 -0
- data/test/asf-soap-adapter-rails-app/nbproject/project.xml +9 -0
- data/test/asf-soap-adapter-rails-app/public/404.html +30 -0
- data/test/asf-soap-adapter-rails-app/public/422.html +30 -0
- data/test/asf-soap-adapter-rails-app/public/500.html +30 -0
- data/test/asf-soap-adapter-rails-app/public/favicon.ico +0 -0
- data/test/asf-soap-adapter-rails-app/public/images/rails.png +0 -0
- data/test/asf-soap-adapter-rails-app/public/javascripts/application.js +2 -0
- data/test/asf-soap-adapter-rails-app/public/javascripts/controls.js +963 -0
- data/test/asf-soap-adapter-rails-app/public/javascripts/dragdrop.js +973 -0
- data/test/asf-soap-adapter-rails-app/public/javascripts/effects.js +1128 -0
- data/test/asf-soap-adapter-rails-app/public/javascripts/prototype.js +4320 -0
- data/test/asf-soap-adapter-rails-app/public/robots.txt +5 -0
- data/test/asf-soap-adapter-rails-app/public/stylesheets/scaffold.css +54 -0
- data/test/asf-soap-adapter-rails-app/script/about +4 -0
- data/test/asf-soap-adapter-rails-app/script/console +3 -0
- data/test/asf-soap-adapter-rails-app/script/dbconsole +3 -0
- data/test/asf-soap-adapter-rails-app/script/destroy +3 -0
- data/test/asf-soap-adapter-rails-app/script/generate +3 -0
- data/test/asf-soap-adapter-rails-app/script/performance/benchmarker +3 -0
- data/test/asf-soap-adapter-rails-app/script/performance/profiler +3 -0
- data/test/asf-soap-adapter-rails-app/script/plugin +3 -0
- data/test/asf-soap-adapter-rails-app/script/runner +3 -0
- data/test/asf-soap-adapter-rails-app/script/server +3 -0
- data/test/asf-soap-adapter-rails-app/test/performance/browsing_test.rb +9 -0
- data/test/asf-soap-adapter-rails-app/test/test_helper.rb +44 -0
- data/test/asf-soap-adapter-rails-app/test/test_keys.rb +4 -0
- data/test/asf-soap-adapter-rails-app/test/unit/adapter_home_test.rb +8 -0
- data/test/asf-soap-adapter-rails-app/test/unit/helpers/adapter_homes_helper_test.rb +4 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/account_feed_test.rb +16 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/account_test.rb +66 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/apex_log_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/asset_feed_test.rb +14 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/asset_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/campaign_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/campaign_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/case_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/case_team_member_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/case_team_role.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/case_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/chatter_feed_test.rb +53 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/contact_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/contact_test.rb +14 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/contract_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/contract_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/entity_subscription_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/feed_comment_test.rb +9 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/feed_post_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/feed_tracked_change_test.rb +9 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/group_member_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/group_test.rb +24 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/lead_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/lead_test.rb +40 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/news_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/opportunity_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/opportunity_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/organization_test.rb +8 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/product2_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/product2_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/salesforce_base_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/solution_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/solution_history_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/solution_test.rb +14 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/task_feed_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/task_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/user_feed_test.rb +13 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/user_profile_feed_test.rb +11 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/user_role_test.rb +10 -0
- data/test/asf-soap-adapter-rails-app/test/unit/salesforce/user_test.rb +48 -0
- data/test/basic_test.rb +204 -0
- data/test/config.yml +5 -0
- data/test/helper.rb +10 -0
- data/test/recorded_test_case.rb +87 -0
- data/test/simple_test.rb +96 -0
- data/test/tests_without_rail.rb +65 -0
- metadata +401 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class FeedPost < SfBase
|
25
|
+
set_table_name 'feed_posts'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class FeedTrackedChange < SfBase
|
25
|
+
set_table_name 'feed_tracked_changes'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'logger'
|
2
|
+
module Salesforce
|
3
|
+
class FileWriter < Object
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
#### define @logger
|
8
|
+
# http://ruby-doc.org/core/classes/@logger.html
|
9
|
+
# TODO use a log file, rather than Standout
|
10
|
+
@logger = Logger.new(STDOUT)
|
11
|
+
@logger.debug 'FileWriter initialized.'
|
12
|
+
end
|
13
|
+
|
14
|
+
# This method optimizes the file writing process. If the local file already exists
|
15
|
+
# and matchs the remote filesize, it skips writing. Otherwise, it writes the file.
|
16
|
+
# <b>returns local_file_name = RAILS_ROOT/public/tmp/<parent_dir>/filename</b>
|
17
|
+
#
|
18
|
+
# 'filename' the remote filename
|
19
|
+
# 'filesize' the size of the remote file
|
20
|
+
# 'filedata' contains encoded file data
|
21
|
+
# 'parent_dir' the subdirectory where the file will be stored at
|
22
|
+
def do_write_file(filename, filesize, filedata, parent_dir)
|
23
|
+
# Downloaded files are put in the subdirectory matching each session-id in the /public/tmp directory.
|
24
|
+
# creates dir, if it does not exists
|
25
|
+
dir = "/tmp/#{parent_dir}"
|
26
|
+
# Creating the 'tmp' under the 'public' to hold downloaded files.
|
27
|
+
Dir.mkdir(RAILS_ROOT + "/public/tmp" ) unless File.directory?(RAILS_ROOT + "/public/tmp")
|
28
|
+
# Putting files in each user's sesseion directory.
|
29
|
+
Dir.mkdir(RAILS_ROOT + "/public" + dir ) unless File.directory?(RAILS_ROOT + "/public" + dir)
|
30
|
+
local_file_name = dir + "/#{filename}"
|
31
|
+
|
32
|
+
writefile_flag = true
|
33
|
+
#local_file_name = '/tmp/' + session_id + "-" + filename
|
34
|
+
|
35
|
+
if !File.exist?(RAILS_ROOT + "/public" + local_file_name)
|
36
|
+
# local file does not exist, write the local file
|
37
|
+
@logger.info("local file does not exist, write the local file.")
|
38
|
+
writefile_flag = true
|
39
|
+
elsif File.size(RAILS_ROOT + "/public" + local_file_name).to_i == filesize.to_i
|
40
|
+
# local file exists & file size matchs remote file sizem, skip writing the local local file
|
41
|
+
@logger.info("local file exists & file size matchs remote file sizem, skip writing the local local file.")
|
42
|
+
writefile_flag = false
|
43
|
+
else
|
44
|
+
@logger.info("Write the local file: " + RAILS_ROOT + "/public" + local_file_name)
|
45
|
+
writefile_flag = true
|
46
|
+
end
|
47
|
+
|
48
|
+
if writefile_flag
|
49
|
+
#Now, construct the file, 1st decode, 2nd, write it out
|
50
|
+
attachment = File.new(RAILS_ROOT + "/public" + local_file_name, 'w+b')
|
51
|
+
# Salesforce sends back an encoded data. It needs to be decoded into binary.
|
52
|
+
# otherwise, it starts off with "/9j/4AAQSkZJRgABA......."
|
53
|
+
decoded_data = Base64.decode64(filedata)
|
54
|
+
attachment.write(decoded_data) #=> 10
|
55
|
+
end
|
56
|
+
|
57
|
+
return local_file_name
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class Group < SfBase
|
25
|
+
set_table_name 'groups'
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class GroupMember < SfBase
|
25
|
+
#table name must match the Salesforce, or it does not work. This is a quirk of the ActiveSalesforce
|
26
|
+
set_table_name 'group_members'
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class Lead < SfBase
|
25
|
+
set_table_name 'leads'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class LeadFeed < SfBase
|
25
|
+
set_table_name 'lead_feeds'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class NewsFeed < SfBase
|
25
|
+
set_table_name 'news_feeds'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class Opportunity < SfBase
|
25
|
+
set_table_name 'opportunities'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class OpportunityFeed < SfBase
|
25
|
+
set_table_name 'opportunity_feeds'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class Organization < SfBase
|
25
|
+
set_table_name "organizations"
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class Product2 < SfBase
|
25
|
+
set_table_name 'product2s'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# See http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
|
23
|
+
# For complete list of Salesforce Standard Objects in V20.
|
24
|
+
class Product2Feed < SfBase
|
25
|
+
set_table_name 'product2_feeds'
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
=begin
|
2
|
+
asf-soap-adapter
|
3
|
+
Copyright 2010 Raymond Gao
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
# Salesforce package contains convenience classes for mapping Salesforce objects into
|
19
|
+
# ActiveRecord objects. The SfBase is the mother of all other objects. Additionally,
|
20
|
+
# SfUtitlity class provides several useful methods for manipulating SF objects.
|
21
|
+
module Salesforce
|
22
|
+
# SfBase is the mother of all other objects. It establishes the SOAP connection
|
23
|
+
# to Salesforce Server and turns it into A/R objects.
|
24
|
+
# Main methods are:
|
25
|
+
# 1. self.loging (username, password, security_token) -> static method
|
26
|
+
# 2. logout (session {as both single or hash}) -> instance method
|
27
|
+
# 3. self.swap_connction(connection) -> static method
|
28
|
+
# 4. self.query_by_sql(sql) -> static method
|
29
|
+
# For complete list of Salesforce Standard Objects in V20.
|
30
|
+
class SfBase < ActiveRecord::Base
|
31
|
+
self.abstract_class = true
|
32
|
+
|
33
|
+
# By default the 'salesforce-default-realm' in the 'database.yml' is the default
|
34
|
+
# connection, meaning all Salesforce objects will use that for the A/R connection.
|
35
|
+
# However, a web application is designed to support multiple users. Therefore,
|
36
|
+
# each user should have his/her own connection. To do that, the web-application
|
37
|
+
# should use the 'before-filter' to swap contexts/connections for each user.
|
38
|
+
# A good place to put that filter is in the 'application_controller.rb' file.
|
39
|
+
# The context can be changed for 1) a single SF class. Or 2) the root (SfObject),
|
40
|
+
# it will affect every other class inherited from the SfObject.
|
41
|
+
def self.login(user, pass, token)
|
42
|
+
params = {:adapter => "activesalesforce",
|
43
|
+
:url => "https://login.salesforce.com/services/Soap/u/20.0",
|
44
|
+
:username => user,
|
45
|
+
:password => pass + token
|
46
|
+
}
|
47
|
+
self.establish_connection(params)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Logs out of the Salesforce session
|
51
|
+
def logout(session_ids=Hash.new)
|
52
|
+
result = SfBase.connection.binding.invalidateSessions(session_ids)
|
53
|
+
if"invalidateSessionsResponse" == result.to_s
|
54
|
+
return true
|
55
|
+
else
|
56
|
+
return false
|
57
|
+
end
|
58
|
+
#result this.connection.binding.logout(Hash.new)
|
59
|
+
end
|
60
|
+
|
61
|
+
establish_connection "salesforce-default-realm"
|
62
|
+
|
63
|
+
set_table_name 'salesforce_sf_bases'
|
64
|
+
|
65
|
+
# Swaps the connection to Salesforce
|
66
|
+
def self.swap_connection (connection)
|
67
|
+
@@connection = connection
|
68
|
+
end
|
69
|
+
|
70
|
+
#Provides a method to directly call SQL via RFORCe
|
71
|
+
def self.query_by_sql(sql)
|
72
|
+
query_results = connection.binding.query :searchString => sql
|
73
|
+
return query_results.queryResponse.result.records unless query_results.queryResponse.result.size < 1
|
74
|
+
end
|
75
|
+
|
76
|
+
attr_reader :current_connection, :connection_owner, :current_connection_binding
|
77
|
+
|
78
|
+
# Return a read only version of the current_connection
|
79
|
+
def current_connection
|
80
|
+
connection
|
81
|
+
end
|
82
|
+
|
83
|
+
# Returns the owner's info of the current Salesforce WS connection
|
84
|
+
def connection_owner
|
85
|
+
connection.get_user_info
|
86
|
+
end
|
87
|
+
|
88
|
+
# Return a read-only version of the binding associated with the current connection
|
89
|
+
def current_connection_binding
|
90
|
+
connection.binding
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|