export type GetApiApiV1RatingsArgs = {favorites?: boolean | undefined, type?: 'music_track' | undefined, sort?: ('createdAt' | 'rating') | undefined, take?: number | undefined, skip?: number | undefined, order?: ('ASC' | 'DESC') | undefined}; export type GetApiApiV1RatingsOptions = {baseUrl: string, LocalUserJWT?: string | undefined, fetch?: typeof fetch | undefined}; /** * 🛡️ Query ratings for the currently logged in user. * * GET /api/v1/ratings */ export const getApiApiV1Ratings = async (args: GetApiApiV1RatingsArgs, options: GetApiApiV1RatingsOptions) => { const {baseUrl, fetch: fetchFn = fetch, LocalUserJWT} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.favorites != null) query.append("favorites", String(args.favorites)) if (args.type != null) query.append("type", String(args.type)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.take != null) query.append("take", String(args.take)) if (args.skip != null) query.append("skip", String(args.skip)) if (args.order != null) query.append("order", String(args.order)) if (LocalUserJWT !== undefined) headers.set('authorization', `Bearer ${LocalUserJWT}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/ratings${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };