sf_integrator 0.0.9
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/lib/generators/sf_integrator/install_generator.rb +9 -0
- data/lib/generators/sf_integrator/templates/sf_integrator.rb +6 -0
- data/lib/sf_integrator/configuration.rb +12 -0
- data/lib/sf_integrator/engine.rb +4 -0
- data/lib/sf_integrator/integrator.rb +19 -0
- data/lib/sf_integrator/lead.rb +27 -0
- data/lib/sf_integrator/version.rb +3 -0
- data/lib/sf_integrator.rb +9 -0
- data/sf_integrator.gemspec +27 -0
- data/spec/configuration_spec.rb +27 -0
- data/spec/integrator_spec.rb +22 -0
- data/spec/lead_spec.rb +80 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/version_spec.rb +6 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 098462d10d0ed108233318ffbae543a560d0f5dd
|
4
|
+
data.tar.gz: f4a93f4091750d46949f1153efbe3b95096f0240
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b5ac75954787d51e035683ea6c2a7919aea9cb946b6e2629b738bfc19d85d689214ba0e3b9af8407348b7824147a473ac73068e2568c4412814cc4ab4db7c37
|
7
|
+
data.tar.gz: cecf0cae644586d15efc66e240936c16b978df5d6dd032b30286fdf5531454c8933333079128acd87d60ba9e893ad174faf655d5bc8e38fa25ff981c59d4f7f0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Luiz Cezer
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# SfIntegrator
|
2
|
+
|
3
|
+
Simple gem to integration with SalesForce Leads.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sf_integrator'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sf_integrator
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Run the generator:
|
22
|
+
|
23
|
+
`rails g sf_integrator:install`
|
24
|
+
|
25
|
+
This command will copy a template file to `app/config/initializers/sf_integrator.rb`, in this file you need to write your credentials from salesforce
|
26
|
+
|
27
|
+
After that you create a simples ruby class that inherits from `SfIntegrator::Lead`:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
class Lead < SfIntegrator::Lead
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Now in your controller you can use like a `ActiveRecord` model, the `SfIntegrator::Lead` include `ActiveModel::Validations`.
|
35
|
+
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it ( http://github.com/<my-github-username>/sf_integrator/fork )
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,6 @@
|
|
1
|
+
SfIntegrator::Integrator.configure do |config|
|
2
|
+
config.username = 'YOUR_EMAIL_FROM_SALESFORCE_ACCOUNT'
|
3
|
+
config.password = 'YOUR_PASSWORD_FROM_SALESFORCE+YOUR_SECURITY_TOKEN'
|
4
|
+
config.client_id = 'YOUR_APP_CUSTOMER_KEY'
|
5
|
+
config.client_secret = 'YOUR_APP_CUSTOMER_SECRET'
|
6
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module SfIntegrator
|
4
|
+
class Integrator
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
attr_accessor :configs
|
8
|
+
|
9
|
+
def self.configure
|
10
|
+
instance.configs = SfIntegrator::Configuration.new
|
11
|
+
yield instance.configs
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configs
|
15
|
+
instance.configs
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
|
3
|
+
module SfIntegrator
|
4
|
+
class Lead
|
5
|
+
include ActiveModel::Validations
|
6
|
+
|
7
|
+
validates :first_name, :last_name, :email, :company, :job_title, :phone, :website, presence: true
|
8
|
+
|
9
|
+
attr_accessor :client, :first_name, :last_name, :email, :company, :job_title, :phone, :website
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@client = Restforce.new(SfIntegrator::Integrator.configs.to_hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
params = build_params
|
17
|
+
client.create('Lead', params)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def build_params
|
23
|
+
{ FirstName: first_name, LastName: last_name, Email: email, Company: company, Title: job_title, Phone: phone, Website: website }
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sf_integrator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sf_integrator"
|
8
|
+
spec.version = SfIntegrator::VERSION
|
9
|
+
spec.authors = ["Luiz Cezer"]
|
10
|
+
spec.email = ["lccezinha@gmail.com"]
|
11
|
+
spec.summary = %q{ Integration with Sales Force leads. }
|
12
|
+
spec.description = %q{ Integration with Sales Force leads. }
|
13
|
+
spec.homepage = "http://github.com/lccezinha/sf_integrator"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'restforce', '1.4.3'
|
22
|
+
spec.add_runtime_dependency "activemodel"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../lib/sf_integrator/configuration.rb'
|
3
|
+
|
4
|
+
describe SfIntegrator::Configuration do
|
5
|
+
context 'accessors' do
|
6
|
+
[:username, :password, :client_id, :client_secret].each do |field|
|
7
|
+
context field.to_s do
|
8
|
+
it { expect(subject).to respond_to field }
|
9
|
+
it { expect(subject).to respond_to "#{field}=" }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context '#to_hash' do
|
15
|
+
subject { described_class.new }
|
16
|
+
|
17
|
+
it 'match values' do
|
18
|
+
subject.username = 'Luiz'
|
19
|
+
subject.password = '123123123'
|
20
|
+
subject.client_id = '123123123'
|
21
|
+
subject.client_secret = '123123123'
|
22
|
+
|
23
|
+
expected = { username: 'Luiz', password: '123123123', client_id: '123123123', client_secret: '123123123' }
|
24
|
+
expect(subject.to_hash).to match(expected)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../lib/sf_integrator/integrator.rb'
|
3
|
+
|
4
|
+
describe SfIntegrator::Integrator do
|
5
|
+
subject { described_class }
|
6
|
+
|
7
|
+
context 'valid configs' do
|
8
|
+
before do
|
9
|
+
SfIntegrator::Integrator.configure do |config|
|
10
|
+
config.username = 'lccezinha@gmail.com'
|
11
|
+
config.password = 'batata880AvOSHd43zql8ZIMJ1emQNjkt'
|
12
|
+
config.client_id = '3MVG9xOCXq4ID1uFbfzoMHMM0bGJfUgjThmhEmajKOh75cvDlJn.E3g5FYx2R45vTpFRJfiPDfda5o.td8HQ2'
|
13
|
+
config.client_secret = '3340784302062558262'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it { expect(subject.instance.configs.username).to eql('lccezinha@gmail.com') }
|
18
|
+
it { expect(subject.instance.configs.password).to eql('batata880AvOSHd43zql8ZIMJ1emQNjkt') }
|
19
|
+
it { expect(subject.instance.configs.client_id).to eql('3MVG9xOCXq4ID1uFbfzoMHMM0bGJfUgjThmhEmajKOh75cvDlJn.E3g5FYx2R45vTpFRJfiPDfda5o.td8HQ2') }
|
20
|
+
it { expect(subject.instance.configs.client_secret).to eql('3340784302062558262') }
|
21
|
+
end
|
22
|
+
end
|
data/spec/lead_spec.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../lib/sf_integrator/lead.rb'
|
3
|
+
|
4
|
+
describe SfIntegrator::Lead do
|
5
|
+
subject(:lead) { described_class.new }
|
6
|
+
|
7
|
+
context 'be instance of SfIntegrator::Lead' do
|
8
|
+
it { expect(lead).to be_an_instance_of(SfIntegrator::Lead) }
|
9
|
+
end
|
10
|
+
|
11
|
+
it { expect(described_class.ancestors).to include(ActiveModel::Validations) }
|
12
|
+
|
13
|
+
context 'accessors' do
|
14
|
+
[:client, :first_name, :last_name, :email, :company, :job_title, :phone, :website].each do |attribute|
|
15
|
+
context attribute.to_s do
|
16
|
+
it { expect(lead).to respond_to attribute }
|
17
|
+
it { expect(lead).to respond_to "#{attribute}=" }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'validations' do
|
23
|
+
context 'presence_of' do
|
24
|
+
[:first_name, :last_name, :email, :company, :job_title, :phone, :website].each do |attribute|
|
25
|
+
it attribute.to_s do
|
26
|
+
lead.send("#{attribute}=", '')
|
27
|
+
expect(lead).not_to be_valid
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it { expect(lead).to respond_to(:create) }
|
34
|
+
|
35
|
+
it 'match values' do
|
36
|
+
lead.first_name = 'Luiz'
|
37
|
+
lead.last_name = 'Cezer'
|
38
|
+
lead.email = 'lccezinha@gmail.com'
|
39
|
+
lead.company = 'Google'
|
40
|
+
lead.job_title = 'Rails Dev'
|
41
|
+
lead.phone = '5555555'
|
42
|
+
lead.website = 'github.com/lccezinha'
|
43
|
+
|
44
|
+
expect(lead.first_name).to eql('Luiz')
|
45
|
+
expect(lead.last_name).to eql('Cezer')
|
46
|
+
expect(lead.email).to eql('lccezinha@gmail.com')
|
47
|
+
expect(lead.company).to eql('Google')
|
48
|
+
expect(lead.job_title).to eql('Rails Dev')
|
49
|
+
expect(lead.phone).to eql('5555555')
|
50
|
+
expect(lead.website).to eql('github.com/lccezinha')
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'create new lead' do
|
54
|
+
context 'when success' do
|
55
|
+
it do
|
56
|
+
lead.first_name = 'Cezer'
|
57
|
+
lead.last_name = 'Filho'
|
58
|
+
lead.email = 'luiz.cezer@gmail.com'
|
59
|
+
lead.company = 'Google'
|
60
|
+
lead.job_title = 'Rails Dev'
|
61
|
+
lead.phone = '5555555'
|
62
|
+
lead.website = 'http://github.com/lccezinha'
|
63
|
+
|
64
|
+
result = lead.create
|
65
|
+
|
66
|
+
expect(result).to match(/[a-z]|[A-Z]|[0-9]/)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when fail' do
|
71
|
+
it do
|
72
|
+
lead.first_name = 'Luiz'
|
73
|
+
|
74
|
+
result = lead.create
|
75
|
+
|
76
|
+
expect(result).to eq(false)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sf_integrator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.9
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luiz Cezer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: restforce
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.4.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemodel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: ' Integration with Sales Force leads. '
|
84
|
+
email:
|
85
|
+
- lccezinha@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/generators/sf_integrator/install_generator.rb
|
97
|
+
- lib/generators/sf_integrator/templates/sf_integrator.rb
|
98
|
+
- lib/sf_integrator.rb
|
99
|
+
- lib/sf_integrator/configuration.rb
|
100
|
+
- lib/sf_integrator/engine.rb
|
101
|
+
- lib/sf_integrator/integrator.rb
|
102
|
+
- lib/sf_integrator/lead.rb
|
103
|
+
- lib/sf_integrator/version.rb
|
104
|
+
- sf_integrator.gemspec
|
105
|
+
- spec/configuration_spec.rb
|
106
|
+
- spec/integrator_spec.rb
|
107
|
+
- spec/lead_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
- spec/version_spec.rb
|
110
|
+
homepage: http://github.com/lccezinha/sf_integrator
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.0.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Integration with Sales Force leads.
|
134
|
+
test_files:
|
135
|
+
- spec/configuration_spec.rb
|
136
|
+
- spec/integrator_spec.rb
|
137
|
+
- spec/lead_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
- spec/version_spec.rb
|