...
The client must hit both of the previously mentioned data sources and intersect the data to decide what to present. The sequence in which these queries are executed will depend on the client and its implementation. It is advised to first query Sanity for all "sorted offers" (active system-wide offers), “config offers” (possible personalized offers for any given user), and "reward categories" (active rewards), and then utilize those identifiers to request pertinent information from the Loyalty Engine.
Querying Sanity
There are two ways of querying Sanity:
Using GraphQL
Using GROQ
We strongly suggest using GraphQLTo query Sanity you must us GraphQL, as this is a more widely known querying language. Additionally, using Vendors can use the provided GraphQL playground , vendors will to be able to see the whole schema during development and make necessary adjustments to their queries with ease.
Info |
---|
Recommended reading:
|
...
Using Sanity GraphQL
Info |
---|
GraphQL URL (Playground Available): https://czqk28jt.api.sanity.io/v1/graphql/staging_bk_de/default |
...
Expand | ||
---|---|---|
| ||
To get list of ruleSet available, navigate to https://czqk28jt.apicdn.sanity.io/v1/graphql/dev_bk_aq/default, and search for “ruleSet” in the Schema explorer as seen here: |
Option 2) Using a GROQ Query
Replace
staging_bk_de
with the{{stage}}_{{brand}}_{{country}}
that you desire to query.Replace
{{GROQ_QUERY}}
with the desired GROQ query.
Code Block |
---|
https://czqk28jt.api.sanity.io/v2021-10-21/data/query/staging_bk_de?query={{GROQ_QUERY}} |
Example offers query
Code Block |
---|
https://czqk28jt.api.sanity.io/v2021-10-21/data/query/staging_bk_de?query=*%5B_type+in+%5B%27systemwideOffer%27%2C%27configOffer%27%5D%26%26_id+in*%5B_id%3D%3D%27feature-loyalty-offers-ui-singleton%27%5D%7B%22refs%22%3A%40.liveConfigOffers%5B%5D._ref%2B%40.sortedSystemwideOffers%5B%5D._ref%7D.refs%5B%5D+%5D%7B_id%2C_type%2Cname%2Cincentives%2Cdescription%2ClocalizedImage%2CofferPrice%2CrestaurantAvailabilityValidation%7BvalidationStatus%2ClastValidated%7D%2Crules%2Cdaypart%2CshortCode%2CredemptionMethod%2CloyaltyEngineId%7D |
Example reward query
...
Querying the Loyalty Platform
...
Please 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 kiosks:ids
- a collection of Engine IDs for offers/rewards. This is theloyaltyEngineId
field on every sanity offer/reward document.omitInvalids
- 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
Info |
---|
You should use the
|
...