Skip to content

Commit 9cd4a86

Browse files
author
stlc-bot
committed
fix(web-search): explain why a result's page content is missing (#3074)
Stainless-Generated-From: 8a7f36276922d50bde1d50d425c1d794a6c3e3e9
1 parent a117a12 commit 9cd4a86

4 files changed

Lines changed: 52 additions & 3 deletions

File tree

‎src/Web/WebSearchResponse/Result/Highlights.php‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace ContextDev\Web\WebSearchResponse\Result;
66

7+
use ContextDev\Core\Attributes\Optional;
78
use ContextDev\Core\Attributes\Required;
89
use ContextDev\Core\Concerns\SdkModel;
910
use ContextDev\Core\Contracts\BaseModel;
@@ -13,7 +14,9 @@
1314
* Highlights status and passages for this result.
1415
*
1516
* @phpstan-type HighlightsShape = array{
16-
* code: Code|value-of<Code>, highlights: list<string>|null
17+
* code: Code|value-of<Code>,
18+
* highlights: list<string>|null,
19+
* message?: string|null,
1720
* }
1821
*/
1922
final class Highlights implements BaseModel
@@ -37,6 +40,12 @@ final class Highlights implements BaseModel
3740
#[Required(list: 'string')]
3841
public ?array $highlights;
3942

43+
/**
44+
* Why this output is missing. Present only when `code` is a failure.
45+
*/
46+
#[Optional]
47+
public ?string $message;
48+
4049
/**
4150
* `new Highlights()` is missing required properties by the API.
4251
*
@@ -64,13 +73,18 @@ public function __construct()
6473
* @param Code|value-of<Code> $code
6574
* @param list<string>|null $highlights
6675
*/
67-
public static function with(Code|string $code, ?array $highlights): self
68-
{
76+
public static function with(
77+
Code|string $code,
78+
?array $highlights,
79+
?string $message = null
80+
): self {
6981
$self = new self;
7082

7183
$self['code'] = $code;
7284
$self['highlights'] = $highlights;
7385

86+
null !== $message && $self['message'] = $message;
87+
7488
return $self;
7589
}
7690

@@ -99,4 +113,15 @@ public function withHighlights(?array $highlights): self
99113

100114
return $self;
101115
}
116+
117+
/**
118+
* Why this output is missing. Present only when `code` is a failure.
119+
*/
120+
public function withMessage(string $message): self
121+
{
122+
$self = clone $this;
123+
$self['message'] = $message;
124+
125+
return $self;
126+
}
102127
}

‎src/Web/WebSearchResponse/Result/Highlights/Code.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ enum Code: string
2121

2222
case WEBSITE_BLOCKED = 'WEBSITE_BLOCKED';
2323

24+
case WEBSITE_NOT_FOUND = 'WEBSITE_NOT_FOUND';
25+
2426
case ERROR = 'ERROR';
2527
}

‎src/Web/WebSearchResponse/Result/Markdown.php‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* code: Code|value-of<Code>,
1919
* markdown: string|null,
2020
* finalDomState?: null|FinalDomState|value-of<FinalDomState>,
21+
* message?: string|null,
2122
* }
2223
*/
2324
final class Markdown implements BaseModel
@@ -47,6 +48,12 @@ final class Markdown implements BaseModel
4748
#[Optional('finalDOMState', enum: FinalDomState::class)]
4849
public ?string $finalDomState;
4950

51+
/**
52+
* Why this output is missing. Present only when `code` is a failure.
53+
*/
54+
#[Optional]
55+
public ?string $message;
56+
5057
/**
5158
* `new Markdown()` is missing required properties by the API.
5259
*
@@ -78,13 +85,15 @@ public static function with(
7885
Code|string $code,
7986
?string $markdown,
8087
FinalDomState|string|null $finalDomState = null,
88+
?string $message = null,
8189
): self {
8290
$self = new self;
8391

8492
$self['code'] = $code;
8593
$self['markdown'] = $markdown;
8694

8795
null !== $finalDomState && $self['finalDomState'] = $finalDomState;
96+
null !== $message && $self['message'] = $message;
8897

8998
return $self;
9099
}
@@ -125,4 +134,15 @@ public function withFinalDomState(FinalDomState|string $finalDomState): self
125134

126135
return $self;
127136
}
137+
138+
/**
139+
* Why this output is missing. Present only when `code` is a failure.
140+
*/
141+
public function withMessage(string $message): self
142+
{
143+
$self = clone $this;
144+
$self['message'] = $message;
145+
146+
return $self;
147+
}
128148
}

‎src/Web/WebSearchResponse/Result/Markdown/Code.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ enum Code: string
2121

2222
case WEBSITE_BLOCKED = 'WEBSITE_BLOCKED';
2323

24+
case WEBSITE_NOT_FOUND = 'WEBSITE_NOT_FOUND';
25+
2426
case ERROR = 'ERROR';
2527
}

0 commit comments

Comments
 (0)