export type GetApiApiNotesEntityEntityIdArgs = {entity: string, entityId: number, sale_list_id?: number | undefined}; export type GetApiApiNotesEntityEntityIdOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List notes for an entity * * GET /api/notes/{entity}/{entityId} */ export const getApiApiNotesEntityEntityId = async (args: GetApiApiNotesEntityEntityIdArgs, options: GetApiApiNotesEntityEntityIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.sale_list_id != null) query.append("sale_list_id", String(args.sale_list_id)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/notes/${encodeURIComponent(String(args.entity))}/${encodeURIComponent(String(args.entityId))}${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 };