50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import {
|
|
PrivateAlbumsResponse,
|
|
PrivateAlbumsResponseSchema,
|
|
PrivateAlbumUnlockResponse,
|
|
PrivateAlbumUnlockResponseSchema,
|
|
UnlockPrivateAlbumRequest,
|
|
} from "@/data/schemas/private-room";
|
|
|
|
import { ApiPath } from "./api_path";
|
|
import { httpClient } from "./http_client";
|
|
import { type ApiEnvelope, unwrap } from "./response_helper";
|
|
|
|
export interface GetPrivateAlbumsInput {
|
|
characterId: string;
|
|
limit?: number;
|
|
}
|
|
|
|
export class PrivateRoomApi {
|
|
async getAlbums(
|
|
input: GetPrivateAlbumsInput,
|
|
): Promise<PrivateAlbumsResponse> {
|
|
const env = await httpClient<ApiEnvelope<unknown>>(
|
|
ApiPath.privateRoomAlbums,
|
|
{
|
|
query: {
|
|
characterId: input.characterId,
|
|
limit: input.limit ?? 20,
|
|
},
|
|
},
|
|
);
|
|
return PrivateAlbumsResponseSchema.parse(unwrap(env));
|
|
}
|
|
|
|
async unlockAlbum(
|
|
albumId: string,
|
|
body: UnlockPrivateAlbumRequest,
|
|
): Promise<PrivateAlbumUnlockResponse> {
|
|
const env = await httpClient<ApiEnvelope<unknown>>(
|
|
ApiPath.privateRoomAlbumUnlock(albumId),
|
|
{
|
|
method: "POST",
|
|
body,
|
|
},
|
|
);
|
|
return PrivateAlbumUnlockResponseSchema.parse(unwrap(env));
|
|
}
|
|
}
|
|
|
|
export const privateRoomApi = new PrivateRoomApi();
|