Warbler Ruby Client Library

The Warbler gem lets you integrate with Warbler to track activities, reward customers and let them redeem rewards without leaving your application.

Dependencies

  • unirest

Installaction

gem install warbler

Or add it to your gemfile

gem 'warbler'

Quick Start Example

  1. Sign up for a sandbox account on https://www.warblersandbox.com

  2. Get your merchant_token from the 'Authorization Tokens' area available under 'Settings'

  3. Define an initializer holding the following values

  Warbler::Configuration.merchant_token = xxxxx # merchant_token from step 2
  Warbler::Configuration.mode = 'sandbox' # or 'production'
  Warbler::Configuration.device_identifier = 'webapp'
  1. Define the methods you'll use accross the app
  module Warblerable
    def identify_warbler_user(user)
      session[:device_token] = Warbler::UsersController.new.identify(user.email)['device_token']
    end

    def track_warbler_activity(activity_slug)
      Warbler::ActivitiesController.new(session[:device_token]).track(activity_slug)
    end

    def list_warbler_rewards
      Warbler::RewardsController.new(session[:device_token]).list
    end

    def show_warbler_reward(reward_id)
      Warbler::RewardsController.new(session[:device_token]).show(reward_id)
    end

    def redeem_warbler_reward(reward_id)
      Warbler::RewardsController.new(session[:device_token]).redeem(reward_id)
    rescue Warbler::APIException => e
      redirect_to :back, alert: JSON.parse(e.message).to_sentence
    end
  end
  1. Use the methods defined in the previous step

Sample Project

Check out our Sample Ruby on Rails project.

Help

If you have any questions feel free to email us at [email protected] We are happy to help.

Licence

See the LICENCE file.