refactor: clean up imports, fix typos, and enhance pet action handling

This commit is contained in:
2025-02-01 13:50:27 -03:00
parent f133e18302
commit 8875eb75af
14 changed files with 341 additions and 113 deletions

View File

@@ -1,5 +1,5 @@
import { ApiService } from './index';
import { Pet } from '../../types/Pet';
import { Pet, Resources } from '../../types/Pet';
import { PetCreationRequest } from '../../types/PetCreationRequest';
import { PetUpdateActionRequest } from '../../types/PetUpdateActionRequest';
@@ -28,10 +28,30 @@ export async function createPet(data: PetCreationRequest): Promise<Pet> {
export async function updatePetAction(petId: string, data: PetUpdateActionRequest): Promise<Pet> {
try {
const response = await api.put<Pet>(`/api/v1/pet/${petId}/action`, data);
const response = await api.put<Pet>(`/api/v1/pet/${petId}/action/gather`, data);
return response.data;
} catch (error: any) {
console.error('Failed to update pet action:', error.message);
throw error;
}
}
export async function getPetGatheredResources(petId: string): Promise<Resources> {
try {
const response = await api.get<Resources>(`/api/v1/pet/${petId}/resources/gathered`);
return response.data;
} catch (error: any) {
console.error('Failed to fetch pet gathered resources:', error.message);
throw error;
}
}
export async function putPetCollectResources(petId: string): Promise<Pet> {
try {
const response = await api.put<Pet>(`/api/v1/pet/${petId}/resources/collect`);
return response.data;
} catch (error: any) {
console.error('Failed to collect pet gathered resources:', error.message);
throw error;
}
}