// 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 { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class BaseJson extends APIResource { static override readonly _key: readonly ['browserRendering', 'json'] = Object.freeze([ 'browserRendering', 'json', ] as const); /** * Gets json from a webpage from a provided URL or HTML. Pass `prompt` or `schema` * in the body. Control page loading with `gotoOptions` and `waitFor*` options. * * @example * ```ts * const json = await client.browserRendering.json.create({ * account_id: 'account_id', * url: 'https://www.example.com/', * }); * ``` */ create(params: JsonCreateParams, options?: RequestOptions): APIPromise { const { account_id, cacheTTL, ...body } = params; return ( this._client.post(path`/accounts/${account_id}/browser-rendering/json`, { query: { cacheTTL }, body, ...options, }) as APIPromise<{ result: JsonCreateResponse }> )._thenUnwrap((obj) => obj.result); } } export class Json extends BaseJson {} export type JsonCreateResponse = { [key: string]: unknown }; export interface JsonCreateParams { /** * Path param: Account ID. */ account_id: 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 `