Files
romm/frontend/src/services/api/platform.ts
2025-08-28 09:48:52 -04:00

48 lines
1.0 KiB
TypeScript

import api from "@/services/api";
import type { Platform } from "@/stores/platforms";
export const platformApi = api;
async function uploadPlatform({
fsSlug,
}: {
fsSlug: string;
}): Promise<{ data: Platform }> {
return api.post("/platforms", { fs_slug: fsSlug });
}
async function getPlatforms(): Promise<{ data: Platform[] }> {
return api.get("/platforms");
}
async function getPlatform(
id: number | undefined,
): Promise<{ data: Platform }> {
return api.get(`/platforms/${id}`);
}
async function getSupportedPlatforms(): Promise<{ data: Platform[] }> {
return api.get("/platforms/supported");
}
async function updatePlatform({
platform,
}: {
platform: Platform;
}): Promise<{ data: Platform }> {
return api.put(`/platforms/${platform.id}`, platform);
}
async function deletePlatform({ platform }: { platform: Platform }) {
return api.delete(`/platforms/${platform.id}`);
}
export default {
uploadPlatform,
getPlatforms,
getPlatform,
getSupportedPlatforms,
updatePlatform,
deletePlatform,
};