This is a sample implementation of the Tremendous Embed module within a Rails application.
First, to receive your sandbox API keys, sign up through the Tremendous sandbox.
Add an .env file within this project's root with the follow envvars:
TREMENDOUS_REST_API_HOST=https://testflight.tremendous.com/api/v2/
TREMENDOUS_API_PRIVATE_KEY=YOUR_SANDBOX_API_PRIVATE_KEY
TREMENDOUS_EMBED_PUBLIC_KEY=YOUR_EMBED_SANDBOX_PUBLIC_KEY
bundle
rake db:migrate
rake catalog_update
rails s
The heart of the integration is located in a combination of rewards_controller.rb
and the associated rewards views.
At a high level, the backend encrypts your reward order JSON using your private API keys. That encrypted JSON is passed to the embed client SDK as a JWT to create a reward via the frontend SDK (see new.html.erb
for an example). The reward must then be passed to your backend and approved via the REST API.
The embed SDK documentation can be found here. The REST documentation can be found here.