lahar 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6b1fae32e4358b3f44aff6b748f824aa71dd3f7e
4
+ data.tar.gz: 36b90363d0570d12ca52b3804ac7ce4b43721be9
5
+ SHA512:
6
+ metadata.gz: 3afddb799530063c61a579a662e10c5281c3d795f0ae2d2914969e0a578aa1bda354875a7bc783792f51f8b661c7cd5a24a96999126b32f3816498e983b2a8cb
7
+ data.tar.gz: b882a3e8e4b698476412da4a012afa2c4c08b1218f78c04e2bb264bc10d35f19811f504494c06f674ca3eebf6a6ef15f5a008b8ed4314367c36b2a215108af7c
@@ -0,0 +1,10 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ tmp
6
+
7
+ # YARD artifacts
8
+ .yardoc
9
+ _yardoc
10
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iugu-ruby.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lahar (0.1.0)
5
+ httparty (~> 0.12)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ httparty (0.13.7)
11
+ json (~> 1.8)
12
+ multi_xml (>= 0.5.2)
13
+ json (1.8.3)
14
+ multi_xml (0.5.5)
15
+ rake (10.4.2)
16
+
17
+ PLATFORMS
18
+ ruby
19
+
20
+ DEPENDENCIES
21
+ bundler (~> 1.9)
22
+ lahar!
23
+ rake (~> 10.0)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Daniel Docki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Lahar::Ruby
2
+
3
+ Ruby API wrapper for Lahar
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'lahar'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install lahar
18
+
19
+ ## Usage
20
+
21
+ ### Creating a Lead
22
+ lead = Lahar::Client.new('lahar_token')
23
+ lead.create_lead({ :email => 'foo@bar.com', :nome => 'Foo Bar', nome_formulario: 'nome_da_conversao' })
24
+
25
+ ### Changing a Lead
26
+ lead = Lahar::Client.new('lahar_token')
27
+ lead.change_lead({ :email => 'foo@bar.com', :nome => 'Bar Foo', nome_formulario: 'nome_da_conversao' })
28
+
29
+ ### Change Lead Status
30
+ lead = Lahar::Client.new('lahar_token')
31
+ lead.change_lead_status({ :email => 'foo@bar.com', :estagio_lead => '2' })
32
+
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lahar/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lahar"
8
+ spec.version = Lahar::VERSION
9
+ spec.authors = ["Daniel Docki"]
10
+ spec.email = ["daniel.docki@gmail.com"]
11
+
12
+ spec.summary = "Ruby API wrapper for Lahar"
13
+ spec.description = "Ruby API wrapper for Lahar"
14
+ spec.homepage = "http://www.lahar.com.br"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "httparty", "~> 0.12"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.9"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1,3 @@
1
+ require "httparty"
2
+ require_relative "lahar/version"
3
+ require_relative "lahar/client"
@@ -0,0 +1,81 @@
1
+ module Lahar
2
+ #
3
+ # Mais informações em http://ajuda.lahar.com.br/integracoes
4
+ #
5
+ class Client
6
+ include HTTParty
7
+
8
+ def initialize(token, event="integration")
9
+ @event = event
10
+ @token = token
11
+ end
12
+
13
+ #
14
+ # A hash do Lead pode conter os seguintes parâmetros:
15
+ # (obrigatório) :email_contato
16
+ # (obrigatório) :nome_formulario (use para converter em um evento)
17
+ # :nome_contato
18
+ # :sobrenome
19
+ # :nome_empresa
20
+ # :cargo
21
+ # :site_empresa
22
+ # :site_contato
23
+ # :setor
24
+ # :tel_fixo
25
+ # :tel_empresa
26
+ # :email_empresa
27
+ # :tel_celular
28
+ # :anotacoes
29
+ # :tags
30
+ # :twitter
31
+ # :facebook
32
+ # :twitter_empresa
33
+ # :facebook_empresa
34
+ # :linkedin
35
+ # :cidade
36
+ # :estado
37
+ # :endereco_empresa
38
+ # Caso algum parâmetro não seja identificado como campo padrão ou como
39
+ # campo personalizado, este parâmetro desconhecido será ignorado.
40
+
41
+ def create_lead(lead_hash)
42
+ lead_hash = token_hash.merge(lead_hash)
43
+ lead_hash = lead_hash.merge(event_hash) unless lead_hash.has_key?(:nome_formulario)
44
+ post_with_body("/conversions", { :body => lead_hash })
45
+ end
46
+ alias_method :change_lead, :create_lead
47
+
48
+
49
+ # param lead_hash:
50
+ # Hash contendo:
51
+ # :estagio_lead
52
+ # 1 - Lead; 2 - Oportunidade; 3 - Cliente
53
+
54
+ def change_lead_status(lead_hash)
55
+ lead_hash = token_hash.merge(lead_hash)
56
+ put_with_body("/leads", :body => lead_hash.to_json, :headers => { 'Content-Type' => 'application/json' })
57
+ end
58
+
59
+ private
60
+
61
+ def base_url
62
+ "http://app.lahar.com.br/api"
63
+ end
64
+
65
+ def token_hash
66
+ { :token_api_lahar => @token }
67
+ end
68
+
69
+ def event_hash
70
+ { :nome_formulario => @event }
71
+ end
72
+
73
+ def post_with_body(path, opts)
74
+ self.class.post("#{base_url}#{path}", opts)
75
+ end
76
+
77
+ def put_with_body(path, opts)
78
+ self.class.put("#{base_url}#{path}", opts)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,3 @@
1
+ module Lahar
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Lahar do
4
+ it "must be defined" do
5
+ Lahar::VERSION.wont_be_nil
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require File.expand_path('../../lib/iugu.rb', __FILE__)
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lahar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Docki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.12'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Ruby API wrapper for Lahar
56
+ email:
57
+ - daniel.docki@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - lahar.gemspec
69
+ - lib/lahar.rb
70
+ - lib/lahar/client.rb
71
+ - lib/lahar/version.rb
72
+ - test/lib/version_test.rb
73
+ - test/test_helper.rb
74
+ homepage: http://www.lahar.com.br
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.5
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Ruby API wrapper for Lahar
98
+ test_files:
99
+ - test/lib/version_test.rb
100
+ - test/test_helper.rb