feat: add expiring reset card wallet
This commit is contained in:
@@ -209,6 +209,15 @@ export type WorksTokenPointBalance = {
|
||||
shared_available: boolean | null;
|
||||
};
|
||||
|
||||
export type WorksResetCard = {
|
||||
id: string;
|
||||
status: 'available' | 'expired' | 'redeemed';
|
||||
granted_at: string;
|
||||
expires_at: string;
|
||||
redeemed_at: string | null;
|
||||
redeemed_cycle_id: string | null;
|
||||
};
|
||||
|
||||
export type PlazaCard = {
|
||||
id: string;
|
||||
title: string;
|
||||
@@ -427,6 +436,34 @@ export async function fetchWorksTokenPointBalance(accessToken: string): Promise<
|
||||
return assertSuccess(response, 'points', 'Failed to load Works Square token points');
|
||||
}
|
||||
|
||||
export async function fetchWorksResetCards(accessToken: string): Promise<WorksResetCard[]> {
|
||||
const response = await hostApiFetch<WorksActionResponse<'cards', WorksResetCard[]>>(
|
||||
'/api/works/billing/reset-cards',
|
||||
{
|
||||
headers: {
|
||||
'X-NianCode-Access-Token': accessToken,
|
||||
},
|
||||
},
|
||||
);
|
||||
return assertSuccess(response, 'cards', 'Failed to load Works Square reset cards');
|
||||
}
|
||||
|
||||
export async function redeemWorksResetCard(
|
||||
accessToken: string,
|
||||
cardId: string,
|
||||
): Promise<WorksResetCard> {
|
||||
const response = await hostApiFetch<WorksActionResponse<'card', WorksResetCard>>(
|
||||
`/api/works/billing/reset-cards/${encodeURIComponent(cardId)}/redeem`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-NianCode-Access-Token': accessToken,
|
||||
},
|
||||
},
|
||||
);
|
||||
return assertSuccess(response, 'card', 'Failed to redeem Works Square reset card');
|
||||
}
|
||||
|
||||
export async function fetchMyWorksProjectStatus(
|
||||
accessToken: string,
|
||||
appId: string,
|
||||
|
||||
Reference in New Issue
Block a user