salesforce_connector_light 0.0.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/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.rdoc +58 -0
- data/Rakefile +1 -0
- data/lib/salesforce_connector.rb +12 -0
- data/lib/salesforce_connector/account.rb +9 -0
- data/lib/salesforce_connector/contact.rb +9 -0
- data/lib/salesforce_connector/lead.rb +9 -0
- data/lib/salesforce_connector/oauth_object.rb +35 -0
- data/lib/salesforce_connector/opportunity.rb +9 -0
- data/lib/salesforce_connector/profile.rb +18 -0
- data/lib/salesforce_connector/user.rb +17 -0
- data/lib/salesforce_connector/version.rb +3 -0
- data/lib/salesforce_connector/visitor.rb +9 -0
- data/salesforce_connector_light.gemspec +24 -0
- metadata +92 -0
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= Salesforce_connector
|
2
|
+
|
3
|
+
Rails gem to connect an application to Salesforce accounts.
|
4
|
+
|
5
|
+
== Install in your Gemfile
|
6
|
+
|
7
|
+
gem 'salesforce_connector_light'
|
8
|
+
|
9
|
+
== Dependencies
|
10
|
+
|
11
|
+
Salesforce Connector is based on HTTParty to access Salesforce API using a OAuth2 tokens.
|
12
|
+
|
13
|
+
== Usage
|
14
|
+
|
15
|
+
|
16
|
+
Configure the Salesforce remote server URL and version
|
17
|
+
ENV['sfdc_token'] = "dkfjslkdfjsk;jslkjcskldjclkdjkwrlj;"
|
18
|
+
ENV['sfdc_instance_url'] = "https://eu1.salesforce.com"
|
19
|
+
ENV['sfdc_api_version'] = "24.0"
|
20
|
+
|
21
|
+
If you use Omniauth those
|
22
|
+
|
23
|
+
ENV['sfdc_token'] = auth_hash["credentials"]['token']
|
24
|
+
ENV['sfdc_instance_url'] = auth_hash["credentials"]['instance_url']
|
25
|
+
ENV['sfdc_api_version'] = '24.0'
|
26
|
+
|
27
|
+
Then for example you can retrieve your Current User details and Profile
|
28
|
+
user = SalesforceConnector::User.find(<user_id>)
|
29
|
+
profile = SalesforceConnector::Profile.find(u['ProfileId'])
|
30
|
+
|
31
|
+
== Note
|
32
|
+
|
33
|
+
Salesforce OAuth only implement https authentication.
|
34
|
+
Be sure that your server (requester) is also running behing https.
|
35
|
+
|
36
|
+
== License
|
37
|
+
|
38
|
+
Copyright (c) 2011 Vzmind
|
39
|
+
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
41
|
+
a copy of this software and associated documentation files (the
|
42
|
+
"Software"), to deal in the Software without restriction, including
|
43
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
44
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
45
|
+
permit persons to whom the Software is furnished to do so, subject to
|
46
|
+
the following conditions:
|
47
|
+
|
48
|
+
The above copyright notice and this permission notice shall be
|
49
|
+
included in all copies or substantial portions of the Software.
|
50
|
+
|
51
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
52
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
53
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
54
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
55
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
56
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
57
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
58
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "salesforce_connector/version"
|
2
|
+
require "salesforce_connector/oauth_object"
|
3
|
+
require "salesforce_connector/account"
|
4
|
+
require "salesforce_connector/lead"
|
5
|
+
require "salesforce_connector/contact"
|
6
|
+
require "salesforce_connector/opportunity"
|
7
|
+
require "salesforce_connector/user"
|
8
|
+
require "salesforce_connector/profile"
|
9
|
+
|
10
|
+
module SalesforceConnector
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module SalesforceConnector
|
4
|
+
class OauthObject
|
5
|
+
include HTTParty
|
6
|
+
format :json
|
7
|
+
|
8
|
+
def self.set_headers
|
9
|
+
headers 'Authorization' => "OAuth #{ENV['sfdc_token']}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.root_url
|
13
|
+
@root_url = ENV['sfdc_instance_url']+"/services/data/v"+ENV['sfdc_api_version']
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.query(str)
|
17
|
+
self.set_headers
|
18
|
+
result = get(self.root_url+"/query/?q=#{CGI::escape(str)}")
|
19
|
+
return result.parsed_response["records"] || []
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.sobjects
|
23
|
+
self.set_headers
|
24
|
+
result = get(self.root_url+"/sobjects")
|
25
|
+
return result.parsed_response["sobjects"] || []
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.describe_sobject(str)
|
29
|
+
self.set_headers
|
30
|
+
result = get(self.root_url+"/sobjects/#{str.capitalize}")
|
31
|
+
return result.parsed_response["objectDescribe"] || []
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SalesforceConnector
|
2
|
+
|
3
|
+
class Profile < OauthObject
|
4
|
+
def self.get_first_hundred
|
5
|
+
Profile.query('SELECT Name, Id from Profile LIMIT 100')
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find(str)
|
9
|
+
self.set_headers
|
10
|
+
result = get(self.root_url+"/sobjects/Profile/#{CGI::escape(str)}")
|
11
|
+
return result.parsed_response || []
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SalesforceConnector
|
2
|
+
|
3
|
+
class User < OauthObject
|
4
|
+
def self.get_first_hundred
|
5
|
+
User.query('SELECT Name, Id from User LIMIT 100')
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find(str)
|
9
|
+
self.set_headers
|
10
|
+
result = get(self.root_url+"/sobjects/User/#{CGI::escape(str)}")
|
11
|
+
return result.parsed_response || []
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "salesforce_connector/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "salesforce_connector_light"
|
7
|
+
s.version = SalesforceConnector::VERSION
|
8
|
+
s.authors = ["Vzmind"]
|
9
|
+
s.email = ["vzmind@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/vzmind"
|
11
|
+
s.summary = "Connect your Rails 3 app to a Salesforce account using OAuth token"
|
12
|
+
s.description = "Use a previously acquired token to easily access the REST API with httparty"
|
13
|
+
|
14
|
+
s.rubyforge_project = "salesforce_connector"
|
15
|
+
|
16
|
+
s.required_rubygems_version = ">= 1.3.6"
|
17
|
+
|
18
|
+
s.add_dependency("httparty","~> 0.8.3")
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: salesforce_connector_light
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Vzmind
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-07-13 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: httparty
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 8
|
30
|
+
- 3
|
31
|
+
version: 0.8.3
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
description: Use a previously acquired token to easily access the REST API with httparty
|
35
|
+
email:
|
36
|
+
- vzmind@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- README.rdoc
|
47
|
+
- Rakefile
|
48
|
+
- lib/salesforce_connector.rb
|
49
|
+
- lib/salesforce_connector/account.rb
|
50
|
+
- lib/salesforce_connector/contact.rb
|
51
|
+
- lib/salesforce_connector/lead.rb
|
52
|
+
- lib/salesforce_connector/oauth_object.rb
|
53
|
+
- lib/salesforce_connector/opportunity.rb
|
54
|
+
- lib/salesforce_connector/profile.rb
|
55
|
+
- lib/salesforce_connector/user.rb
|
56
|
+
- lib/salesforce_connector/version.rb
|
57
|
+
- lib/salesforce_connector/visitor.rb
|
58
|
+
- salesforce_connector_light.gemspec
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/vzmind
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 3
|
82
|
+
- 6
|
83
|
+
version: 1.3.6
|
84
|
+
requirements: []
|
85
|
+
|
86
|
+
rubyforge_project: salesforce_connector
|
87
|
+
rubygems_version: 1.3.6
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Connect your Rails 3 app to a Salesforce account using OAuth token
|
91
|
+
test_files: []
|
92
|
+
|