[U] Update userbox SDK

This commit is contained in:
Azalea 2024-12-29 04:49:43 -05:00
parent 29e757ba75
commit d9081563c2

View File

@ -8,7 +8,7 @@ import type {
TrendEntry, TrendEntry,
AquaNetUser, GameOption, AquaNetUser, GameOption,
UserBox, UserBox,
UserBoxItemKind UserItem
} from './generalTypes' } from './generalTypes'
import type { GameName } from './scoring' import type { GameName } from './scoring'
@ -262,13 +262,8 @@ export const USER = {
} }
export const USERBOX = { export const USERBOX = {
getProfile: (): Promise<UserBox> => getProfile: (): Promise<{ user: UserBox, items: UserItem[] }> =>
get('/api/v2/game/chu3/user-box', {}), get('/api/v2/game/chu3/user-box', {}),
getUnlockedItems: (itemId: UserBoxItemKind): Promise<{ itemKind: number, itemId: number, stock: number, isValid: boolean }[]> =>
get(`/api/v2/game/chu3/user-box-item-by-kind`,{ itemId }),
getItemLabels: () => get(`/api/v2/game/chu3/user-box-all-items`, {}).then(it =>
Object.fromEntries(Object.entries(it).map(([key, value]) =>
[key, Object.fromEntries((value as any[]).map(it => [it.id, it.name]))]))),
setUserBox: (d: { field: string, value: number | string }) => setUserBox: (d: { field: string, value: number | string }) =>
post(`/api/v2/game/chu3/user-detail-set`, d), post(`/api/v2/game/chu3/user-detail-set`, d),
} }
@ -305,7 +300,9 @@ export const GAME = {
export const DATA = { export const DATA = {
allMusic: (game: GameName): Promise<AllMusic> => allMusic: (game: GameName): Promise<AllMusic> =>
fetch(`${DATA_HOST}/d/${game}/00/all-music.json`).then(it => it.json()) fetch(`${DATA_HOST}/d/${game}/00/all-music.json`).then(it => it.json()),
allItems: (game: GameName): Promise<Record<string, Record<string, any>>> =>
fetch(`${DATA_HOST}/d/${game}/00/all-items.json`).then(it => it.json()),
} }
export const SETTING = { export const SETTING = {