diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 427b8ec..21f6056 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.9.0" + ".": "2.10.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 97db86d..90b5514 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 40 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-a0dda03bbb600917cfb9add468cc4c8c84351a8dbbf61644dbc353263ca1748f.yml -openapi_spec_hash: c24264f32a46d9317aac5af9d6a396f7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-1c93116e47cab52ea63490f5bca186ed3acda8bbd7f0ce5a320effb9f5b72b1f.yml +openapi_spec_hash: f56204d55bd4bffb6e4d50d6a5d9471a config_hash: 920678668dd2da6f8966fbf1b8fde4e2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f203b9..929dc1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 2.10.0 (2026-08-08) + +Full Changelog: [v2.9.0...v2.10.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.9.0...v2.10.0) + +### Features + +* **api:** api update ([2f3a923](https://github.com/context-dot-dev/context-php-sdk/commit/2f3a923880a205a86d61f10d2aad236496f56144)) + ## 2.9.0 (2026-08-07) Full Changelog: [v2.8.0...v2.9.0](https://github.com/context-dot-dev/context-php-sdk/compare/v2.8.0...v2.9.0) diff --git a/README.md b/README.md index 8272f7d..462850f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The REST API documentation can be found on [docs.context.dev](https://docs.conte ``` -composer require "context-dev/context-dev-php 2.9.0" +composer require "context-dev/context-dev-php 2.10.0" ``` diff --git a/src/Batch/BatchGetResultsResponse/Data/ScrapedPage/Metadata.php b/src/Batch/BatchGetResultsResponse/Data/ScrapedPage/Metadata.php index d3619e8..db6b217 100644 --- a/src/Batch/BatchGetResultsResponse/Data/ScrapedPage/Metadata.php +++ b/src/Batch/BatchGetResultsResponse/Data/ScrapedPage/Metadata.php @@ -6,6 +6,7 @@ use ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\AdditionalMeta; use ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\Alternate; +use ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\Heading; use ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\OpenGraph; use ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\Twitter; use ContextDev\Core\Attributes\Optional; @@ -22,6 +23,7 @@ * @phpstan-import-type TwitterVariants from \ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\Twitter * @phpstan-import-type AdditionalMetaShape from \ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\AdditionalMeta * @phpstan-import-type AlternateShape from \ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\Alternate + * @phpstan-import-type HeadingShape from \ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\Heading * @phpstan-import-type OpenGraphShape from \ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\OpenGraph * @phpstan-import-type TwitterShape from \ContextDev\Batch\BatchGetResultsResponse\Data\ScrapedPage\Metadata\Twitter * @@ -34,6 +36,7 @@ * canonicalURL?: string|null, * description?: string|null, * favicon?: string|null, + * headings?: list|null, * image?: string|null, * jsonLd?: list>|null, * keywords?: list|null, @@ -104,6 +107,14 @@ final class Metadata implements BaseModel #[Optional] public ?string $favicon; + /** + * Page headings (h1–h6) in document order, extracted from the unfiltered document. Capped at the first 500 headings. Omitted when the page has none. + * + * @var list|null $headings + */ + #[Optional(list: Heading::class)] + public ?array $headings; + /** * Primary resolved preview image from Open Graph, Twitter, or image metadata. */ @@ -204,6 +215,7 @@ public function __construct() * * @param array|null $additionalMeta * @param list|null $alternates + * @param list|null $headings * @param list>|null $jsonLd * @param list|null $keywords * @param array|null $openGraph @@ -218,6 +230,7 @@ public static function with( ?string $canonicalURL = null, ?string $description = null, ?string $favicon = null, + ?array $headings = null, ?string $image = null, ?array $jsonLd = null, ?array $keywords = null, @@ -241,6 +254,7 @@ public static function with( null !== $canonicalURL && $self['canonicalURL'] = $canonicalURL; null !== $description && $self['description'] = $description; null !== $favicon && $self['favicon'] = $favicon; + null !== $headings && $self['headings'] = $headings; null !== $image && $self['image'] = $image; null !== $jsonLd && $self['jsonLd'] = $jsonLd; null !== $keywords && $self['keywords'] = $keywords; @@ -348,6 +362,19 @@ public function withFavicon(string $favicon): self return $self; } + /** + * Page headings (h1–h6) in document order, extracted from the unfiltered document. Capped at the first 500 headings. Omitted when the page has none. + * + * @param list $headings + */ + public function withHeadings(array $headings): self + { + $self = clone $this; + $self['headings'] = $headings; + + return $self; + } + /** * Primary resolved preview image from Open Graph, Twitter, or image metadata. */ diff --git a/src/Batch/BatchGetResultsResponse/Data/ScrapedPage/Metadata/Heading.php b/src/Batch/BatchGetResultsResponse/Data/ScrapedPage/Metadata/Heading.php new file mode 100644 index 0000000..f6e9aa2 --- /dev/null +++ b/src/Batch/BatchGetResultsResponse/Data/ScrapedPage/Metadata/Heading.php @@ -0,0 +1,86 @@ + */ + use SdkModel; + + /** + * Heading level, 1–6 (from h1–h6). + */ + #[Required] + public int $level; + + /** + * Heading text with whitespace collapsed, truncated to 1000 characters. + */ + #[Required] + public string $text; + + /** + * `new Heading()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Heading::with(level: ..., text: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Heading)->withLevel(...)->withText(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(int $level, string $text): self + { + $self = new self; + + $self['level'] = $level; + $self['text'] = $text; + + return $self; + } + + /** + * Heading level, 1–6 (from h1–h6). + */ + public function withLevel(int $level): self + { + $self = clone $this; + $self['level'] = $level; + + return $self; + } + + /** + * Heading text with whitespace collapsed, truncated to 1000 characters. + */ + public function withText(string $text): self + { + $self = clone $this; + $self['text'] = $text; + + return $self; + } +} diff --git a/src/Services/WebRawService.php b/src/Services/WebRawService.php index 953b50d..f472881 100644 --- a/src/Services/WebRawService.php +++ b/src/Services/WebRawService.php @@ -482,7 +482,7 @@ public function webScrapeImages( * | HTTP status | Billed? | Meaning | * | --- | --- | --- | * | 200 | Yes — 1 credit, or 2 credits with actions | Successful scrape, including a zero-length result when includeSelectors matched nothing | - * | 400 | No | Invalid input, skipped PDF, or the page could not be scraped | + * | 400 | No | Invalid input, skipped PDF, or the page could not be scraped. error_code WEBSITE_BLOCKED specifically means the site answered with an anti-bot challenge, CAPTCHA wall, or login shell instead of the page (even when the site returned HTTP 200) — retrying later or from another country sometimes succeeds | * | 401 / 403 | No | Invalid/disabled key, insufficient permissions, or credits exhausted; inspect error_code | * | 404 | No | Target page returned or fingerprinted as not found | * | 408 | No | Request timed out | diff --git a/src/Services/WebService.php b/src/Services/WebService.php index 27e6e7e..f6cc793 100644 --- a/src/Services/WebService.php +++ b/src/Services/WebService.php @@ -593,7 +593,7 @@ public function webScrapeImages( * | HTTP status | Billed? | Meaning | * | --- | --- | --- | * | 200 | Yes — 1 credit, or 2 credits with actions | Successful scrape, including a zero-length result when includeSelectors matched nothing | - * | 400 | No | Invalid input, skipped PDF, or the page could not be scraped | + * | 400 | No | Invalid input, skipped PDF, or the page could not be scraped. error_code WEBSITE_BLOCKED specifically means the site answered with an anti-bot challenge, CAPTCHA wall, or login shell instead of the page (even when the site returned HTTP 200) — retrying later or from another country sometimes succeeds | * | 401 / 403 | No | Invalid/disabled key, insufficient permissions, or credits exhausted; inspect error_code | * | 404 | No | Target page returned or fingerprinted as not found | * | 408 | No | Request timed out | diff --git a/src/Version.php b/src/Version.php index fc11686..220673a 100644 --- a/src/Version.php +++ b/src/Version.php @@ -5,5 +5,5 @@ namespace ContextDev; // x-release-please-start-version -const VERSION = '2.9.0'; +const VERSION = '2.10.0'; // x-release-please-end diff --git a/src/Web/WebWebCrawlMdResponse/Result/Metadata.php b/src/Web/WebWebCrawlMdResponse/Result/Metadata.php index 6da696c..26e7d76 100644 --- a/src/Web/WebWebCrawlMdResponse/Result/Metadata.php +++ b/src/Web/WebWebCrawlMdResponse/Result/Metadata.php @@ -11,6 +11,7 @@ use ContextDev\Core\Conversion\MapOf; use ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\AdditionalMeta; use ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\Alternate; +use ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\Heading; use ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\OpenGraph; use ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\Twitter; @@ -20,6 +21,7 @@ * @phpstan-import-type TwitterVariants from \ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\Twitter * @phpstan-import-type AdditionalMetaShape from \ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\AdditionalMeta * @phpstan-import-type AlternateShape from \ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\Alternate + * @phpstan-import-type HeadingShape from \ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\Heading * @phpstan-import-type OpenGraphShape from \ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\OpenGraph * @phpstan-import-type TwitterShape from \ContextDev\Web\WebWebCrawlMdResponse\Result\Metadata\Twitter * @@ -37,6 +39,7 @@ * canonicalURL?: string|null, * description?: string|null, * favicon?: string|null, + * headings?: list|null, * image?: string|null, * jsonLd?: list>|null, * keywords?: list|null, @@ -136,6 +139,14 @@ final class Metadata implements BaseModel #[Optional] public ?string $favicon; + /** + * Page headings (h1–h6) in document order, extracted from the unfiltered document. Capped at the first 500 headings. Omitted when the page has none. + * + * @var list|null $headings + */ + #[Optional(list: Heading::class)] + public ?array $headings; + /** * Primary resolved preview image from Open Graph, Twitter, or image metadata. */ @@ -245,6 +256,7 @@ public function __construct() * * @param array|null $additionalMeta * @param list|null $alternates + * @param list|null $headings * @param list>|null $jsonLd * @param list|null $keywords * @param array|null $openGraph @@ -264,6 +276,7 @@ public static function with( ?string $canonicalURL = null, ?string $description = null, ?string $favicon = null, + ?array $headings = null, ?string $image = null, ?array $jsonLd = null, ?array $keywords = null, @@ -291,6 +304,7 @@ public static function with( null !== $canonicalURL && $self['canonicalURL'] = $canonicalURL; null !== $description && $self['description'] = $description; null !== $favicon && $self['favicon'] = $favicon; + null !== $headings && $self['headings'] = $headings; null !== $image && $self['image'] = $image; null !== $jsonLd && $self['jsonLd'] = $jsonLd; null !== $keywords && $self['keywords'] = $keywords; @@ -452,6 +466,19 @@ public function withFavicon(string $favicon): self return $self; } + /** + * Page headings (h1–h6) in document order, extracted from the unfiltered document. Capped at the first 500 headings. Omitted when the page has none. + * + * @param list $headings + */ + public function withHeadings(array $headings): self + { + $self = clone $this; + $self['headings'] = $headings; + + return $self; + } + /** * Primary resolved preview image from Open Graph, Twitter, or image metadata. */ diff --git a/src/Web/WebWebCrawlMdResponse/Result/Metadata/Heading.php b/src/Web/WebWebCrawlMdResponse/Result/Metadata/Heading.php new file mode 100644 index 0000000..560f6f5 --- /dev/null +++ b/src/Web/WebWebCrawlMdResponse/Result/Metadata/Heading.php @@ -0,0 +1,86 @@ + */ + use SdkModel; + + /** + * Heading level, 1–6 (from h1–h6). + */ + #[Required] + public int $level; + + /** + * Heading text with whitespace collapsed, truncated to 1000 characters. + */ + #[Required] + public string $text; + + /** + * `new Heading()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Heading::with(level: ..., text: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Heading)->withLevel(...)->withText(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(int $level, string $text): self + { + $self = new self; + + $self['level'] = $level; + $self['text'] = $text; + + return $self; + } + + /** + * Heading level, 1–6 (from h1–h6). + */ + public function withLevel(int $level): self + { + $self = clone $this; + $self['level'] = $level; + + return $self; + } + + /** + * Heading text with whitespace collapsed, truncated to 1000 characters. + */ + public function withText(string $text): self + { + $self = clone $this; + $self['text'] = $text; + + return $self; + } +} diff --git a/src/Web/WebWebScrapeHTMLResponse/Metadata.php b/src/Web/WebWebScrapeHTMLResponse/Metadata.php index 23b827a..13f3662 100644 --- a/src/Web/WebWebScrapeHTMLResponse/Metadata.php +++ b/src/Web/WebWebScrapeHTMLResponse/Metadata.php @@ -11,6 +11,7 @@ use ContextDev\Core\Conversion\MapOf; use ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\AdditionalMeta; use ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\Alternate; +use ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\Heading; use ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\OpenGraph; use ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\Twitter; @@ -22,6 +23,7 @@ * @phpstan-import-type TwitterVariants from \ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\Twitter * @phpstan-import-type AdditionalMetaShape from \ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\AdditionalMeta * @phpstan-import-type AlternateShape from \ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\Alternate + * @phpstan-import-type HeadingShape from \ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\Heading * @phpstan-import-type OpenGraphShape from \ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\OpenGraph * @phpstan-import-type TwitterShape from \ContextDev\Web\WebWebScrapeHTMLResponse\Metadata\Twitter * @@ -34,6 +36,7 @@ * canonicalURL?: string|null, * description?: string|null, * favicon?: string|null, + * headings?: list|null, * image?: string|null, * jsonLd?: list>|null, * keywords?: list|null, @@ -104,6 +107,14 @@ final class Metadata implements BaseModel #[Optional] public ?string $favicon; + /** + * Page headings (h1–h6) in document order, extracted from the unfiltered document. Capped at the first 500 headings. Omitted when the page has none. + * + * @var list|null $headings + */ + #[Optional(list: Heading::class)] + public ?array $headings; + /** * Primary resolved preview image from Open Graph, Twitter, or image metadata. */ @@ -204,6 +215,7 @@ public function __construct() * * @param array|null $additionalMeta * @param list|null $alternates + * @param list|null $headings * @param list>|null $jsonLd * @param list|null $keywords * @param array|null $openGraph @@ -218,6 +230,7 @@ public static function with( ?string $canonicalURL = null, ?string $description = null, ?string $favicon = null, + ?array $headings = null, ?string $image = null, ?array $jsonLd = null, ?array $keywords = null, @@ -241,6 +254,7 @@ public static function with( null !== $canonicalURL && $self['canonicalURL'] = $canonicalURL; null !== $description && $self['description'] = $description; null !== $favicon && $self['favicon'] = $favicon; + null !== $headings && $self['headings'] = $headings; null !== $image && $self['image'] = $image; null !== $jsonLd && $self['jsonLd'] = $jsonLd; null !== $keywords && $self['keywords'] = $keywords; @@ -348,6 +362,19 @@ public function withFavicon(string $favicon): self return $self; } + /** + * Page headings (h1–h6) in document order, extracted from the unfiltered document. Capped at the first 500 headings. Omitted when the page has none. + * + * @param list $headings + */ + public function withHeadings(array $headings): self + { + $self = clone $this; + $self['headings'] = $headings; + + return $self; + } + /** * Primary resolved preview image from Open Graph, Twitter, or image metadata. */ diff --git a/src/Web/WebWebScrapeHTMLResponse/Metadata/Heading.php b/src/Web/WebWebScrapeHTMLResponse/Metadata/Heading.php new file mode 100644 index 0000000..08aa555 --- /dev/null +++ b/src/Web/WebWebScrapeHTMLResponse/Metadata/Heading.php @@ -0,0 +1,86 @@ + */ + use SdkModel; + + /** + * Heading level, 1–6 (from h1–h6). + */ + #[Required] + public int $level; + + /** + * Heading text with whitespace collapsed, truncated to 1000 characters. + */ + #[Required] + public string $text; + + /** + * `new Heading()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Heading::with(level: ..., text: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Heading)->withLevel(...)->withText(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(int $level, string $text): self + { + $self = new self; + + $self['level'] = $level; + $self['text'] = $text; + + return $self; + } + + /** + * Heading level, 1–6 (from h1–h6). + */ + public function withLevel(int $level): self + { + $self = clone $this; + $self['level'] = $level; + + return $self; + } + + /** + * Heading text with whitespace collapsed, truncated to 1000 characters. + */ + public function withText(string $text): self + { + $self = clone $this; + $self['text'] = $text; + + return $self; + } +} diff --git a/src/Web/WebWebScrapeMdParams.php b/src/Web/WebWebScrapeMdParams.php index 99db851..f08a7a6 100644 --- a/src/Web/WebWebScrapeMdParams.php +++ b/src/Web/WebWebScrapeMdParams.php @@ -33,7 +33,7 @@ * | HTTP status | Billed? | Meaning | * | --- | --- | --- | * | 200 | Yes — 1 credit, or 2 credits with actions | Successful scrape, including a zero-length result when includeSelectors matched nothing | - * | 400 | No | Invalid input, skipped PDF, or the page could not be scraped | + * | 400 | No | Invalid input, skipped PDF, or the page could not be scraped. error_code WEBSITE_BLOCKED specifically means the site answered with an anti-bot challenge, CAPTCHA wall, or login shell instead of the page (even when the site returned HTTP 200) — retrying later or from another country sometimes succeeds | * | 401 / 403 | No | Invalid/disabled key, insufficient permissions, or credits exhausted; inspect error_code | * | 404 | No | Target page returned or fingerprinted as not found | * | 408 | No | Request timed out | diff --git a/src/Web/WebWebScrapeMdResponse/Metadata.php b/src/Web/WebWebScrapeMdResponse/Metadata.php index b7e67b7..2d33288 100644 --- a/src/Web/WebWebScrapeMdResponse/Metadata.php +++ b/src/Web/WebWebScrapeMdResponse/Metadata.php @@ -11,6 +11,7 @@ use ContextDev\Core\Conversion\MapOf; use ContextDev\Web\WebWebScrapeMdResponse\Metadata\AdditionalMeta; use ContextDev\Web\WebWebScrapeMdResponse\Metadata\Alternate; +use ContextDev\Web\WebWebScrapeMdResponse\Metadata\Heading; use ContextDev\Web\WebWebScrapeMdResponse\Metadata\OpenGraph; use ContextDev\Web\WebWebScrapeMdResponse\Metadata\Twitter; @@ -22,6 +23,7 @@ * @phpstan-import-type TwitterVariants from \ContextDev\Web\WebWebScrapeMdResponse\Metadata\Twitter * @phpstan-import-type AdditionalMetaShape from \ContextDev\Web\WebWebScrapeMdResponse\Metadata\AdditionalMeta * @phpstan-import-type AlternateShape from \ContextDev\Web\WebWebScrapeMdResponse\Metadata\Alternate + * @phpstan-import-type HeadingShape from \ContextDev\Web\WebWebScrapeMdResponse\Metadata\Heading * @phpstan-import-type OpenGraphShape from \ContextDev\Web\WebWebScrapeMdResponse\Metadata\OpenGraph * @phpstan-import-type TwitterShape from \ContextDev\Web\WebWebScrapeMdResponse\Metadata\Twitter * @@ -34,6 +36,7 @@ * canonicalURL?: string|null, * description?: string|null, * favicon?: string|null, + * headings?: list|null, * image?: string|null, * jsonLd?: list>|null, * keywords?: list|null, @@ -104,6 +107,14 @@ final class Metadata implements BaseModel #[Optional] public ?string $favicon; + /** + * Page headings (h1–h6) in document order, extracted from the unfiltered document. Capped at the first 500 headings. Omitted when the page has none. + * + * @var list|null $headings + */ + #[Optional(list: Heading::class)] + public ?array $headings; + /** * Primary resolved preview image from Open Graph, Twitter, or image metadata. */ @@ -204,6 +215,7 @@ public function __construct() * * @param array|null $additionalMeta * @param list|null $alternates + * @param list|null $headings * @param list>|null $jsonLd * @param list|null $keywords * @param array|null $openGraph @@ -218,6 +230,7 @@ public static function with( ?string $canonicalURL = null, ?string $description = null, ?string $favicon = null, + ?array $headings = null, ?string $image = null, ?array $jsonLd = null, ?array $keywords = null, @@ -241,6 +254,7 @@ public static function with( null !== $canonicalURL && $self['canonicalURL'] = $canonicalURL; null !== $description && $self['description'] = $description; null !== $favicon && $self['favicon'] = $favicon; + null !== $headings && $self['headings'] = $headings; null !== $image && $self['image'] = $image; null !== $jsonLd && $self['jsonLd'] = $jsonLd; null !== $keywords && $self['keywords'] = $keywords; @@ -348,6 +362,19 @@ public function withFavicon(string $favicon): self return $self; } + /** + * Page headings (h1–h6) in document order, extracted from the unfiltered document. Capped at the first 500 headings. Omitted when the page has none. + * + * @param list $headings + */ + public function withHeadings(array $headings): self + { + $self = clone $this; + $self['headings'] = $headings; + + return $self; + } + /** * Primary resolved preview image from Open Graph, Twitter, or image metadata. */ diff --git a/src/Web/WebWebScrapeMdResponse/Metadata/Heading.php b/src/Web/WebWebScrapeMdResponse/Metadata/Heading.php new file mode 100644 index 0000000..0d6516c --- /dev/null +++ b/src/Web/WebWebScrapeMdResponse/Metadata/Heading.php @@ -0,0 +1,86 @@ + */ + use SdkModel; + + /** + * Heading level, 1–6 (from h1–h6). + */ + #[Required] + public int $level; + + /** + * Heading text with whitespace collapsed, truncated to 1000 characters. + */ + #[Required] + public string $text; + + /** + * `new Heading()` is missing required properties by the API. + * + * To enforce required parameters use + * ``` + * Heading::with(level: ..., text: ...) + * ``` + * + * Otherwise ensure the following setters are called + * + * ``` + * (new Heading)->withLevel(...)->withText(...) + * ``` + */ + public function __construct() + { + $this->initialize(); + } + + /** + * Construct an instance from the required parameters. + * + * You must use named parameters to construct any parameters with a default value. + */ + public static function with(int $level, string $text): self + { + $self = new self; + + $self['level'] = $level; + $self['text'] = $text; + + return $self; + } + + /** + * Heading level, 1–6 (from h1–h6). + */ + public function withLevel(int $level): self + { + $self = clone $this; + $self['level'] = $level; + + return $self; + } + + /** + * Heading text with whitespace collapsed, truncated to 1000 characters. + */ + public function withText(string $text): self + { + $self = clone $this; + $self['text'] = $text; + + return $self; + } +}