LeadTune API Ruby Gem
github.com/leadtune/leadtune-ruby
Copyright 2010 LeadTune, LLC
Eric Wollesen ([email protected])
For details about the LeadTune API, see: leadtune.com/api
Configuration
Authentication credentials can be specified by any of several methods, as detailed below. Available configuration values include:
-
api_key
-
organization
Rack Initializer
# config/initializers/leadtune.rb
Leadtune::Config.api_key = "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f"
Leadtune::Config.organization = "MYC"
Factors Hash
When initializing your Leadtune::Prospect, you can include your API key and organization along with any factors you wish to submit. These values take precedence over values read from the rack initializer.
Instance Methods
You can also set your API key and organization by calling the Leadtune::Prospect object’s #api_key= and #organization= methods. These values take precedence over values read from the factors hash and the rack initializer.
Example Usage
An attempt was made to allow for an ActiveModel-like interface.
require "rubygems"
require "leadtune"
prospect = Leadtune::Prospect.post({
:api_key => "DeadB33fDeadB33fDeadB33fDeadB33fDeadB33f", # required (See Leadtune::Config)
:organization => "LOL", # required (See Leadtune::Config)
:event => "offers_prepared", # required
:email => "[email protected]", # required
:target_buyers => ["TB-LOL", "AcmeU"], # required
# ... include optional factors here, see http://leadtune.com/factors for details
})
Or alternatively
prospect = Leadtune::Prospect.post do |p|
p.event = "offers_prepared"
p.email = "[email protected]"
... and so on
end
Or even
prospect = Leadtune::Prospect.new
prospect.event = "offers_prepared"
prospect.email = "[email protected]"
... and so on
prospect.post
Automatic Environment Detection
At initialization, an attempt is made to detect your application’s current environment. If a rack or rails production environment is detected, prospects will be posted to LeadTune’s production host. Otherwise prospects will be posted to LeadTune’s sandbox host. The application environment can be overriden via the APP_ENV
environment variable, which takes precedence over all other methods.