Project

tracksale

0.0
No commit activity in last 3 years
No release in over 3 years
Integration gem for tracksale api v2
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Gem Version

Tracksale

Tracksale v2 API integration gem.

Install

  1. Add gem 'tracksale' into your Gemfile.
  2. Run bundle install

Configure

You must generate a Tracksale key on tracksale.co website and configure it on rails you can use an initializer.

config/initializers/tracksale.rb

Tracksale.configure do |config|
  config.key = 'YOUR_KEY_HERE'
end

If you want to run the dummy client, which prevents the gem from accessing the API (useful for developers without tracksale credential access) you can:

Tracksale.configure do |config|
  config.force_dummy_client
end

Also the dummy client accepts a default response that you can set and may be useful for some testings as in:

> Tracksale::DummyClient.response = nil # default value
=> nil
> Tracksale::Campaign.all
=> []

> Tracksale::DummyClient.response = [{
  'name' => 'foo', 
  'code' => 'bar', 
  'detractors' => '0' , 
  'passives' => 1, 
  'promoters' => 2
}]
=> [{"name"=>"foo", "code"=>"bar", "detractors"=>"0", "passives"=>1, "promoters"=>2}]
> Tracksale::Campaign.all
=> [#<Tracksale::Campaign:0x0055ea11d2b738 @code="bar", @name="foo", @score={:detractors=>"0", :passives=>1, :promoters=>2}>]

Key generation instructions can be found on the official documentation at: https://api.tracksale.co/?lang=en#submenu1

Using

After configuration you should be able to use it easily as in

Tracksale::Campaign.find_by_name('foobar') => #<Tracksale::Campaign:0x00559c458ec128
 @code=123,
 @name="foobar",
 @score={:detractors=>1, :passives=>2, :promoters=>3}>

Debug

You can enable the HTTParty debug on the request by using the '-d' option on IRB or Ruby

Limitations

This gem is on early stages of development and you will only be able to:

  • Find campaigns by name ( Tracksale::Campaign.find_by_name(name) )
  • List all campaigns ( Tracksale::Campaign.all )

Also you can only access 5 items from a campaign (name, code, detractors, passives and promoters).