export type GetApiContactreportsArgs = {limit?: number | undefined, type?: number | undefined, group?: number | undefined, start?: string | undefined, stop?: string | undefined, people?: string | undefined, resource?: string | undefined, tag?: string | undefined, page?: number | undefined, notice?: number | undefined, search?: string | undefined, order?: ('id' | 'report' | 'datetimecreated') | undefined, order_dir?: ('asc' | 'desc') | undefined}; export type GetApiContactreportsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Display a listing of contact reports * * GET /contactreports */ export const getApiContactreports = async (args: GetApiContactreportsArgs, options?: GetApiContactreportsOptions) => { const {baseUrl = "https://www.rcac.purdue.edu/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.limit != null) query.append("limit", String(args.limit)) if (args.type != null) query.append("type", String(args.type)) if (args.group != null) query.append("group", String(args.group)) if (args.start != null) query.append("start", String(args.start)) if (args.stop != null) query.append("stop", String(args.stop)) if (args.people != null) query.append("people", String(args.people)) if (args.resource != null) query.append("resource", String(args.resource)) if (args.tag != null) query.append("tag", String(args.tag)) if (args.page != null) query.append("page", String(args.page)) if (args.notice != null) query.append("notice", String(args.notice)) if (args.search != null) query.append("search", String(args.search)) if (args.order != null) query.append("order", String(args.order)) if (args.order_dir != null) query.append("order_dir", String(args.order_dir)) const url = `${baseUrl.replace(/\/+$/, '')}/contactreports${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 };