export type GetApiInquiriesArgs = {page?: number | undefined, types?: Array | undefined, ids?: Array | undefined, numbers?: Array | undefined, branch_ids?: Array | undefined, statuses?: Array | undefined, managers?: Array | undefined, clients_ids?: Array | undefined, client_names?: Array | undefined, client_phones?: Array | undefined, asset_uid?: string | undefined, created_at?: Array | undefined, due_date?: Array | undefined, sort?: ('id' | '-id' | 'due_date' | '-due_date') | undefined}; export type GetApiInquiriesOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Inquiries * * GET /inquiries */ export const getApiInquiries = async (args: GetApiInquiriesArgs, options?: GetApiInquiriesOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) for (const item of args.types ?? []) query.append("types", String(item)) for (const item of args.ids ?? []) query.append("ids", String(item)) for (const item of args.numbers ?? []) query.append("numbers", String(item)) for (const item of args.branch_ids ?? []) query.append("branch_ids", String(item)) for (const item of args.statuses ?? []) query.append("statuses", String(item)) for (const item of args.managers ?? []) query.append("managers", String(item)) for (const item of args.clients_ids ?? []) query.append("clients_ids", String(item)) for (const item of args.client_names ?? []) query.append("client_names", String(item)) for (const item of args.client_phones ?? []) query.append("client_phones", String(item)) if (args.asset_uid != null) query.append("asset_uid", String(args.asset_uid)) for (const item of args.created_at ?? []) query.append("created_at", String(item)) for (const item of args.due_date ?? []) query.append("due_date", String(item)) if (args.sort != null) query.append("sort", String(args.sort)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/inquiries${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 };