export type GetApiItemIdSteamPreviewArgs = {item_id: number, type?: ('profiles' | 'games') | undefined}; export type GetApiItemIdSteamPreviewOptions = {baseUrl?: string | undefined, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Steam HTML * * GET /{item_id}/steam-preview */ export const getApiItemIdSteamPreview = async (args: GetApiItemIdSteamPreviewArgs, options?: GetApiItemIdSteamPreviewOptions) => { const {baseUrl = "https://api.lzt.market", fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (args.type != null) query.append("type", String(args.type)) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.item_id))}/steam-preview${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.text() };