export type GetApiEntitiesEntityTokenDocumentsDocumentTokenOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a Document * * GET /entities/{entity_token}/documents/{document_token} * * Also accepts auth: basic */ export const getApiEntitiesEntityTokenDocumentsDocumentToken = async (options?: GetApiEntitiesEntityTokenDocumentsDocumentTokenOptions) => { const {baseUrl = "https://sandbox.alloy.co/v1", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/*") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/entities/${encodeURIComponent(String(args.entity_token))}/documents/${encodeURIComponent(String(args.document_token))}${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() };