leadsquared 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4457c15176528bf134ce7a7508d6d9c1aa5aa314
4
+ data.tar.gz: a6f8e10a837e2700a48fd7d0fa2724942a3c6b5f
5
+ SHA512:
6
+ metadata.gz: f236634bb8f198e5a1596f0dff7952fa77afb384e9292686ddef94a1b7e042d49bdfeb4a9fd25fcb024d67e915c596bba5b99dcb942ad7e009281b1ed8c6930a
7
+ data.tar.gz: 7613afb63bc28d440e1e673a96463daaff4a650b6386d3cb88bacbd3e4a8c2b43c3c19202bf7065c05c8fc38cf628a05caa28e5826a33d3edd466d435e438d64
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ - 2.2.1
5
+ - 2.2.2
6
+ - 2.2.3
7
+
8
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'activesupport'
4
+ gem 'faraday'
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development, :test do
9
+ gem "rspec"
10
+ gem "rdoc"
11
+ gem "bundler"
12
+ gem "jeweler", "~> 2.0.1"
13
+ gem "simplecov"
14
+ gem "pry-byebug"
15
+ gem "webmock"
16
+ gem "timecop"
17
+ gem "codeclimate-test-reporter", require: nil
18
+ end
@@ -0,0 +1,120 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (4.2.4)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
10
+ addressable (2.3.8)
11
+ builder (3.2.2)
12
+ byebug (5.0.0)
13
+ columnize (= 0.9.0)
14
+ codeclimate-test-reporter (0.4.8)
15
+ simplecov (>= 0.7.1, < 1.0.0)
16
+ coderay (1.1.0)
17
+ columnize (0.9.0)
18
+ crack (0.4.2)
19
+ safe_yaml (~> 1.0.0)
20
+ descendants_tracker (0.0.4)
21
+ thread_safe (~> 0.3, >= 0.3.1)
22
+ diff-lcs (1.2.5)
23
+ docile (1.1.5)
24
+ faraday (0.9.2)
25
+ multipart-post (>= 1.2, < 3)
26
+ git (1.2.9.1)
27
+ github_api (0.12.4)
28
+ addressable (~> 2.3)
29
+ descendants_tracker (~> 0.0.4)
30
+ faraday (~> 0.8, < 0.10)
31
+ hashie (>= 3.4)
32
+ multi_json (>= 1.7.5, < 2.0)
33
+ nokogiri (~> 1.6.6)
34
+ oauth2
35
+ hashdiff (0.2.2)
36
+ hashie (3.4.2)
37
+ highline (1.7.8)
38
+ i18n (0.7.0)
39
+ jeweler (2.0.1)
40
+ builder
41
+ bundler (>= 1.0)
42
+ git (>= 1.2.5)
43
+ github_api
44
+ highline (>= 1.6.15)
45
+ nokogiri (>= 1.5.10)
46
+ rake
47
+ rdoc
48
+ json (1.8.3)
49
+ jwt (1.5.1)
50
+ method_source (0.8.2)
51
+ mini_portile (0.6.2)
52
+ minitest (5.8.1)
53
+ multi_json (1.11.2)
54
+ multi_xml (0.5.5)
55
+ multipart-post (2.0.0)
56
+ nokogiri (1.6.6.2)
57
+ mini_portile (~> 0.6.0)
58
+ oauth2 (1.0.0)
59
+ faraday (>= 0.8, < 0.10)
60
+ jwt (~> 1.0)
61
+ multi_json (~> 1.3)
62
+ multi_xml (~> 0.5)
63
+ rack (~> 1.2)
64
+ pry (0.10.3)
65
+ coderay (~> 1.1.0)
66
+ method_source (~> 0.8.1)
67
+ slop (~> 3.4)
68
+ pry-byebug (3.2.0)
69
+ byebug (~> 5.0)
70
+ pry (~> 0.10)
71
+ rack (1.6.4)
72
+ rake (10.4.2)
73
+ rdoc (4.2.0)
74
+ rspec (3.3.0)
75
+ rspec-core (~> 3.3.0)
76
+ rspec-expectations (~> 3.3.0)
77
+ rspec-mocks (~> 3.3.0)
78
+ rspec-core (3.3.2)
79
+ rspec-support (~> 3.3.0)
80
+ rspec-expectations (3.3.1)
81
+ diff-lcs (>= 1.2.0, < 2.0)
82
+ rspec-support (~> 3.3.0)
83
+ rspec-mocks (3.3.2)
84
+ diff-lcs (>= 1.2.0, < 2.0)
85
+ rspec-support (~> 3.3.0)
86
+ rspec-support (3.3.0)
87
+ safe_yaml (1.0.4)
88
+ simplecov (0.10.0)
89
+ docile (~> 1.1.0)
90
+ json (~> 1.8)
91
+ simplecov-html (~> 0.10.0)
92
+ simplecov-html (0.10.0)
93
+ slop (3.6.0)
94
+ thread_safe (0.3.5)
95
+ timecop (0.8.0)
96
+ tzinfo (1.2.2)
97
+ thread_safe (~> 0.1)
98
+ webmock (1.22.1)
99
+ addressable (>= 2.3.6)
100
+ crack (>= 0.3.2)
101
+ hashdiff
102
+
103
+ PLATFORMS
104
+ ruby
105
+
106
+ DEPENDENCIES
107
+ activesupport
108
+ bundler
109
+ codeclimate-test-reporter
110
+ faraday
111
+ jeweler (~> 2.0.1)
112
+ pry-byebug
113
+ rdoc
114
+ rspec
115
+ simplecov
116
+ timecop
117
+ webmock
118
+
119
+ BUNDLED WITH
120
+ 1.10.6
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 David Paluy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # leadsquared gem
2
+
3
+ This is a simple Ruby wrapper to [Leadsquared](http://apidocs.leadsquared.com/) API
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/leadsquared.png)](http://badge.fury.io/rb/leadsquared)
6
+ [![Build Status](https://secure.travis-ci.org/dpaluy/leadsquared.png)](http://travis-ci.org/dpaluy/leadsquared)
7
+ [![Code Climate](https://codeclimate.com/github/dpaluy/leadsquared/badges/gpa.svg)](https://codeclimate.com/github/dpaluy/leadsquared)
8
+ [![Dependency Status](https://gemnasium.com/dpaluy/leadsquared.svg)](https://gemnasium.com/dpaluy/leadsquared)
9
+
10
+ ## Usage
11
+
12
+ `gem 'leadsquared'`
13
+
14
+ You just need to provide the authentication details in you configuration, and you're set. For example, in Rails that would go into config/initializers/leadsquared.rb:
15
+
16
+ ```
17
+ Leadsquared.configure do |config|
18
+ config.key = 'mylogin'
19
+ config.secret = 'secret'
20
+ config.logger = Rails.logger
21
+ end
22
+ ```
23
+
24
+ ### NOTE
25
+
26
+ This version implements only [LeadManagement](http://apidocs.leadsquared.com/meta-data/) and [ActivityManagement](http://apidocs.leadsquared.com/get-activities-of-a-lead/)
27
+
28
+ ## Contributing to leadsquared
29
+
30
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
31
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
32
+ * Fork the project.
33
+ * Start a feature/bugfix branch.
34
+ * Commit and push until you are happy with your contribution.
35
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
36
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
37
+
38
+ ## Copyright
39
+
40
+ Copyright (c) 2015 David Paluy. See LICENSE.txt for further details.
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "leadsquared"
18
+ gem.homepage = "http://github.com/dpaluy/leadsquared"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Ruby framework for integration with Leadsquared API}
21
+ gem.description = %Q{Ruby framework for integration with Leadsquared. Leadsquared API: http://apidocs.leadsquared.com/}
22
+ gem.email = "dpaluy@gmail.com"
23
+ gem.authors = ["David Paluy"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ desc "Code coverage detail"
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = "true"
37
+ Rake::Task['spec'].execute
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "leadsquared #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,93 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: leadsquared 0.2.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "leadsquared"
9
+ s.version = "0.2.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["David Paluy"]
14
+ s.date = "2015-10-26"
15
+ s.description = "Ruby framework for integration with Leadsquared. Leadsquared API: http://apidocs.leadsquared.com/"
16
+ s.email = "dpaluy@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ ".travis.yml",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "leadsquared.gemspec",
32
+ "lib/leadsquared.rb",
33
+ "lib/leadsquared/activity.rb",
34
+ "lib/leadsquared/api_connection.rb",
35
+ "lib/leadsquared/client.rb",
36
+ "lib/leadsquared/config.rb",
37
+ "lib/leadsquared/engine.rb",
38
+ "lib/leadsquared/invalid_request_error.rb",
39
+ "lib/leadsquared/lead.rb",
40
+ "spec/leadsquared/activity_spec.rb",
41
+ "spec/leadsquared/client_spec.rb",
42
+ "spec/leadsquared/lead_spec.rb",
43
+ "spec/leadsquared_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+ s.homepage = "http://github.com/dpaluy/leadsquared"
47
+ s.licenses = ["MIT"]
48
+ s.rubygems_version = "2.4.5.1"
49
+ s.summary = "Ruby framework for integration with Leadsquared API"
50
+
51
+ if s.respond_to? :specification_version then
52
+ s.specification_version = 4
53
+
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
56
+ s.add_runtime_dependency(%q<faraday>, [">= 0"])
57
+ s.add_development_dependency(%q<rspec>, [">= 0"])
58
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
59
+ s.add_development_dependency(%q<bundler>, [">= 0"])
60
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
61
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
62
+ s.add_development_dependency(%q<pry-byebug>, [">= 0"])
63
+ s.add_development_dependency(%q<webmock>, [">= 0"])
64
+ s.add_development_dependency(%q<timecop>, [">= 0"])
65
+ s.add_development_dependency(%q<codeclimate-test-reporter>, [">= 0"])
66
+ else
67
+ s.add_dependency(%q<activesupport>, [">= 0"])
68
+ s.add_dependency(%q<faraday>, [">= 0"])
69
+ s.add_dependency(%q<rspec>, [">= 0"])
70
+ s.add_dependency(%q<rdoc>, [">= 0"])
71
+ s.add_dependency(%q<bundler>, [">= 0"])
72
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
73
+ s.add_dependency(%q<simplecov>, [">= 0"])
74
+ s.add_dependency(%q<pry-byebug>, [">= 0"])
75
+ s.add_dependency(%q<webmock>, [">= 0"])
76
+ s.add_dependency(%q<timecop>, [">= 0"])
77
+ s.add_dependency(%q<codeclimate-test-reporter>, [">= 0"])
78
+ end
79
+ else
80
+ s.add_dependency(%q<activesupport>, [">= 0"])
81
+ s.add_dependency(%q<faraday>, [">= 0"])
82
+ s.add_dependency(%q<rspec>, [">= 0"])
83
+ s.add_dependency(%q<rdoc>, [">= 0"])
84
+ s.add_dependency(%q<bundler>, [">= 0"])
85
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
86
+ s.add_dependency(%q<simplecov>, [">= 0"])
87
+ s.add_dependency(%q<pry-byebug>, [">= 0"])
88
+ s.add_dependency(%q<webmock>, [">= 0"])
89
+ s.add_dependency(%q<timecop>, [">= 0"])
90
+ s.add_dependency(%q<codeclimate-test-reporter>, [">= 0"])
91
+ end
92
+ end
93
+
@@ -0,0 +1,15 @@
1
+ require 'leadsquared/config'
2
+ require 'leadsquared/client'
3
+ require 'leadsquared/api_connection'
4
+ require 'leadsquared/lead'
5
+ require 'leadsquared/activity'
6
+ require 'leadsquared/invalid_request_error'
7
+ require 'leadsquared/engine' if defined?(Rails)
8
+
9
+ module Leadsquared
10
+ VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip.freeze
11
+
12
+ def self.logger
13
+ config.logger
14
+ end
15
+ end
@@ -0,0 +1,71 @@
1
+ require 'json'
2
+ require 'active_support/core_ext/object/try'
3
+
4
+ module Leadsquared
5
+ class Activity < ApiConnection
6
+ SERVICE = '/v2/ProspectActivity.svc/'.freeze
7
+
8
+ def initialize
9
+ super(SERVICE)
10
+ end
11
+
12
+ def get_activities(lead_id, activity_event_id, offset = 0, row_count = 10)
13
+ url = url_with_service("Retrieve")
14
+ body = {
15
+ "Parameter" => {"ActivityEvent" => activity_event_id},
16
+ "Paging" => {"Offset" => offset, "RowCount" => row_count}
17
+ }
18
+ response = connection.post(url, {leadId: lead_id}, body.to_json)
19
+ handle_response response
20
+ end
21
+
22
+ # direction - Use ‘1’ as direction for Outbound Activity and ‘0’ for Inbound Activity
23
+ def create_activity_type(name, score, description, direction = 0)
24
+ url = url_with_service("CreateType")
25
+ body = {
26
+ "ActivityEventName" => name,
27
+ "Score" => score,
28
+ "Description" => description,
29
+ "Direction" => direction
30
+ }
31
+ response = connection.post(url, {}, body.to_json)
32
+ parsed_response = handle_response response
33
+ parsed_response["Message"]["Id"]
34
+ end
35
+
36
+ def create_lead_activity(lead_id, event_id, notes = nil)
37
+ url = url_with_service("Create")
38
+ body = {
39
+ "RelatedProspectId" => lead_id,
40
+ "ActivityEvent" => event_id,
41
+ "ActivityNote" => notes,
42
+ "ActivityDateTime" => current_utc_time
43
+ }
44
+ response = connection.post(url, {leadId: lead_id}, body.to_json)
45
+ parsed_response = handle_response response
46
+ parsed_response["Message"]["Id"]
47
+ end
48
+
49
+ def create(email, event_id, notes = nil, first_name = nil, last_name = nil)
50
+ url = url_with_service("Create")
51
+ body = {
52
+ "EmailAddress" => email,
53
+ "ActivityEvent" => event_id,
54
+ "ActivityNote" => notes,
55
+ "ActivityDateTime" => current_utc_time,
56
+ "FirstName" => first_name,
57
+ "LastName" => last_name
58
+ }
59
+ response = connection.post(url, {}, body.to_json)
60
+ parsed_response = handle_response response
61
+ parsed_response["Message"]["Id"]
62
+ end
63
+
64
+ private
65
+
66
+ def current_utc_time
67
+ Time.now.utc.to_s.gsub(/ UTC$/, "")
68
+ end
69
+ end
70
+ end
71
+