Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby library for accessing the Loyalty Lab API.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG.rdoc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 loyalty_lab_sdk.gemspec
README.rdoc

Loyalty Lab SDK

A ruby library for accessing the Loyalty Lab API documented here: api.loyaltylab.com/loyaltyapi/help/index.html

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.

Synopsis

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

api = LoyaltyLabSDK::LoyaltyAPI.new
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'] = 'test@gmail.com'
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

Authentication

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.

Timeouts

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.

Rails

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.

Something went wrong with that request. Please try again.