Bunch of contract updates

This commit is contained in:
Eric Bailey
2024-10-28 18:14:36 -05:00
parent 6d0c5078e9
commit e9c6a8461c
9 changed files with 188 additions and 64 deletions
+24 -2
View File
@@ -1,4 +1,5 @@
import {RawSubscriptionObject} from '#/state/purchases/subscriptions/api/types'
import {EntitlementId} from '#/state/purchases/subscriptions/types'
export async function getMainSubscriptions({
did,
@@ -13,10 +14,31 @@ export async function getMainSubscriptions({
if (!res.ok) {
console.error('error fetching subscriptions', res.status, await res.text())
return {
active: [],
available: [],
}
}
const json = await res.json()
return json as {
active: RawSubscriptionObject[]
available: RawSubscriptionObject[]
}
}
export async function getEntitlements({did}: {did: string}) {
const res = await fetch(
`https://bsky-purchases.ngrok.io/entitlements?user=${did}`,
)
if (!res.ok) {
console.error('error fetching entitlements', res.status, await res.text())
return []
}
const {subscriptions} = await res.json()
const {entitlements} = await res.json()
return subscriptions as RawSubscriptionObject[]
return entitlements as {id: EntitlementId}[]
}