export type GetApiV1StatusOptions = {baseUrl: string, APITOKEN?: string | undefined, fetch?: typeof fetch | undefined}; /** * Provides information on the status of the service * * GET /v1/status */ export const getApiV1Status = async (options: GetApiV1StatusOptions) => { const {baseUrl, fetch: fetchFn = fetch, APITOKEN} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (APITOKEN !== undefined) headers.set("X-Quandoo-AuthToken", APITOKEN) const url = `${baseUrl.replace(/\/+$/, '')}/v1/status${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 };