export type GetApiApiV2AssetsIdentifierArgs = {identifier: string, language?: string | undefined, version?: ('working' | 'live') | undefined}; export type GetApiApiV2AssetsIdentifierOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get raw file-asset content by identifier * * GET /api/v2/assets/{identifier} */ export const getApiApiV2AssetsIdentifier = async (args: GetApiApiV2AssetsIdentifierArgs, options: GetApiApiV2AssetsIdentifierOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.language != null) query.append("language", String(args.language)) if (args.version != null) query.append("version", String(args.version)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/assets/${encodeURIComponent(String(args.identifier))}${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 res.blob() };