leadtune 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/leadtune/prospect.rb +21 -2
- data/lib/leadtune/rest.rb +19 -3
- data/lib/leadtune/version.rb +1 -1
- data/spec/checks.bash +37 -0
- data/spec/delete.rb +23 -0
- data/spec/get.rb +9 -11
- data/spec/post.rb +17 -11
- data/spec/put.rb +5 -10
- metadata +17 -15
data/lib/leadtune/prospect.rb
CHANGED
@@ -63,6 +63,14 @@ module Leadtune
|
|
63
63
|
new(options_and_factors, &block).put
|
64
64
|
end
|
65
65
|
|
66
|
+
# Delete a prospect from the LeadTune Appraiser service.
|
67
|
+
#
|
68
|
+
# Raises a Leadtune::LeadtuneError if a non-2XX response is received.
|
69
|
+
|
70
|
+
def self.delete(options_and_factors={}, &block)
|
71
|
+
new(options_and_factors, &block).delete
|
72
|
+
end
|
73
|
+
|
66
74
|
# Get a prospect from the LeadTune Appraiser service.
|
67
75
|
#
|
68
76
|
# Raises a Leadtune::LeadtuneError if a non-2XX response is received.
|
@@ -93,6 +101,16 @@ module Leadtune
|
|
93
101
|
self
|
94
102
|
end
|
95
103
|
|
104
|
+
# Delete a prospect from the LeadTune Appraiser service.
|
105
|
+
#
|
106
|
+
# Raises a Leadtune::LeadtuneError if a non-2XX response is received.
|
107
|
+
|
108
|
+
def delete
|
109
|
+
json = @rest.delete(post_data)
|
110
|
+
parse_response(json) unless json.nil?
|
111
|
+
self
|
112
|
+
end
|
113
|
+
|
96
114
|
# The unique +decision_id+ for this prospect.
|
97
115
|
|
98
116
|
def decision_id
|
@@ -184,8 +202,9 @@ module Leadtune
|
|
184
202
|
CURL_OPTIONS = ["username", "password", "timeout", "leadtune_host",] #:nodoc:
|
185
203
|
|
186
204
|
def post_data #:nodoc:
|
187
|
-
@factors.merge("
|
188
|
-
|
205
|
+
f = @factors.merge("organization" => organization)
|
206
|
+
f.merge!("decision" => @decision) if @decision
|
207
|
+
f
|
189
208
|
end
|
190
209
|
|
191
210
|
def load_options_and_factors(options) #:nodoc:
|
data/lib/leadtune/rest.rb
CHANGED
@@ -39,6 +39,13 @@ module Leadtune
|
|
39
39
|
parse_response(curl.body_str)
|
40
40
|
end
|
41
41
|
|
42
|
+
def delete(post_data)
|
43
|
+
@post_data = post_data
|
44
|
+
curl = build_curl_easy_object_delete
|
45
|
+
curl.http("DELETE")
|
46
|
+
parse_response(curl.body_str) unless curl.body_str.empty?
|
47
|
+
end
|
48
|
+
|
42
49
|
|
43
50
|
private
|
44
51
|
|
@@ -64,7 +71,7 @@ module Leadtune
|
|
64
71
|
|
65
72
|
def build_curl_easy_object_post #:nodoc:
|
66
73
|
build_curl_easy_object do |curl|
|
67
|
-
curl.url =
|
74
|
+
curl.url = build_post_url
|
68
75
|
curl.post_body = @post_data.to_json
|
69
76
|
$stderr.puts curl.post_body if curl.verbose?
|
70
77
|
end
|
@@ -73,8 +80,13 @@ module Leadtune
|
|
73
80
|
def build_curl_easy_object_put #:nodoc:
|
74
81
|
build_curl_easy_object do |curl|
|
75
82
|
curl.url = build_put_url
|
76
|
-
curl.
|
77
|
-
|
83
|
+
curl.post_body = @post_data.to_json
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def build_curl_easy_object_delete #:nodoc:
|
88
|
+
build_curl_easy_object do |curl|
|
89
|
+
curl.url = build_get_url
|
78
90
|
end
|
79
91
|
end
|
80
92
|
|
@@ -84,6 +96,10 @@ module Leadtune
|
|
84
96
|
end
|
85
97
|
end
|
86
98
|
|
99
|
+
def build_post_url #:nodoc:
|
100
|
+
URI.join(@config.leadtune_host, "/prospects").to_s
|
101
|
+
end
|
102
|
+
|
87
103
|
def build_get_url #:nodoc:
|
88
104
|
params = {:organization => @post_data["organization"],}
|
89
105
|
if @post_data["prospect_ref"]
|
data/lib/leadtune/version.rb
CHANGED
data/spec/checks.bash
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# LeadTune API Ruby Gem
|
4
|
+
#
|
5
|
+
# http://github.com/leadtune/leadtune-ruby
|
6
|
+
# Eric Wollesen (mailto:devs@leadtune.com)
|
7
|
+
# Copyright 2010 LeadTune LLC
|
8
|
+
|
9
|
+
# this is just a quick script to check a few prerequisites
|
10
|
+
|
11
|
+
which curl > /dev/null
|
12
|
+
if [ $? -ne 0 ]; then
|
13
|
+
echo "curl binary not found"
|
14
|
+
exit 1
|
15
|
+
fi
|
16
|
+
|
17
|
+
curl -V | grep -qi '\bssl\b'
|
18
|
+
if [ $? -ne 0 ]; then
|
19
|
+
echo "curl does not support ssl"
|
20
|
+
exit 1
|
21
|
+
fi
|
22
|
+
|
23
|
+
host appraiser.leadtune.com > /dev/null
|
24
|
+
if [ $? -ne 0 ]; then
|
25
|
+
echo "could not resolve appraiser.leadtune.com"
|
26
|
+
exit 1
|
27
|
+
fi
|
28
|
+
|
29
|
+
host sandbox-appraiser.leadtune.com > /dev/null
|
30
|
+
if [ $? -ne 0 ]; then
|
31
|
+
echo "could not resolve sandbox-appraiser.leadtune.com"
|
32
|
+
exit 1
|
33
|
+
fi
|
34
|
+
|
35
|
+
|
36
|
+
echo Everything looks good.
|
37
|
+
exit 0
|
data/spec/delete.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# LeadTune API Ruby Gem
|
4
|
+
#
|
5
|
+
# http://github.com/leadtune/leadtune-ruby
|
6
|
+
# Eric Wollesen (mailto:devs@leadtune.com)
|
7
|
+
# Copyright 2010 LeadTune LLC
|
8
|
+
|
9
|
+
require "rubygems"
|
10
|
+
require "pp"
|
11
|
+
require File.join(File.dirname(__FILE__), "../lib/leadtune")
|
12
|
+
|
13
|
+
begin
|
14
|
+
p = Leadtune::Prospect.delete do |p|
|
15
|
+
p.organization = "LOL"
|
16
|
+
p.username = "admin@loleads.com"
|
17
|
+
p.password = "admin"
|
18
|
+
p.leadtune_host = "http://localhost:8080"
|
19
|
+
p.prospect_id = ARGV[0]
|
20
|
+
end
|
21
|
+
rescue Leadtune::LeadtuneError => e
|
22
|
+
puts e.to_s
|
23
|
+
end
|
data/spec/get.rb
CHANGED
@@ -12,20 +12,18 @@ require File.join(File.dirname(__FILE__), "../lib/leadtune")
|
|
12
12
|
|
13
13
|
begin
|
14
14
|
p = Leadtune::Prospect.get({
|
15
|
-
:organization => "
|
16
|
-
:username => "admin@
|
15
|
+
:organization => "LOL",
|
16
|
+
:username => "admin@loleads.com",
|
17
17
|
:password => "admin",
|
18
|
-
# :leadtune_host => "
|
19
|
-
:
|
20
|
-
|
21
|
-
})
|
22
|
-
pp p.factors
|
18
|
+
# :leadtune_host => "https://staging-appraiser.leadtune.com",
|
19
|
+
# :leadtune_host => "https://sandbox-appraiser.leadtune.com",
|
20
|
+
:leadtune_host => "http://localhost:8080",
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
:password => "admin",
|
27
|
-
:organization => "AcmeU",}).get.factors
|
22
|
+
:prospect_id => ARGV[0],
|
23
|
+
})
|
28
24
|
rescue Leadtune::LeadtuneError => e
|
29
25
|
puts e.to_s
|
26
|
+
else
|
27
|
+
pp p.factors
|
30
28
|
end
|
31
29
|
|
data/spec/post.rb
CHANGED
@@ -10,15 +10,21 @@ require "rubygems"
|
|
10
10
|
require "pp"
|
11
11
|
require File.join(File.dirname(__FILE__), "../lib/leadtune")
|
12
12
|
|
13
|
-
|
14
|
-
p
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
13
|
+
begin
|
14
|
+
p = Leadtune::Prospect.post do |p|
|
15
|
+
p.organization = "LOL"
|
16
|
+
p.username = "admin@loleads.com"
|
17
|
+
p.password = "admin"
|
18
|
+
# p.leadtune_host = "https://staging-appraiser.leadtune.com"
|
19
|
+
# p.leadtune_host = "https://sandbox-appraiser.leadtune.com"
|
20
|
+
p.leadtune_host = "http://localhost:8080"
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
p.event = "offers_prepared"
|
23
|
+
p.email = "test@example.com"
|
24
|
+
p.target_buyers = ["AcmeU", "Bravo", "ConvU",]
|
25
|
+
end
|
26
|
+
pp p.factors
|
27
|
+
`/bin/echo -n #{p.prospect_id} | pbcopy 2>&1 > /dev/null`
|
28
|
+
rescue Leadtune::LeadtuneError => e
|
29
|
+
puts e.to_s
|
30
|
+
end
|
data/spec/put.rb
CHANGED
@@ -10,22 +10,17 @@ require "rubygems"
|
|
10
10
|
require "pp"
|
11
11
|
require File.join(File.dirname(__FILE__), "../lib/leadtune")
|
12
12
|
|
13
|
-
|
14
13
|
begin
|
15
|
-
p = Leadtune::Prospect.
|
16
|
-
:username => "admin@
|
14
|
+
p = Leadtune::Prospect.new({:prospect_id => ARGV[0],
|
15
|
+
:username => "admin@loleads.com",
|
17
16
|
:password => "admin",
|
18
|
-
:
|
19
|
-
|
17
|
+
:target_buyers => ["AcmeU", "Bravo", "ConvU",],
|
18
|
+
:organization => "LOL",
|
19
|
+
:age => rand(30)+18})
|
20
20
|
p.leadtune_host = "http://localhost:8080"
|
21
21
|
p.put
|
22
22
|
|
23
|
-
p = Leadtune::Prospect.get({:prospect_id => "4c92f8d6b34601dd5ecac030",
|
24
|
-
:username => "admin@acme.edu",
|
25
|
-
:password => "admin",
|
26
|
-
:organization => "AcmeU",})
|
27
23
|
pp p.factors
|
28
|
-
|
29
24
|
rescue Leadtune::LeadtuneError => e
|
30
25
|
puts e.to_s
|
31
26
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leadtune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric Wollesen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-22 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -30,10 +30,10 @@ dependencies:
|
|
30
30
|
- 0
|
31
31
|
- 0
|
32
32
|
version: 1.0.0
|
33
|
-
prerelease: false
|
34
33
|
requirement: *id001
|
35
34
|
type: :development
|
36
35
|
name: bundler
|
36
|
+
prerelease: false
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
segments:
|
45
45
|
- 0
|
46
46
|
version: "0"
|
47
|
-
prerelease: false
|
48
47
|
requirement: *id002
|
49
48
|
type: :development
|
50
49
|
name: ruby-debug
|
50
|
+
prerelease: false
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
52
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
@@ -62,10 +62,10 @@ dependencies:
|
|
62
62
|
- beta
|
63
63
|
- 19
|
64
64
|
version: 2.0.0.beta.19
|
65
|
-
prerelease: false
|
66
65
|
requirement: *id003
|
67
66
|
type: :development
|
68
67
|
name: rspec
|
68
|
+
prerelease: false
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
71
71
|
none: false
|
@@ -80,10 +80,10 @@ dependencies:
|
|
80
80
|
- beta
|
81
81
|
- 19
|
82
82
|
version: 2.0.0.beta.19
|
83
|
-
prerelease: false
|
84
83
|
requirement: *id004
|
85
84
|
type: :development
|
86
85
|
name: rspec-core
|
86
|
+
prerelease: false
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
- beta
|
99
99
|
- 19
|
100
100
|
version: 2.0.0.beta.19
|
101
|
-
prerelease: false
|
102
101
|
requirement: *id005
|
103
102
|
type: :development
|
104
103
|
name: rspec-expectations
|
104
|
+
prerelease: false
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
@@ -116,10 +116,10 @@ dependencies:
|
|
116
116
|
- beta
|
117
117
|
- 19
|
118
118
|
version: 2.0.0.beta.19
|
119
|
-
prerelease: false
|
120
119
|
requirement: *id006
|
121
120
|
type: :development
|
122
121
|
name: rspec-mocks
|
122
|
+
prerelease: false
|
123
123
|
- !ruby/object:Gem::Dependency
|
124
124
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
125
125
|
none: false
|
@@ -130,10 +130,10 @@ dependencies:
|
|
130
130
|
segments:
|
131
131
|
- 0
|
132
132
|
version: "0"
|
133
|
-
prerelease: false
|
134
133
|
requirement: *id007
|
135
134
|
type: :development
|
136
135
|
name: webmock
|
136
|
+
prerelease: false
|
137
137
|
- !ruby/object:Gem::Dependency
|
138
138
|
version_requirements: &id008 !ruby/object:Gem::Requirement
|
139
139
|
none: false
|
@@ -144,10 +144,10 @@ dependencies:
|
|
144
144
|
segments:
|
145
145
|
- 0
|
146
146
|
version: "0"
|
147
|
-
prerelease: false
|
148
147
|
requirement: *id008
|
149
148
|
type: :development
|
150
149
|
name: tcpsocket-wait
|
150
|
+
prerelease: false
|
151
151
|
- !ruby/object:Gem::Dependency
|
152
152
|
version_requirements: &id009 !ruby/object:Gem::Requirement
|
153
153
|
none: false
|
@@ -158,10 +158,10 @@ dependencies:
|
|
158
158
|
segments:
|
159
159
|
- 0
|
160
160
|
version: "0"
|
161
|
-
prerelease: false
|
162
161
|
requirement: *id009
|
163
162
|
type: :runtime
|
164
163
|
name: rake
|
164
|
+
prerelease: false
|
165
165
|
- !ruby/object:Gem::Dependency
|
166
166
|
version_requirements: &id010 !ruby/object:Gem::Requirement
|
167
167
|
none: false
|
@@ -172,10 +172,10 @@ dependencies:
|
|
172
172
|
segments:
|
173
173
|
- 0
|
174
174
|
version: "0"
|
175
|
-
prerelease: false
|
176
175
|
requirement: *id010
|
177
176
|
type: :runtime
|
178
177
|
name: curb
|
178
|
+
prerelease: false
|
179
179
|
- !ruby/object:Gem::Dependency
|
180
180
|
version_requirements: &id011 !ruby/object:Gem::Requirement
|
181
181
|
none: false
|
@@ -186,10 +186,10 @@ dependencies:
|
|
186
186
|
segments:
|
187
187
|
- 0
|
188
188
|
version: "0"
|
189
|
-
prerelease: false
|
190
189
|
requirement: *id011
|
191
190
|
type: :runtime
|
192
191
|
name: json
|
192
|
+
prerelease: false
|
193
193
|
description: LeadTune Ruby API Gem
|
194
194
|
email:
|
195
195
|
- devs@leadtune.com
|
@@ -214,6 +214,8 @@ files:
|
|
214
214
|
- lib/leadtune/rest.rb
|
215
215
|
- lib/leadtune/util.rb
|
216
216
|
- lib/leadtune/version.rb
|
217
|
+
- spec/checks.bash
|
218
|
+
- spec/delete.rb
|
217
219
|
- spec/echo_server.rb
|
218
220
|
- spec/get.rb
|
219
221
|
- spec/leadtune/appraisals_spec.rb
|