refactor: 拆分 API Client 资源模块
This commit is contained in:
1 parent
f3adf7bc15
commit
357f271639
24 files changed
+1280
-905
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import type { Offering } from "../types/offering.js";
|
||||
|
||||
export interface OfferingMethods {
|
||||
getPublicOffering(id: string): Promise<Offering>;
|
||||
listPublicOfferings(): Promise<Offering[]>;
|
||||
listAdminOfferings(): Promise<Offering[]>;
|
||||
createAdminOffering(body: Omit<Offering, "id" | "brandId">): Promise<Offering>;
|
||||
updateAdminOffering(
|
||||
id: string,
|
||||
body: Partial<Omit<Offering, "id" | "brandId">>,
|
||||
): Promise<Offering>;
|
||||
deleteAdminOffering(id: string): Promise<{ deleted: boolean }>;
|
||||
}
|
||||
|
||||
export function offeringMethods({ request }: { request: RequestFn }): OfferingMethods {
|
||||
return {
|
||||
getPublicOffering: (id) => request(`/public/offerings/${encodeURIComponent(id)}`),
|
||||
listPublicOfferings: () => request("/public/offerings"),
|
||||
listAdminOfferings: () => request("/admin/workspace/offerings"),
|
||||
createAdminOffering: (body) => request("/admin/workspace/offerings", { method: "POST", body }),
|
||||
updateAdminOffering: (id, body) =>
|
||||
request(`/admin/workspace/offerings/${encodeURIComponent(id)}`, {
|
||||
method: "PATCH",
|
||||
body,
|
||||
}),
|
||||
deleteAdminOffering: (id) =>
|
||||
request(`/admin/workspace/offerings/${encodeURIComponent(id)}`, {
|
||||
method: "DELETE",
|
||||
}),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user