refactor(private-zone): use canonical product name
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import type {
|
||||
GetPrivateAlbumsInput,
|
||||
IPrivateZoneRepository,
|
||||
} from "@/data/repositories/interfaces";
|
||||
import {
|
||||
type PrivateAlbumsResponse,
|
||||
type PrivateAlbumUnlockResponse,
|
||||
UnlockPrivateAlbumRequestSchema,
|
||||
} from "@/data/schemas/private-zone";
|
||||
import {
|
||||
PrivateZoneApi,
|
||||
privateZoneApi,
|
||||
} from "@/data/services/api/private_zone_api";
|
||||
import { Result } from "@/utils/result";
|
||||
|
||||
import { createLazySingleton } from "./lazy_singleton";
|
||||
|
||||
export class PrivateZoneRepository implements IPrivateZoneRepository {
|
||||
constructor(private readonly api: PrivateZoneApi) {}
|
||||
|
||||
getAlbums(
|
||||
input: GetPrivateAlbumsInput,
|
||||
): Promise<Result<PrivateAlbumsResponse>> {
|
||||
return Result.wrap(() => this.api.getAlbums(input));
|
||||
}
|
||||
|
||||
unlockAlbum(
|
||||
albumId: string,
|
||||
expectedCost: number,
|
||||
): Promise<Result<PrivateAlbumUnlockResponse>> {
|
||||
return Result.wrap(() =>
|
||||
this.api.unlockAlbum(
|
||||
albumId,
|
||||
UnlockPrivateAlbumRequestSchema.parse({ expectedCost }),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const getPrivateZoneRepository =
|
||||
createLazySingleton<IPrivateZoneRepository>(
|
||||
() => new PrivateZoneRepository(privateZoneApi),
|
||||
);
|
||||
Reference in New Issue
Block a user