rdstation-ruby-client 0.0.1 → 0.0.2
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 +4 -4
- data/Gemfile.lock +32 -2
- data/README.md +23 -3
- data/Rakefile +6 -0
- data/lib/rdstation/client.rb +68 -5
- data/lib/rdstation/version.rb +1 -1
- data/rdstation-ruby-client.gemspec +5 -1
- data/spec/lib/rdstation-ruby-client_spec.rb +12 -0
- data/spec/spec_helper.rb +14 -0
- metadata +74 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 241aecdc02ed1fd18142980cce941833e5af996b
|
4
|
+
data.tar.gz: 35d829695bba940e158422db66ff58870cdf4dde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 580b88ecf5a5e1be41eeeac5555bd3223737e0998042ac6992d01f614e7e3b7e7700b440f89d08c8f7f6644a94344115724c6c4591f03e9483381aad2d6d267d
|
7
|
+
data.tar.gz: ddbcb332b035f78c97df8557271ff74b31b9a3be2b8ff605495913bcba8842b7d8328950eb241dc227514f55116fa39dcbcd1ab1ae6bcbd77d053998f1b23827
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rdstation-ruby-client (0.0.
|
4
|
+
rdstation-ruby-client (0.0.2)
|
5
5
|
httparty (~> 0.12.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
addressable (2.3.7)
|
11
|
+
ansi (1.5.0)
|
12
|
+
crack (0.4.2)
|
13
|
+
safe_yaml (~> 1.0.0)
|
14
|
+
diff-lcs (1.2.5)
|
10
15
|
httparty (0.12.0)
|
11
16
|
json (~> 1.8)
|
12
17
|
multi_xml (>= 0.5.2)
|
13
|
-
json (1.8.
|
18
|
+
json (1.8.2)
|
19
|
+
minitest (4.7.5)
|
14
20
|
multi_xml (0.5.5)
|
15
21
|
rake (10.1.0)
|
22
|
+
rspec (3.1.0)
|
23
|
+
rspec-core (~> 3.1.0)
|
24
|
+
rspec-expectations (~> 3.1.0)
|
25
|
+
rspec-mocks (~> 3.1.0)
|
26
|
+
rspec-core (3.1.7)
|
27
|
+
rspec-support (~> 3.1.0)
|
28
|
+
rspec-expectations (3.1.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.1.0)
|
31
|
+
rspec-mocks (3.1.3)
|
32
|
+
rspec-support (~> 3.1.0)
|
33
|
+
rspec-support (3.1.2)
|
34
|
+
safe_yaml (1.0.4)
|
35
|
+
turn (0.9.7)
|
36
|
+
ansi
|
37
|
+
minitest (~> 4)
|
38
|
+
vcr (2.9.3)
|
39
|
+
webmock (1.20.4)
|
40
|
+
addressable (>= 2.3.6)
|
41
|
+
crack (>= 0.3.2)
|
16
42
|
|
17
43
|
PLATFORMS
|
18
44
|
ruby
|
@@ -21,3 +47,7 @@ DEPENDENCIES
|
|
21
47
|
bundler (~> 1.3)
|
22
48
|
rake
|
23
49
|
rdstation-ruby-client!
|
50
|
+
rspec
|
51
|
+
turn
|
52
|
+
vcr
|
53
|
+
webmock
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ TODO: Write a gem description
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'rdstation-ruby'
|
9
|
+
gem 'rdstation-ruby-client'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -14,11 +14,22 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install rdstation-ruby
|
17
|
+
$ gem install rdstation-ruby-client
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
### Creating a Lead
|
22
|
+
rdstation_client = RDStation::Client.new('rdstation_token', 'auth_token')
|
23
|
+
rdstation_client.create_lead({:email => 'joe@foo.bar', :nome => 'Joe Foo', :empresa => 'A random Company', :cargo => 'Developer', identificador: 'nome_da_conversao'})
|
24
|
+
|
25
|
+
### Changing a Lead
|
26
|
+
rdstation_client = RDStation::Client.new('rdstation_token', 'auth_token')
|
27
|
+
rdstation_client.change_lead('joe@foo.bar', {:lifecycle_stage => 1, :opportunity => true})
|
28
|
+
|
29
|
+
### Change Lead Status
|
30
|
+
rdstation_client = RDStation::Client.new('rdstation_token', 'auth_token')
|
31
|
+
rdstation_client.change_lead_status(email: 'joe@foo.bar', status: 'won', value: 999)
|
32
|
+
|
22
33
|
|
23
34
|
## Contributing
|
24
35
|
|
@@ -27,3 +38,12 @@ TODO: Write usage instructions here
|
|
27
38
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
39
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
40
|
5. Create new Pull Request
|
41
|
+
|
42
|
+
## Reference
|
43
|
+
|
44
|
+
You can check out RDstation's integration (pt-BR) documentation here:
|
45
|
+
|
46
|
+
- [Pure HTML](https://gist.github.com/pedrobachiega/3298970);
|
47
|
+
- [Wordpress & Contact Form 7](https://gist.github.com/pedrobachiega/3277536);
|
48
|
+
- [PHP](https://gist.github.com/pedrobachiega/3248293);
|
49
|
+
- [HTML+Ajax with jQuery](https://gist.github.com/pedrobachiega/3248013);
|
data/Rakefile
CHANGED
data/lib/rdstation/client.rb
CHANGED
@@ -1,15 +1,78 @@
|
|
1
1
|
module RDStation
|
2
|
+
#
|
3
|
+
# Mais informações em https://www.rdstation.com.br/docs/api
|
4
|
+
#
|
2
5
|
class Client
|
3
6
|
include HTTParty
|
4
|
-
base_uri "https://www.rdstation.com.br"
|
5
7
|
|
6
|
-
def initialize(
|
7
|
-
@
|
8
|
+
def initialize(rdstation_token, auth_token, identifier="integração")
|
9
|
+
@identificador = identifier
|
10
|
+
@rdstation_token = rdstation_token
|
11
|
+
@auth_token = auth_token
|
8
12
|
end
|
9
13
|
|
14
|
+
#
|
15
|
+
# A hash de lead pode conter os parametros
|
16
|
+
# (requerido) :identificador
|
17
|
+
# (requerido) :email
|
18
|
+
# :nome
|
19
|
+
# :empresa
|
20
|
+
# :cargo
|
21
|
+
# :telefone
|
22
|
+
# :celular
|
23
|
+
# :website
|
24
|
+
# :twitter
|
25
|
+
# :c_utmz
|
26
|
+
#
|
10
27
|
def create_lead(lead_hash)
|
11
|
-
lead_hash =
|
12
|
-
|
28
|
+
lead_hash = rdstation_token_hash.merge(lead_hash)
|
29
|
+
lead_hash = lead_hash.merge(identifier_hash) unless lead_hash.has_key?(:identificador)
|
30
|
+
post_with_body("/conversions", {:body => lead_hash})
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# param lead:
|
35
|
+
# id ou email do Lead a ser alterado
|
36
|
+
#
|
37
|
+
# param lead_hash:
|
38
|
+
# Hash contendo:
|
39
|
+
# :lifecycle_stage
|
40
|
+
# 0 - Lead; 1 - Lead Qualificado; 2 - Cliente
|
41
|
+
# :opportunity
|
42
|
+
# true ou false
|
43
|
+
#
|
44
|
+
def change_lead(lead, lead_hash)
|
45
|
+
lead_hash = auth_token_hash.merge({:lead => lead_hash})
|
46
|
+
put_with_body("/leads/#{lead}", :body => lead_hash.to_json, :headers => {'Content-Type' => 'application/json'})
|
47
|
+
end
|
48
|
+
|
49
|
+
def change_lead_status(lead_hash)
|
50
|
+
post_with_body("/services/#{@auth_token}/generic", :body => lead_hash )
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
def base_url
|
55
|
+
"https://www.rdstation.com.br/api/1.2"
|
56
|
+
end
|
57
|
+
|
58
|
+
def rdstation_token_hash
|
59
|
+
{ :token_rdstation => @rdstation_token }
|
60
|
+
end
|
61
|
+
|
62
|
+
def auth_token_hash
|
63
|
+
{ :auth_token => @auth_token }
|
64
|
+
end
|
65
|
+
|
66
|
+
def identifier_hash
|
67
|
+
{ :identificador => @identificador }
|
68
|
+
end
|
69
|
+
|
70
|
+
def post_with_body(path, opts)
|
71
|
+
self.class.post("#{base_url}#{path}", opts)
|
72
|
+
end
|
73
|
+
|
74
|
+
def put_with_body(path, opts)
|
75
|
+
self.class.put("#{base_url}#{path}", opts)
|
13
76
|
end
|
14
77
|
end
|
15
78
|
end
|
data/lib/rdstation/version.rb
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["paulo.casaretto@resultadosdigitais.com.br"]
|
11
11
|
spec.description = "Ruby API wrapper for RD Station"
|
12
12
|
spec.summary = "Ruby API wrapper for RD Station"
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "http://resultadosdigitais.com.br"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -20,6 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency 'vcr'
|
25
|
+
spec.add_development_dependency 'webmock'
|
26
|
+
spec.add_development_dependency 'turn'
|
23
27
|
|
24
28
|
spec.add_dependency "httparty", "~> 0.12.0"
|
25
29
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rdstation-ruby-client'
|
2
|
+
require 'vcr'
|
3
|
+
|
4
|
+
VCR.configure do |c|
|
5
|
+
c.cassette_library_dir = 'spec/cassettes'
|
6
|
+
c.hook_into :webmock
|
7
|
+
c.configure_rspec_metadata!
|
8
|
+
end
|
9
|
+
|
10
|
+
# RSpec.configure do |c|
|
11
|
+
# # so we can use :vcr rather than :vcr => true;
|
12
|
+
# # in RSpec 3 this will no longer be necessary.
|
13
|
+
# c.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
+
# end
|
metadata
CHANGED
@@ -1,55 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdstation-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo L F Casaretto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
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: webmock
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: turn
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
39
95
|
- !ruby/object:Gem::Version
|
40
96
|
version: '0'
|
41
97
|
- !ruby/object:Gem::Dependency
|
42
98
|
name: httparty
|
43
99
|
requirement: !ruby/object:Gem::Requirement
|
44
100
|
requirements:
|
45
|
-
- - ~>
|
101
|
+
- - "~>"
|
46
102
|
- !ruby/object:Gem::Version
|
47
103
|
version: 0.12.0
|
48
104
|
type: :runtime
|
49
105
|
prerelease: false
|
50
106
|
version_requirements: !ruby/object:Gem::Requirement
|
51
107
|
requirements:
|
52
|
-
- - ~>
|
108
|
+
- - "~>"
|
53
109
|
- !ruby/object:Gem::Version
|
54
110
|
version: 0.12.0
|
55
111
|
description: Ruby API wrapper for RD Station
|
@@ -59,7 +115,7 @@ executables: []
|
|
59
115
|
extensions: []
|
60
116
|
extra_rdoc_files: []
|
61
117
|
files:
|
62
|
-
- .gitignore
|
118
|
+
- ".gitignore"
|
63
119
|
- Gemfile
|
64
120
|
- Gemfile.lock
|
65
121
|
- LICENSE
|
@@ -69,7 +125,9 @@ files:
|
|
69
125
|
- lib/rdstation/client.rb
|
70
126
|
- lib/rdstation/version.rb
|
71
127
|
- rdstation-ruby-client.gemspec
|
72
|
-
|
128
|
+
- spec/lib/rdstation-ruby-client_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
homepage: http://resultadosdigitais.com.br
|
73
131
|
licenses:
|
74
132
|
- MIT
|
75
133
|
metadata: {}
|
@@ -79,18 +137,20 @@ require_paths:
|
|
79
137
|
- lib
|
80
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
139
|
requirements:
|
82
|
-
- -
|
140
|
+
- - ">="
|
83
141
|
- !ruby/object:Gem::Version
|
84
142
|
version: '0'
|
85
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
144
|
requirements:
|
87
|
-
- -
|
145
|
+
- - ">="
|
88
146
|
- !ruby/object:Gem::Version
|
89
147
|
version: '0'
|
90
148
|
requirements: []
|
91
149
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.2.2
|
93
151
|
signing_key:
|
94
152
|
specification_version: 4
|
95
153
|
summary: Ruby API wrapper for RD Station
|
96
|
-
test_files:
|
154
|
+
test_files:
|
155
|
+
- spec/lib/rdstation-ruby-client_spec.rb
|
156
|
+
- spec/spec_helper.rb
|