export type GetApiV1StaffArgs = {startId?: number | undefined, limit?: number | undefined, page?: number | undefined}; export type GetApiV1StaffOptions = {baseUrl: string, https?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Get staff records * * GET /v1/staff */ export const getApiV1Staff = async (args: GetApiV1StaffArgs, options: GetApiV1StaffOptions) => { const {baseUrl, fetch: fetchFn = fetch, https} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.startId != null) query.append("startId", String(args.startId)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.page != null) query.append("page", String(args.page)) if (https !== undefined) headers.set('authorization', `Basic ${btoa(`${https.username}:${https.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/staff${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 };