Loading Offers & Businesses
The GetintheLoop SDK provides consistent interfaces for loading offer and business related data.
Basics
Collections
Searching Collections by Tag
Lists of collections can be retrieved with the following code:
// lmgClient is an instance of Client
lmgClient.collection.list(); // returns Promise<Array<Collection>>
list()
optionally accepts a list of collection "tags" to filter by
lmgClient.collection.list({ tags: ["tag-1", "tag-2"] });
Loading Collection Details and Contents
Load details for a specific Collection:
lmgClient.collection.get(collectionId); // returns Promise<Collection>
Load Businesses and Offers in a specific Collection:
lmgClient.collection.business.list(collectionId); // returns Promise<PagedList<Business>>
Each Business contains a list of Offers at that Business.
Global ordering point and geo area are used to sort and filter Locations and Offers.
Offers
Loading Offer Details
Get details of a specific Offer:
lmgClient.offer.get(offerId); // returns Promise<Offer>
Global ordering point is used to sort Offer's Locations.
Using Offers
Offer status and redemption are handled through a RedemptionController
Get a redemption controller for an Offer
const redemptionController = lmgClient.offer.getRedemptionController(
offerId,
businessId,
locationId
);
The redemption controller takes callbacks to be executed when something happens
// Called every time the Offer's redemption state is updated
// Guaranteed to be called once when attached
redemptionController.onStateChanged((redemptionState) => {
console.log('State changed to ' + redemptionState.displayStatus);
});
// Called when there is an error redeeming
redemptionController.onError((error) => {
console.error(error);
});
// Called when redemption is cancelled
redemptionController.onRedemptionCancelled(() => {
console.log('Redemption cancelled');
});
// Called when redemption controller needs user confirmation
redemptionController.onPromptRequired((resolver) => {
const useOffer = window.confirm('Are you sure you want to use this offer?');
resolver(useOffer);
});
Redeem offer
redemptionController.transitionToNextState();
// returns nothing
// will result in callback for onStateChanged, onPromptRequired, or onError
Business Details
Get details of a specific Business
lmgClient.business.get(businessId, locationId) // returns Promise<Business>
Global ordering point and geo area are used to sort and filter Business' Locations and Offers.
Locations Lists
List Business Locations for Maps
lmgClient.location.list()
Global ordering point and geo area are used to sort and filter Locations.
Advanced
Search
To search for offers:
lmgClient.business.list({ searchQuery: "Search Query" }); // returns Promise<PagedList<Business>>
Global ordering point and geo area are used to sort and filter Offers.
Bookmarked Offers
Bookmark an offer
lmgClient.offer.bookmark(
offerId, // offer id to bookmark
isBookmarked, // true: set bookmark
// false: unset existing bookmark
{
locationIds, // array of locationIds
businessId // string
}
);
Get bookmarked Offers
lmgClient.business.list({ limitToSaved: true }); // returns Promise<PagedList<Offer>>