export type GetApiV1ApplicationsArgs = {domain?: string | undefined}; export type GetApiV1ApplicationsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GET /V1/Applications */ export const getApiV1Applications = async (args: GetApiV1ApplicationsArgs, options: GetApiV1ApplicationsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.domain != null) query.append("domain", String(args.domain)) const url = `${baseUrl.replace(/\/+$/, '')}/V1/Applications${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 };