Speed up entitlement lookups by having a simple API to see what products someone bought (receipts)
Wiki home: https://cnissues.atlassian.net/wiki/spaces/CMSG/pages/327942320/Entitlement+Receipts+Service
RateLimit-*
headers
to check your quota. In the GraphQL Playground, you can set auth by adding something like this to HTTP HEADERS:{
"Authorization": "Basic YW5kaTp0ZXN0"
}
Definitions are stored as living documentation in the GraphQL schema to avoid duplicating work.
Basic entitlement query:
mutation ExampleFetch {
fetchProfile(input: { profile: { amgUuid: "24851284-1fae-4818-b92e-56da11555c6f" } }) {
profile {
viewEntitlements {
product
starts
expires
__typename
}
}
}
}
Only return CDS results
mutation ExampleOnlyCDS {
fetchProfile(
input: {
profile: { amgUuid: "24851284-1fae-4818-b92e-56da11555c6f" }
refreshPolicy: "refresh"
}
) {
didRefresh
didRefreshReason
profile {
viewEntitlements {
... on CdsViewEntitlements {
product
starts
expires
}
}
}
}
}
View what we know about a profile
query ExampleGetProfileByEmail {
profile(email: "active@tt.com") {
amgUuid
receipts {
providerId
v
timestamp
}
viewEntitlements {
product
starts
expires
}
}
}
Force a refresh of a profile
mutation ExampleRefresh {
fetchProfile(
input: {
profile: { amgUuid: "24851284-1fae-4818-b92e-56da11555c6f" }
refreshPolicy: "refresh"
}
) {
profile {
amgUuid
receipts {
providerId
timestamp
}
viewEntitlements {
product
starts
expires
}
}
}
}
entitlements-receiptsThe original data from providers is stored in entitlements-receipts with
amgUuid as the partition key and the providerId as the sort key. This is
just a cache. All this data can get retrieved again.
CDS Global
---
amgUuid: '58383a82-eadc-4172-8685-ca800e7b9500'
providerId: 'cds.<accountNumber>.<magCode>'
data: <json body>
timestamp: 1531254336997
CDS UK
---
amgUuid: '58383a82-eadc-4172-8685-ca800e7b9500'
providerId: 'cdsuk.<URN>.<originator>'
data: <json body>
timestamp: 1531254336997
Apple Receipt
---
amgUuid: '58383a82-eadc-4172-8685-ca800e7b9500'
providerId: 'apple.<sha1 of base64 receipt data>'
data: <json verified receipt data>
timestamp: 1531254336997
Andros aka CNEE Legacy receipt
---
amgUuid: '58383a82-eadc-4172-8685-ca800e7b9500'
providerId: 'andros.<coupon code>'
data: <json body>
timestamp: 1531254336997
providerId as a sort key?Instead of throwing everything into one document, we could use amgUuid as the
partition key and provider id as a sort key with a query.
GetItem is slightly faster and cheaper than QueryThere are some special fields you may see:
v: The current schema version (set by SCHEMA_VERSION in config.js)_b: This item was touched by the ElasticSearch backfill processnodemon available globally, npm i -g nodemonAWS_SESSION_TOKEN. See: https://cnissues.atlassian.net/wiki/spaces/DEVOPS/pages/6717524/AWS+CLI+AccessVAULT_TOKEN=$(cat ~/.vault-token) VAULT_SECRET_PATH=secret/colab/entitlements/staging/app node index.jsnpm install
lerna bootstrap
npm run dev