export type GetApiV1FormsArgs = {per_page?: number | undefined, page_no?: number | undefined}; export type GetApiV1FormsOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; /** * List all the dispatch stop forms * * GET /v1/forms */ export const getApiV1Forms = async (args: GetApiV1FormsArgs, options?: GetApiV1FormsOptions) => { const {baseUrl = "https://api.gomotive.com", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.per_page != null) query.append("per_page", String(args.per_page)) if (args.page_no != null) query.append("page_no", String(args.page_no)) if (sec0 !== undefined) headers.set("x-api-key", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/v1/forms${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 };