leadtune 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
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
- * username
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.username = "me@mycorp.com"
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 username,
32
- password, and organization along with any factors you wish to
33
- submit. <em>These values take precedence over values read from the rack
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 username, password, and organization by calling the
39
- Leadtune::Prospect object's #username=, #password=, and #organization=
40
- methods. <em>These values take precedence over values read from the factors
41
- hash and the rack initializer.</em>
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
- :username => "admin@loleads.com" # required (See Leadtune::Config)
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
@@ -8,20 +8,15 @@ module Leadtune
8
8
 
9
9
  class Config #:nodoc:all
10
10
 
11
- attr_accessor :environment, :leadtune_host, :username, :password, :timeout
11
+ attr_accessor :environment, :leadtune_host, :api_key, :timeout
12
12
 
13
13
  @@leadtune_host = nil
14
- @@username = nil
15
- @@password = nil
14
+ @@api_key = nil
16
15
  @@organization = nil
17
16
  @@timeout = nil
18
17
 
19
- def self.username=(username)
20
- @@username = username
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 username
40
- @username ||= @@username
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,
@@ -180,12 +180,8 @@ module Leadtune
180
180
  @config.timeout
181
181
  end
182
182
 
183
- def username=(username)
184
- @config.username = username
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 = ["username", "password", "timeout", "leadtune_host",] #:nodoc:
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:
@@ -5,5 +5,5 @@
5
5
  # Copyright 2010 LeadTune LLC
6
6
 
7
7
  module Leadtune
8
- VERSION = "0.0.7"
8
+ VERSION = "0.0.8"
9
9
  end
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.username = "admin@loleads.com"
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
- :username => "admin@loleads.com",
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 "password" do
23
- Leadtune::Config.password = "secret"
22
+ it "api_key" do
23
+ Leadtune::Config.api_key = "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f"
24
24
 
25
- Leadtune::Config.new.password.should == "secret"
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
@@ -14,7 +14,7 @@ describe Leadtune::Rest do
14
14
 
15
15
  subject {Leadtune::Rest.new(Leadtune::Config.new)}
16
16
 
17
- context("w/ username and password from initializer") do
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 "#username" do
29
- it "uses the initializer value" do
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
- subject.get(mock_post_data)
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.username = "admin@loleads.com"
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
- :username => "admin@loleads.com",
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.username = "init_user"
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.username = nil
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: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
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-10-22 00:00:00 -06:00
18
+ date: 2010-11-05 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency