refactor(private-zoom): rename full feature surface
This commit is contained in:
@@ -6,7 +6,7 @@ import { ApiPath } from "../api_path";
|
||||
describe("ApiPath contract source", () => {
|
||||
it("uses the shared contract path for every static operation", () => {
|
||||
const staticOperations = Object.entries(apiContract).filter(
|
||||
([operationId]) => operationId !== "privateRoomAlbumUnlock",
|
||||
([operationId]) => operationId !== "privateZoomAlbumUnlock",
|
||||
);
|
||||
|
||||
for (const [operationId, operation] of staticOperations) {
|
||||
@@ -17,8 +17,8 @@ describe("ApiPath contract source", () => {
|
||||
});
|
||||
|
||||
it("fills and encodes the private album path parameter", () => {
|
||||
expect(ApiPath.privateRoomAlbumUnlock("album/id 1")).toBe(
|
||||
"/api/private-room/albums/album%2Fid%201/unlock",
|
||||
expect(ApiPath.privateZoomAlbumUnlock("album/id 1")).toBe(
|
||||
"/api/private-zoom/albums/album%2Fid%201/unlock",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ vi.mock("../http_client", () => ({
|
||||
|
||||
import { ChatApi } from "../chat_api";
|
||||
import { CharacterApi } from "../character_api";
|
||||
import { PrivateRoomApi } from "../private_room_api";
|
||||
import { PrivateZoomApi } from "../private_zoom_api";
|
||||
|
||||
const CHARACTER_ID = "elio";
|
||||
|
||||
@@ -146,18 +146,18 @@ describe("multi-character API contract", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("scopes private-room albums to characterId", async () => {
|
||||
it("scopes private-zoom albums to characterId", async () => {
|
||||
httpClientMock.mockResolvedValue({
|
||||
success: true,
|
||||
data: { items: [], creditBalance: 0 },
|
||||
});
|
||||
|
||||
await new PrivateRoomApi().getAlbums({
|
||||
await new PrivateZoomApi().getAlbums({
|
||||
characterId: CHARACTER_ID,
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
expect(httpClientMock).toHaveBeenCalledWith("/api/private-room/albums", {
|
||||
expect(httpClientMock).toHaveBeenCalledWith("/api/private-zoom/albums", {
|
||||
query: { characterId: CHARACTER_ID, limit: 20 },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
"chatHistory": { "method": "get", "path": "/api/chat/history" },
|
||||
"chatUnlockPrivate": { "method": "post", "path": "/api/chat/unlock-private" },
|
||||
"chatUnlockHistory": { "method": "post", "path": "/api/chat/unlock-history" },
|
||||
"privateRoomAlbums": { "method": "get", "path": "/api/private-room/albums" },
|
||||
"privateRoomAlbumUnlock": { "method": "post", "path": "/api/private-room/albums/{albumId}/unlock" },
|
||||
"privateZoomAlbums": { "method": "get", "path": "/api/private-zoom/albums" },
|
||||
"privateZoomAlbumUnlock": { "method": "post", "path": "/api/private-zoom/albums/{albumId}/unlock" },
|
||||
"metricsPwaEvent": { "method": "post", "path": "/api/metrics/pwa/event" },
|
||||
"reportUserInfo": { "method": "post", "path": "/api/data/report-user-info" },
|
||||
"feedback": { "method": "post", "path": "/api/feedback" },
|
||||
|
||||
@@ -81,11 +81,11 @@ export class ApiPath {
|
||||
|
||||
// ============ 私密空间相关 ============
|
||||
/** 获取私密图片包列表 */
|
||||
static readonly privateRoomAlbums = apiContract.privateRoomAlbums.path;
|
||||
static readonly privateZoomAlbums = apiContract.privateZoomAlbums.path;
|
||||
|
||||
/** 解锁私密图片包 */
|
||||
static privateRoomAlbumUnlock(albumId: string): string {
|
||||
return apiContract.privateRoomAlbumUnlock.path.replace(
|
||||
static privateZoomAlbumUnlock(albumId: string): string {
|
||||
return apiContract.privateZoomAlbumUnlock.path.replace(
|
||||
"{albumId}",
|
||||
encodeURIComponent(albumId),
|
||||
);
|
||||
|
||||
@@ -12,6 +12,6 @@ export * from "./feedback_api";
|
||||
export * from "./http_client";
|
||||
export * from "./metrics_api";
|
||||
export * from "./payment_api";
|
||||
export * from "./private_room_api";
|
||||
export * from "./private_zoom_api";
|
||||
export * from "./response_helper";
|
||||
export * from "./user_api";
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import {
|
||||
PrivateAlbumUnlockResponse,
|
||||
PrivateAlbumUnlockResponseSchema,
|
||||
UnlockPrivateAlbumRequest,
|
||||
} from "@/data/schemas/private-room";
|
||||
} from "@/data/schemas/private-zoom";
|
||||
|
||||
import { ApiPath } from "./api_path";
|
||||
import { httpClient } from "./http_client";
|
||||
@@ -15,12 +15,12 @@ export interface GetPrivateAlbumsInput {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export class PrivateRoomApi {
|
||||
export class PrivateZoomApi {
|
||||
async getAlbums(
|
||||
input: GetPrivateAlbumsInput,
|
||||
): Promise<PrivateAlbumsResponse> {
|
||||
const env = await httpClient<ApiEnvelope<unknown>>(
|
||||
ApiPath.privateRoomAlbums,
|
||||
ApiPath.privateZoomAlbums,
|
||||
{
|
||||
query: {
|
||||
characterId: input.characterId,
|
||||
@@ -36,7 +36,7 @@ export class PrivateRoomApi {
|
||||
body: UnlockPrivateAlbumRequest,
|
||||
): Promise<PrivateAlbumUnlockResponse> {
|
||||
const env = await httpClient<ApiEnvelope<unknown>>(
|
||||
ApiPath.privateRoomAlbumUnlock(albumId),
|
||||
ApiPath.privateZoomAlbumUnlock(albumId),
|
||||
{
|
||||
method: "POST",
|
||||
body,
|
||||
@@ -46,4 +46,4 @@ export class PrivateRoomApi {
|
||||
}
|
||||
}
|
||||
|
||||
export const privateRoomApi = new PrivateRoomApi();
|
||||
export const privateZoomApi = new PrivateZoomApi();
|
||||
Reference in New Issue
Block a user