export type GetApiV1ReasonsArgs = {page?: number | undefined, size?: number | undefined, sort_ascending?: boolean | undefined, search_text?: string | undefined, row_count?: number | undefined, auto_sugest?: boolean | undefined, reason_object_type?: number | undefined, reason_action_type?: number | undefined, is_active?: boolean | undefined, show_in_online_booking?: boolean | undefined}; export type GetApiV1ReasonsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve the list of reasons * * GET /v1/reasons */ export const getApiV1Reasons = async (args: GetApiV1ReasonsArgs, options?: GetApiV1ReasonsOptions) => { const {baseUrl = "https://api.zenoti.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page != null) query.append("page", String(args.page)) if (args.size != null) query.append("size", String(args.size)) if (args.sort_ascending != null) query.append("sort_ascending", String(args.sort_ascending)) if (args.search_text != null) query.append("search_text", String(args.search_text)) if (args.row_count != null) query.append("row_count", String(args.row_count)) if (args.auto_sugest != null) query.append("auto_sugest", String(args.auto_sugest)) if (args.reason_object_type != null) query.append("reason_object_type", String(args.reason_object_type)) if (args.reason_action_type != null) query.append("reason_action_type", String(args.reason_action_type)) if (args.is_active != null) query.append("is_active", String(args.is_active)) if (args.show_in_online_booking != null) query.append("show_in_online_booking", String(args.show_in_online_booking)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/reasons${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 (await res.json()) as unknown };