[+] Card summary sdk

pull/14/head
Azalea 2024-02-21 17:42:15 -05:00
parent 06993b9d66
commit cac2f49b06
2 changed files with 27 additions and 11 deletions

View File

@ -24,3 +24,18 @@ export interface UserMe {
cards: Card[]
computedName: string
}
export interface CardSummaryGame {
name: string
rating: number
lastLogin: string
}
export interface CardSummary {
maimai: CardSummaryGame | null
maimai2: CardSummaryGame | null
chusan: CardSummaryGame | null
chunithm: CardSummaryGame | null
ongeki: CardSummaryGame | null
diva: CardSummaryGame | null
}

View File

@ -1,5 +1,5 @@
import { AQUA_HOST } from "./config";
import type { UserMe } from "./generalTypes";
import type { Card, CardSummary, UserMe } from "./generalTypes";
interface RequestInitWithParams extends RequestInit {
params?: { [index: string]: string }
@ -72,18 +72,19 @@ async function login(user: { email: string, password: string, turnstile: string
localStorage.setItem('token', data.token)
}
async function confirmEmail(token: string) {
return await post('/api/v2/user/confirm-email', { token })
}
async function me(): Promise<UserMe> {
return await post('/api/v2/user/me', {})
}
export const USER = {
register,
login,
confirmEmail,
me,
confirmEmail: (token: string) =>
post('/api/v2/user/confirm-email', { token }),
me: (): Promise<UserMe> =>
post('/api/v2/user/me', {}),
isLoggedIn: () => !!localStorage.getItem('token')
}
export const CARD = {
summary: (cardId: string): Promise<{card: Card, summary: CardSummary}> =>
post('/api/v2/card/summary', { cardId }),
bind: (props: { cardId: string, migrate: string }) =>
post('/api/v2/card/bind', props),
}