All files / src/services favoriteService.ts

53.84% Statements 7/13
100% Branches 0/0
0% Functions 0/6
53.84% Lines 7/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 485x               5x           5x             5x             5x           5x             5x            
import { apiGetAuth, apiPostAuth, apiDeleteAuth } from '@/services/api';
import {
  CreateFavoriteLocationRequest,
  FavoriteEventsResponse,
  FavoriteLocation,
  FavoriteLocationsResponse,
} from '@/models/favorite';
 
export async function listFavoriteEvents(
  token: string,
): Promise<FavoriteEventsResponse> {
  return apiGetAuth<FavoriteEventsResponse>('/me/favorites', token);
}
 
export async function addFavorite(
  eventId: string,
  token: string,
): Promise<void> {
  return apiPostAuth<void>(`/events/${eventId}/favorite`, {}, token);
}
 
export async function removeFavorite(
  eventId: string,
  token: string,
): Promise<void> {
  return apiDeleteAuth<void>(`/events/${eventId}/favorite`, token);
}
 
export async function listFavoriteLocations(
  token: string,
): Promise<FavoriteLocationsResponse> {
  return apiGetAuth<FavoriteLocationsResponse>('/me/favorite-locations', token);
}
 
export async function createFavoriteLocation(
  request: CreateFavoriteLocationRequest,
  token: string,
): Promise<FavoriteLocation> {
  return apiPostAuth<FavoriteLocation>('/me/favorite-locations', request, token);
}
 
export async function deleteFavoriteLocation(
  favoriteLocationId: string,
  token: string,
): Promise<void> {
  return apiDeleteAuth<void>(`/me/favorite-locations/${favoriteLocationId}`, token);
}