export type GetApiV0ImageIdArgs = {format?: ('full' | 'card') | undefined, h?: number | undefined, w?: number | undefined, quality?: ('plain' | 'shadow' | 'gold' | 'diamond') | undefined}; export type GetApiV0ImageIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get card image * * GET /v0/image/{id} */ export const getApiV0ImageId = async (args: GetApiV0ImageIdArgs, options?: GetApiV0ImageIdOptions) => { const {baseUrl = "https://api.godsunchained.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.format != null) query.append("format", String(args.format)) if (args.h != null) query.append("h", String(args.h)) if (args.w != null) query.append("w", String(args.w)) if (args.quality != null) query.append("quality", String(args.quality)) const url = `${baseUrl.replace(/\/+$/, '')}/v0/image/${encodeURIComponent(String(args.id))}${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 };