Ruby library for accessing the Loyalty Lab API.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Loyalty Lab SDK

A ruby library for accessing the Loyalty Lab API documented here:

This library attempts to be as transparent as possible by making all method calls, parameters, and objects identical to those documented at the above URL. Capitalization goes against typical ruby conventions, and is instead as documented by Loyalty Lab.

NOTE: This software is in no way affiliated with the Loyalty Lab organization.


LoyaltyLabSDK.config(:username => 'foo', :password => 'bar')

api =
shopper = api.GetShopper 'shopperId' => 1234
shopper_id = shopper['ShopperId']
point_balance = api.AdjustShopperPoints 'shopperId' => shopper_id,
 'pointChange' => 1000,
 'pointType' => 'Base',
 'description' => 'Surprise bonus'

new_retailer_shopper_id = 1234
new_shopper = api.build_default_shopper(new_retailer_shopper_id)
new_shopper['EmailAddress'] = ''
new_shopper['FirstName'] = 'Joe'
new_shopper['LastName'] = 'Schmoe'
new_card = api.build_default_card(new_retailer_shopper_id)
api.CreateShopperWithCard 'shopper' => new_shopper, 'card' => new_card


By default, a new LoyaltyAPI instance will authenticate itself against the API (using #authenticate!) and store the authentication token when it is constructed. Authentication may be skipped by setting the :lazy_authentication option to true when calling the constructor. In this case, authentication will occur when the first API call is made (or it may be done explicitly).

According to Loyalty Lab, the authentication token will expire after 20 minutes of inactivity. By default, LoyaltyAPI has an option :allow_reauthenticate that defaults to true (may be overridden). If it's true, then when you receive an AuthenticationError while making an API call on an already-authenticated LoyaltyAPI instance, it will try once to re-authenticate automatically. This behavior could be overridden by the client by setting :allow_reauthenticate to false and then either ignoring the error, pro-actively calling #authenticate!, or catching AuthenticationError exceptions and re-authenticating then.


By default, all requests will timeout (for opening connections and making requests) after 15 seconds. This may be overridden by setting the :open_timeout and :read_timeout options when calling LoyaltyLabSDK.config.

Environment Variables

For convenience in a command-line environment, configuration of username and password may be skipped by setting the LOYALTY_LAB_SDK_USERNAME and LOYALTY_LAB_SDK_PASSWORD environment variables.


If running in a rails environment, this configuration will automatically use the global Rails.logger instance. This behavior may be overridden by passing in a :logger option to LoyaltyLabSDK.config.