feat(private-zone): add paid video moments
Docker Image / Build and Push Docker Image (push) Successful in 2m5s
Docker Image / Build and Push Docker Image (push) Successful in 2m5s
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import {
|
||||
PrivateZonePostsResponseSchema,
|
||||
PrivateZonePostUnlockResponseSchema,
|
||||
type PrivateZonePostsResponse,
|
||||
type PrivateZonePostUnlockResponse,
|
||||
type UnlockPrivateZonePostRequest,
|
||||
} from "@/data/schemas/private-zone";
|
||||
|
||||
import { ApiPath } from "./api_path";
|
||||
import { httpClient } from "./http_client";
|
||||
import { type ApiEnvelope, unwrap } from "./response_helper";
|
||||
|
||||
export interface GetPrivateZonePostsInput {
|
||||
characterId: string;
|
||||
limit?: number;
|
||||
cursor?: string | null;
|
||||
}
|
||||
|
||||
export class PrivateZonePostApi {
|
||||
async getPosts(
|
||||
input: GetPrivateZonePostsInput,
|
||||
): Promise<PrivateZonePostsResponse> {
|
||||
const env = await httpClient<ApiEnvelope<unknown>>(
|
||||
ApiPath.privateZonePosts,
|
||||
{
|
||||
query: {
|
||||
characterId: input.characterId,
|
||||
limit: input.limit ?? 20,
|
||||
cursor: input.cursor || undefined,
|
||||
},
|
||||
},
|
||||
);
|
||||
return PrivateZonePostsResponseSchema.parse(unwrap(env));
|
||||
}
|
||||
|
||||
async unlockPost(
|
||||
postId: string,
|
||||
body: UnlockPrivateZonePostRequest,
|
||||
): Promise<PrivateZonePostUnlockResponse> {
|
||||
const env = await httpClient<ApiEnvelope<unknown>>(
|
||||
ApiPath.privateZonePostUnlock(postId),
|
||||
{ method: "POST", body },
|
||||
);
|
||||
const parsed = PrivateZonePostUnlockResponseSchema.parse(unwrap(env));
|
||||
return parsed.postId ? parsed : { ...parsed, postId };
|
||||
}
|
||||
}
|
||||
|
||||
export const privateZonePostApi = new PrivateZonePostApi();
|
||||
Reference in New Issue
Block a user