// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import { APIPromise } from '../../core/api-promise'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class BasePDF extends APIResource { static override readonly _key: readonly ['browserRendering', 'pdf'] = Object.freeze([ 'browserRendering', 'pdf', ] as const); /** * Fetches rendered PDF from provided URL or HTML. Check available options like * `gotoOptions` and `waitFor*` to control page load behaviour. * * @example * ```ts * const pdf = await client.browserRendering.pdf.create({ * account_id: 'account_id', * html: '

Hello World!

', * }); * * const content = await pdf.blob(); * console.log(content); * ``` */ create(params: PDFCreateParams, options?: RequestOptions): APIPromise { const { account_id, cacheTTL, ...body } = params; return this._client.post(path`/accounts/${account_id}/browser-rendering/pdf`, { query: { cacheTTL }, body, ...options, headers: buildHeaders([{ Accept: 'application/pdf' }, options?.headers]), __binaryResponse: true, }); } } export class PDF extends BasePDF {} export type PDFCreateParams = PDFCreateParams.Variant0 | PDFCreateParams.Variant1; export declare namespace PDFCreateParams { export interface Variant0 { /** * Path param: Account ID. */ account_id: string; /** * Body param: Set the content of the page, eg: `

Hello World!!

`. Either * `html` or `url` must be set. */ html: string; /** * Query param: Cache TTL default is 5s. Set to 0 to disable. */ cacheTTL?: number; /** * Body param: The maximum duration allowed for the browser action to complete * after the page has loaded (such as taking screenshots, extracting content, or * generating PDFs). If this time limit is exceeded, the action stops and returns a * timeout error. */ actionTimeout?: number; /** * Body param: Adds a `