export type GetApiIncidentTicketArgs = {page?: number | undefined, limit?: number | undefined, status?: string | undefined, priority?: string | undefined, search?: string | undefined}; export type GetApiIncidentTicketOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get all incident tickets for the business * * GET /incident-ticket */ export const getApiIncidentTicket = async (args: GetApiIncidentTicketArgs, options?: GetApiIncidentTicketOptions) => { const {baseUrl = "http://localhost:5000/api/v1", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.status != null) query.append("status", String(args.status)) if (args.priority != null) query.append("priority", String(args.priority)) if (args.search != null) query.append("search", String(args.search)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/incident-ticket${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 };