export type GetApiV1AppointmentsArgs = {span?: string | undefined, from?: string | undefined, until?: string | undefined, date?: string | undefined, date__gte?: string | undefined, date__lte?: string | undefined, time?: string | undefined, time__gte?: string | undefined, time__lte?: string | undefined, statuses?: string | undefined, search?: string | undefined, ordering?: string | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiV1AppointmentsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List appointments * * GET /v1/appointments */ export const getApiV1Appointments = async (args: GetApiV1AppointmentsArgs, options?: GetApiV1AppointmentsOptions) => { const {baseUrl = "https://developer.yezza.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.span != null) query.append("span", String(args.span)) if (args.from != null) query.append("from", String(args.from)) if (args.until != null) query.append("until", String(args.until)) if (args.date != null) query.append("date", String(args.date)) if (args.date__gte != null) query.append("date__gte", String(args.date__gte)) if (args.date__lte != null) query.append("date__lte", String(args.date__lte)) if (args.time != null) query.append("time", String(args.time)) if (args.time__gte != null) query.append("time__gte", String(args.time__gte)) if (args.time__lte != null) query.append("time__lte", String(args.time__lte)) if (args.statuses != null) query.append("statuses", String(args.statuses)) if (args.search != null) query.append("search", String(args.search)) if (args.ordering != null) query.append("ordering", String(args.ordering)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (ApiKeyAuth !== undefined) headers.set("X-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/appointments${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 };