Sunnytrail

This is wrapper for Sunnytrail API - www.thesunnytrail.com

You can find API documentation here: beta.thesunnytrail.com/developers

Installation

Sunnytrail gem is hosted on rubygems.org

To install type in you terminal:

gem install sunnytrail

Usage

First you need to setup you token.

You can do it globally:

Sunnytrail.configure :api_key => "YOURTOKENHERE"

or per instance:

sunnytrail = Sunnytrail.new :api_key => "YOURTOKENHERE"

To add event to Sunnytrail use add_event function.

You can pass all arguments in hash.

Sunnytrail.add_event({:action => {:name =>"signup", :created =>Time.now.to_i}, 
                      :plan => {:name => "Basic", :price => 29, :recurring => 31}, 
                      :name => "User1", 
                      :email => "[email protected]", 
                      :id => "123"
                     })

Or you can build event with Event class.

event = Sunnytrail::Event.new
event.id = 123
event.email = "[email protected]"
event.name = "User1"
event.plan.name = "Basic"
event.plan.price = 29
event.plan.recurring = 31
event.action.name = "signup"
event.created = Time.now.to_i

Sunnytrail.add_event(event)

add_event works also as an instance method.

sunnytrail = Sunnytrail.new
sunnytrail.add_event(event)