export type GetApiOrdersItemsArgs = {state?: ('active [pending_payment, pending_boassignment, pending_collection, pending_approval, pending_fulfillment]' | 'canceled' | 'complete') | undefined, category?: number | undefined, start?: string | undefined, end?: string | undefined, search?: string | undefined, limit?: number | undefined, page?: number | undefined, order?: ('id' | 'datetimecreated') | undefined, order_dir?: ('asc' | 'desc') | undefined}; export type GetApiOrdersItemsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Display a listing of entries * * GET /orders/items */ export const getApiOrdersItems = async (args: GetApiOrdersItemsArgs, options?: GetApiOrdersItemsOptions) => { const {baseUrl = "https://www.rcac.purdue.edu/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.state != null) query.append("state", String(args.state)) if (args.category != null) query.append("category", String(args.category)) if (args.start != null) query.append("start", String(args.start)) if (args.end != null) query.append("end", String(args.end)) if (args.search != null) query.append("search", String(args.search)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.page != null) query.append("page", String(args.page)) 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(/\/+$/, '')}/orders/items${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 };