No release in over a year
This is a fork of https://github.com/tremendous-rewards/tremendous-ruby to add the resend reward API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 12.3.3
>= 3.5.0

Runtime

>= 0.18.0
>= 1.5.0
 Project Readme

Tremendous

A Ruby client library for the Tremendous API.

Note

This branch includes the v5 version of the Tremendous Ruby client, a new version based on our API schema docs. If you are using the v4 versions, please check our UPGRADING guide

Installation

$ gem install tremendous_ruby
# or add it to your Gemfile
$ bundle add tremendous_ruby

Getting started

All API requests require an access token. A sandbox access token is assigned upon signup through the Tremendous Sandbox Environment. Once you are ready to move to production, you will be assigned a production access token.

Authentication

Using a global config & client instances:

Tremendous::Configuration.default.configure do |config|
  # you can use `Tremendous::Configuration::Environment["production"]` when
  # ready to use our production environment.
  config.server_index = Tremendous::Configuration::Environment["testflight"]

  config.access_token = "YOUR-ACCESS-TOKEN"
end

client = Tremendous::TremendousApi.new

Building your own:

config = Tremendous::Configuration.new do |config|
# ...
end

api = Tremendous::ApiClient.new(config)

client = Tremendous::TremendousApi.new(api)

Examples

Submitting an order:

order_data = {
  payment: {
    funding_source_id: "balance",
  },
  reward: {
    value: {
      denomination: 20,
      currency_code: 'USD'
    },
    campaign_id: "CAMPAIGN_ID",
    delivery: {
      method: 'EMAIL',
    },
    recipient: {
      email: 'sarah@tremendous.com',
      name: 'Sarah Smith'
    }
  }
}

response = client.create_order(order_data)
puts "Order created! ID: #{response.order.id}"

Retrieving an Order and a Reward

order = client.get_order("[ORDER_ID]").order
reward = client.get_reward("[REWARD_ID]").reward

puts "The order status is #{order.status}"
puts "The reward was delivered to #{reward.recipient.email}"

Listing products:

products = api_client.list_products.products

products.each { |product| puts product.name }

Listing funding sources:

funding_sources = client.funding_sources.list

funding_sources.each do |funding_source|
  puts "* #{funding_source.method} => #{funding_source.id}"
end