export type GetApiV1DomainArgs = {search?: string | undefined, order?: ('Asc' | 'Desc') | undefined}; export type GetApiV1DomainOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * List all purchased domains and mailboxes with provisioning status * * GET /v1/domain */ export const getApiV1Domain = async (args: GetApiV1DomainArgs, options: GetApiV1DomainOptions) => { const {baseUrl, fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.search != null) query.append("search", String(args.search)) if (args.order != null) query.append("order", String(args.order)) if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/domain${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 };