leadtune 0.0.7 → 0.0.8
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.
- data/README.rdoc +10 -14
- data/lib/leadtune/config.rb +7 -16
- data/lib/leadtune/prospect.rb +3 -7
- data/lib/leadtune/rest.rb +2 -3
- data/lib/leadtune/version.rb +1 -1
- data/spec/delete.rb +1 -2
- data/spec/get.rb +1 -2
- data/spec/leadtune/config_spec.rb +3 -9
- data/spec/leadtune/rest_spec.rb +7 -14
- data/spec/post.rb +1 -2
- data/spec/put.rb +1 -2
- data/spec/spec_helper.rb +2 -4
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -15,30 +15,27 @@ For details about the LeadTune API, see: http://leadtune.com/api
|
|
15
15
|
Authentication credentials can be specified by any of several methods, as
|
16
16
|
detailed below. Available configuration values include:
|
17
17
|
|
18
|
-
*
|
19
|
-
* password
|
18
|
+
* api_key
|
20
19
|
* organization
|
21
20
|
|
22
21
|
=== Rack Initializer
|
23
22
|
|
24
23
|
# config/initializers/leadtune.rb
|
25
|
-
Leadtune::Config.
|
26
|
-
Leadtune::Config.password = "my_secret"
|
24
|
+
Leadtune::Config.api_key = "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f"
|
27
25
|
Leadtune::Config.organization = "MYC"
|
28
26
|
|
29
27
|
=== Factors Hash
|
30
28
|
|
31
|
-
When initializing your Leadtune::Prospect, you can include your
|
32
|
-
|
33
|
-
|
34
|
-
initializer.</em>
|
29
|
+
When initializing your Leadtune::Prospect, you can include your API key and
|
30
|
+
organization along with any factors you wish to submit. <em>These values take
|
31
|
+
precedence over values read from the rack initializer.</em>
|
35
32
|
|
36
33
|
=== Instance Methods
|
37
34
|
|
38
|
-
You can also set your
|
39
|
-
Leadtune::Prospect object's #
|
40
|
-
|
41
|
-
|
35
|
+
You can also set your API key and organization by calling the
|
36
|
+
Leadtune::Prospect object's #api_key= and #organization= methods. <em>These
|
37
|
+
values take precedence over values read from the factors hash and the rack
|
38
|
+
initializer.</em>
|
42
39
|
|
43
40
|
== Example Usage
|
44
41
|
|
@@ -48,8 +45,7 @@ An attempt was made to allow for an ActiveModel-like interface.
|
|
48
45
|
require "leadtune"
|
49
46
|
|
50
47
|
prospect = Leadtune::Prospect.post({
|
51
|
-
:
|
52
|
-
:password => "secret" # required (See Leadtune::Config)
|
48
|
+
:api_key => "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f", # required (See Leadtune::Config)
|
53
49
|
:organization => "LOL", # required (See Leadtune::Config)
|
54
50
|
:event => "offers_prepared", # required
|
55
51
|
:email => "test@example.com" # required
|
data/lib/leadtune/config.rb
CHANGED
@@ -8,20 +8,15 @@ module Leadtune
|
|
8
8
|
|
9
9
|
class Config #:nodoc:all
|
10
10
|
|
11
|
-
attr_accessor :environment, :leadtune_host, :
|
11
|
+
attr_accessor :environment, :leadtune_host, :api_key, :timeout
|
12
12
|
|
13
13
|
@@leadtune_host = nil
|
14
|
-
@@
|
15
|
-
@@password = nil
|
14
|
+
@@api_key = nil
|
16
15
|
@@organization = nil
|
17
16
|
@@timeout = nil
|
18
17
|
|
19
|
-
def self.
|
20
|
-
@@
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.password=(password)
|
24
|
-
@@password = password
|
18
|
+
def self.api_key=(api_key)
|
19
|
+
@@api_key = api_key
|
25
20
|
end
|
26
21
|
|
27
22
|
def self.organization=(organization)
|
@@ -36,12 +31,8 @@ module Leadtune
|
|
36
31
|
@@timeout = timeout
|
37
32
|
end
|
38
33
|
|
39
|
-
def
|
40
|
-
@
|
41
|
-
end
|
42
|
-
|
43
|
-
def password
|
44
|
-
@password ||= @@password
|
34
|
+
def api_key
|
35
|
+
@api_key ||= @@api_key
|
45
36
|
end
|
46
37
|
|
47
38
|
def timeout
|
@@ -75,7 +66,7 @@ module Leadtune
|
|
75
66
|
private
|
76
67
|
|
77
68
|
DEFAULT_TIMEOUT = 5
|
78
|
-
LEADTUNE_HOST_SANDBOX = "https://sandbox-appraiser.leadtune.com".freeze
|
69
|
+
LEADTUNE_HOST_SANDBOX = "https://sandbox-appraiser.leadtune.com".freeze
|
79
70
|
LEADTUNE_HOST_PRODUCTION = "https://appraiser.leadtune.com".freeze
|
80
71
|
LEADTUNE_HOSTS = {
|
81
72
|
:production => LEADTUNE_HOST_PRODUCTION,
|
data/lib/leadtune/prospect.rb
CHANGED
@@ -180,12 +180,8 @@ module Leadtune
|
|
180
180
|
@config.timeout
|
181
181
|
end
|
182
182
|
|
183
|
-
def
|
184
|
-
@config.
|
185
|
-
end
|
186
|
-
|
187
|
-
def password=(password)
|
188
|
-
@config.password = password
|
183
|
+
def api_key=(api_key)
|
184
|
+
@config.api_key = api_key
|
189
185
|
end
|
190
186
|
|
191
187
|
def response #:nodoc:
|
@@ -199,7 +195,7 @@ module Leadtune
|
|
199
195
|
|
200
196
|
private
|
201
197
|
|
202
|
-
CURL_OPTIONS = ["
|
198
|
+
CURL_OPTIONS = ["api_key", "timeout", "leadtune_host",] #:nodoc:
|
203
199
|
|
204
200
|
def post_data #:nodoc:
|
205
201
|
f = @factors.merge("organization" => organization)
|
data/lib/leadtune/rest.rb
CHANGED
@@ -52,8 +52,6 @@ module Leadtune
|
|
52
52
|
def build_curl_easy_object(&block) #:nodoc:
|
53
53
|
Curl::Easy.new do |curl|
|
54
54
|
curl.http_auth_types = [:basic,]
|
55
|
-
curl.username = @config.username
|
56
|
-
curl.password = @config.password
|
57
55
|
curl.timeout = @config.timeout
|
58
56
|
curl.headers = default_headers
|
59
57
|
curl.on_failure do |curl, code|
|
@@ -66,7 +64,8 @@ module Leadtune
|
|
66
64
|
|
67
65
|
def default_headers #:nodoc:
|
68
66
|
{"Content-Type" => "application/json",
|
69
|
-
"Accept" => "application/json",
|
67
|
+
"Accept" => "application/json",
|
68
|
+
"X-API-Key" => @config.api_key,}
|
70
69
|
end
|
71
70
|
|
72
71
|
def build_curl_easy_object_post #:nodoc:
|
data/lib/leadtune/version.rb
CHANGED
data/spec/delete.rb
CHANGED
@@ -13,8 +13,7 @@ require File.join(File.dirname(__FILE__), "../lib/leadtune")
|
|
13
13
|
begin
|
14
14
|
p = Leadtune::Prospect.delete do |p|
|
15
15
|
p.organization = "LOL"
|
16
|
-
p.
|
17
|
-
p.password = "admin"
|
16
|
+
p.api_key = "h5fvNoTFa9AqzxUgixNcGey7HfZNKiBE9pC39fIH"
|
18
17
|
p.leadtune_host = "http://localhost:8080"
|
19
18
|
p.prospect_id = ARGV[0]
|
20
19
|
end
|
data/spec/get.rb
CHANGED
@@ -13,8 +13,7 @@ require File.join(File.dirname(__FILE__), "../lib/leadtune")
|
|
13
13
|
begin
|
14
14
|
p = Leadtune::Prospect.get({
|
15
15
|
:organization => "LOL",
|
16
|
-
:
|
17
|
-
:password => "admin",
|
16
|
+
:api_key => "h5fvNoTFa9AqzxUgixNcGey7HfZNKiBE9pC39fIH",
|
18
17
|
# :leadtune_host => "https://staging-appraiser.leadtune.com",
|
19
18
|
# :leadtune_host => "https://sandbox-appraiser.leadtune.com",
|
20
19
|
:leadtune_host => "http://localhost:8080",
|
@@ -19,16 +19,10 @@ describe Leadtune::Config do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
context("can set") do
|
22
|
-
it "
|
23
|
-
Leadtune::Config.
|
22
|
+
it "api_key" do
|
23
|
+
Leadtune::Config.api_key = "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f"
|
24
24
|
|
25
|
-
Leadtune::Config.new.
|
26
|
-
end
|
27
|
-
|
28
|
-
it "username" do
|
29
|
-
Leadtune::Config.username = "bob"
|
30
|
-
|
31
|
-
Leadtune::Config.new.username.should == "bob"
|
25
|
+
Leadtune::Config.new.api_key.should == "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f"
|
32
26
|
end
|
33
27
|
|
34
28
|
it "timeout" do
|
data/spec/leadtune/rest_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe Leadtune::Rest do
|
|
14
14
|
|
15
15
|
subject {Leadtune::Rest.new(Leadtune::Config.new)}
|
16
16
|
|
17
|
-
context("w/
|
17
|
+
context("w/ api_key from initializer") do
|
18
18
|
|
19
19
|
before(:each) do
|
20
20
|
@curl_easy = null_curl_easy
|
@@ -25,21 +25,14 @@ describe Leadtune::Rest do
|
|
25
25
|
teardown_initializer
|
26
26
|
end
|
27
27
|
|
28
|
-
describe "#
|
29
|
-
it "uses the
|
30
|
-
@curl_easy.should_receive(:username=).with("init_user")
|
31
|
-
|
28
|
+
describe "#get" do
|
29
|
+
it "uses the initialized API key value" do
|
32
30
|
subject.get(mock_post_data)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#password" do
|
37
|
-
it "uses the initializer value" do
|
38
|
-
@curl_easy.should_receive(:password=).with("init_secret")
|
39
31
|
|
40
|
-
|
32
|
+
@curl_easy.headers.should include("X-API-Key" => "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f")
|
41
33
|
end
|
42
34
|
end
|
35
|
+
|
43
36
|
end
|
44
37
|
|
45
38
|
|
@@ -134,7 +127,7 @@ describe Leadtune::Rest do
|
|
134
127
|
|
135
128
|
thread = Thread.new(server) {|s| s.start}
|
136
129
|
|
137
|
-
TCPSocket.wait_for_service_with_timeout({:host => "localhost",
|
130
|
+
TCPSocket.wait_for_service_with_timeout({:host => "localhost",
|
138
131
|
:port => THREADED_MOCK_SERVER_PORT,
|
139
132
|
:timeout => 10})
|
140
133
|
block.call
|
@@ -151,7 +144,7 @@ describe Leadtune::Rest do
|
|
151
144
|
old_stderr, $stderr = $stderr, tf
|
152
145
|
block.call(tf)
|
153
146
|
end
|
154
|
-
|
147
|
+
|
155
148
|
$stdout, $stderr = old_stdout, old_stderr
|
156
149
|
end
|
157
150
|
|
data/spec/post.rb
CHANGED
@@ -13,8 +13,7 @@ require File.join(File.dirname(__FILE__), "../lib/leadtune")
|
|
13
13
|
begin
|
14
14
|
p = Leadtune::Prospect.post do |p|
|
15
15
|
p.organization = "LOL"
|
16
|
-
p.
|
17
|
-
p.password = "admin"
|
16
|
+
p.api_key = "h5fvNoTFa9AqzxUgixNcGey7HfZNKiBE9pC39fIH"
|
18
17
|
# p.leadtune_host = "https://staging-appraiser.leadtune.com"
|
19
18
|
# p.leadtune_host = "https://sandbox-appraiser.leadtune.com"
|
20
19
|
p.leadtune_host = "http://localhost:8080"
|
data/spec/put.rb
CHANGED
@@ -12,8 +12,7 @@ require File.join(File.dirname(__FILE__), "../lib/leadtune")
|
|
12
12
|
|
13
13
|
begin
|
14
14
|
p = Leadtune::Prospect.new({:prospect_id => ARGV[0],
|
15
|
-
:
|
16
|
-
:password => "admin",
|
15
|
+
:api_key => "h5fvNoTFa9AqzxUgixNcGey7HfZNKiBE9pC39fIH",
|
17
16
|
:target_buyers => ["AcmeU", "Bravo", "ConvU",],
|
18
17
|
:organization => "LOL",
|
19
18
|
:age => rand(30)+18})
|
data/spec/spec_helper.rb
CHANGED
@@ -15,16 +15,14 @@ RSpec.configure do |config|
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def setup_initializer
|
18
|
-
Leadtune::Config.
|
19
|
-
Leadtune::Config.password = "init_secret"
|
18
|
+
Leadtune::Config.api_key = "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f"
|
20
19
|
Leadtune::Config.timeout = 7
|
21
20
|
Leadtune::Config.organization = "init_org"
|
22
21
|
Leadtune::Config.leadtune_host = "http://localhost.init"
|
23
22
|
end
|
24
23
|
|
25
24
|
def teardown_initializer
|
26
|
-
Leadtune::Config.
|
27
|
-
Leadtune::Config.password = nil
|
25
|
+
Leadtune::Config.api_key = nil
|
28
26
|
Leadtune::Config.timeout = nil
|
29
27
|
Leadtune::Config.organization = nil
|
30
28
|
Leadtune::Config.leadtune_host = nil
|
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: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
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-11-05 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|