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:
@@ -9,4 +9,5 @@ export * from "./ifeedback_repository";
|
||||
export * from "./imetrics_repository";
|
||||
export * from "./ipayment_repository";
|
||||
export * from "./iprivate_zone_repository";
|
||||
export * from "./iprivate_zone_post_repository";
|
||||
export * from "./iuser_repository";
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import type {
|
||||
PrivateZonePostsResponse,
|
||||
PrivateZonePostUnlockResponse,
|
||||
} from "@/data/schemas/private-zone";
|
||||
import type { Result } from "@/utils/result";
|
||||
|
||||
export interface GetPrivateZonePostsInput {
|
||||
characterId: string;
|
||||
limit?: number;
|
||||
cursor?: string | null;
|
||||
}
|
||||
|
||||
export interface IPrivateZonePostRepository {
|
||||
getPosts(
|
||||
input: GetPrivateZonePostsInput,
|
||||
): Promise<Result<PrivateZonePostsResponse>>;
|
||||
unlockPost(
|
||||
postId: string,
|
||||
expectedCost: number,
|
||||
): Promise<Result<PrivateZonePostUnlockResponse>>;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import type {
|
||||
GetPrivateZonePostsInput,
|
||||
IPrivateZonePostRepository,
|
||||
} from "@/data/repositories/interfaces";
|
||||
import {
|
||||
UnlockPrivateZonePostRequestSchema,
|
||||
type PrivateZonePostsResponse,
|
||||
type PrivateZonePostUnlockResponse,
|
||||
} from "@/data/schemas/private-zone";
|
||||
import {
|
||||
PrivateZonePostApi,
|
||||
privateZonePostApi,
|
||||
} from "@/data/services/api/private_zone_post_api";
|
||||
import { Result } from "@/utils/result";
|
||||
|
||||
import { createLazySingleton } from "./lazy_singleton";
|
||||
|
||||
export class PrivateZonePostRepository implements IPrivateZonePostRepository {
|
||||
constructor(private readonly api: PrivateZonePostApi) {}
|
||||
|
||||
getPosts(
|
||||
input: GetPrivateZonePostsInput,
|
||||
): Promise<Result<PrivateZonePostsResponse>> {
|
||||
return Result.wrap(() => this.api.getPosts(input));
|
||||
}
|
||||
|
||||
unlockPost(
|
||||
postId: string,
|
||||
expectedCost: number,
|
||||
): Promise<Result<PrivateZonePostUnlockResponse>> {
|
||||
return Result.wrap(() =>
|
||||
this.api.unlockPost(
|
||||
postId,
|
||||
UnlockPrivateZonePostRequestSchema.parse({ expectedCost }),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const getPrivateZonePostRepository =
|
||||
createLazySingleton<IPrivateZonePostRepository>(
|
||||
() => new PrivateZonePostRepository(privateZonePostApi),
|
||||
);
|
||||
Reference in New Issue
Block a user