import { BaseService } from './base-service' import { Game } from '@/interfaces/game' import { ValidateMetadataDto } from '@/dtos/validate-metadata.dto' import { useAuthStore } from '@/stores/auth' import { AuthDto } from '@/dtos/auth.dto' export class GameService extends BaseService { public getGames(): Promise { return this.get('games') } public getGame(gameId: string): Promise { return this.get(`games/${gameId}`) } public async upload(game: FormData): Promise { const authStr = useAuthStore() return this.postForm(`games`, game, { Authorization: `Bearer ${authStr.getAuth()?.token}` }) } public async update(game: Game): Promise { await this.put(`games`, null) } public async activate(gameId: string): Promise { await this.post(`games/${gameId}/activate`, null) } public async deactivate(gameId: string): Promise { await this.post(`games/${gameId}/deactivate`, null) } public async download(gameId: string): Promise { await this.get(`games/${gameId}/download`) } public async downloadAll(): Promise { await this.get(`games/download`) } public async patch(): Promise { await this.put(`games/patch`, null) } public async minor(): Promise { await this.put(`games/minor`, null) } public async major(): Promise { await this.put(`games/major`, null) } public async metadata(dto: ValidateMetadataDto): Promise { return this.post(`games/metadata`, dto) } public async deleteGame(gameId: string): Promise { await this.delete(`games/${gameId}`) } }