export type GetApiAvatarsV1Args = {name: string}; export type GetApiAvatarsV1Options = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate an avatar image from a name or initials with customizable styling. * * GET /avatars/v1 */ export const getApiAvatarsV1 = async (args: GetApiAvatarsV1Args, options?: GetApiAvatarsV1Options) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.name != null) query.append("name", String(args.name)) const url = `${baseUrl.replace(/\/+$/, '')}/avatars/v1${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 };