Overview
In order for valid offers and rewards to be rendered to the UI, the client will need to retrieve data from two sources. Loyalty Engine and Sanity (RBI’s CMS). Loyalty Engine will provide incentives that the user is “eligible” for, meaning they pass all the necessary rules. Sanity will provide which incentives are live, and what category a reward might be in, as well as all the display content such as name/image/description etc.
The client will need to hit both of the aforementioned data sources and perform an intersection to determine which to render. The order the these queries are made will be up to the client and it’s implementation. The recommendation is to hit sanity first for all the “sorted offers” (live offers) and “reward categories” (live rewards), then use those ids to query Loyalty Engine for only the relevant data
Querying Sanity
URL - https://czqk28jt.api.sanity.io/v1/graphql/dev_bk_us/default
Replace
dev_bk_us
with the{{stage}}_{{brand}}_{{country}}
that you desire to querySanity Graphql can be hit via POST request. Please reference the POST url structure for each of the sample queries below
Please use this playground to play with the queries below and examine the schema for fields you may wish to request
Example Offers Query
The
id
is subject to the dataset you are using. For the most part it will befeature-loyalty-offers-ui-singleton
, however some markets have drifted from this conventionSample URL if using a REST client - https://czqk28jt.api.sanity.io/v1/graphql/dev_bk_us/default?query=query getSanityOffers { LoyaltyOffersUI(id: "feature-loyalty-offers-ui-singleton") { sortedSystemwideOffers { _id name { enRaw } } liveConfigOffers { _id name { enRaw } } } }
query getSanityOffers { LoyaltyOffersUI(id: "feature-loyalty-offers-ui-singleton") { sortedSystemwideOffers { _id name { enRaw } } liveConfigOffers { _id name { enRaw } } } }
Example Rewards Query
The
id
is subject to the dataset you are using. For the most part it will bereward-list-singleton
, however some markets have drifted from this conventionSample URL if using a REST client - https://czqk28jt.api.sanity.io/v1/graphql/dev_bk_us/default?query=query getSanityRewards { RewardList(id:"reward-list-singleton") { rewardCategories { _id label { en } rewards { ... on Reward { _id name { en } } } } } }
query getSanityRewards { RewardList(id:"reward-list-singleton") { rewardCategories { _id label { en } rewards { ... on Reward { _id name { en } } } } } }
Querying Loyalty Engine
URL - https://dev-bk-loyalty-middleware.rbictg.com/graphql
Replace
dev-bk
with the{{stage}}-{{brand}}
that you desire to query. For all markets other than US/CA, you will need to prefix the url with the AWS region that your market lives in. Please communicate with RBI reps to know which region your market is hosted. Example url for ES (Spain) would be https://euc1-dev-bk-loyalty-middleware.rbictg.com/graphqlPlease use this playground to play with the queries below and examine the schema for fields you may wish to request
Some
where
filters that may be relevant to Kioskids
- a collection of engine ids for offers/rewards. This is theloyaltyEngineId
field on every sanity offer/reward documentomitInvalids
- This controls whether invalid incentives will be returned. Only incentives that failed “fixable” rules will be returned if this is set tofalse
. A fixable rule is one that the user can change behavior to make the rule pass, like theminSpend
, the user can add more items to their cart to meet the requirement. An absolute failure likedate-band
will not be returned regardless of what the value of this filter isThis is useful for displaying error / in-line messages in the UI
serviceMode
- some incentives can only be redeemed if the service mode meets the required rulesetstoreId
- some incentives can only be redeemed at certain storessubtotalAmount
= some incentives require a minimum spendcartEntries
- some incentives require certain items to be in the cart, this rule uses the sanity id of each rbi productpaymentMethod
- some incentives require certain payment methods to be used
Example Offers Query
query getLoyaltyOffers { loyaltyOffersV2(loyaltyId: "some-user-id", where: { omitInvalids: false }) { id name errors { code ruleId } } }
Example Offers Query Response
{ "data": { "loyaltyOffersV2": [ { "id": "a4c24211-2d36-47be-bad8-8deea437dbfa", "name": "$6 Let's Get This Bacon Meal", "errors": null }, { "id": "fbba4e93-eecd-42b6-a4ed-333856d47bda", "name": "Delivery Offer - $8 The Spicy One Meal", "errors": null }, { "id": "6646b80b-dea9-4bf4-81f5-390554926987", "name": "Loyalty Upsize Swap", "errors": [ { "code": "unsatisfied-cart-requirements", "ruleId": "cart-requirement" } ] } ] } }
Example Rewards Query
query getLoyaltyRewards { loyaltyRewards(loyaltyId: "some-user-id", where: { omitInvalids: false }) { id name errors { code ruleId } } }
Example Rewards Response
{ "data": { "loyaltyRewardsV2": [ { "id": "3b5bdddc-c7c9-42d8-9332-b0c3f36c8e1c", "name": "Value Powerade Zero", "errors": null }, { "id": "728aaedd-3234-4eae-89af-35cd5672adcb", "name": "Large Dr. Pepper", "errors": null }, { "id": "480122d7-86ff-4db0-965c-7dbb72bb5179", "name": "Value Soft Drinks", "errors": null } ] } }