Skip to content

Commit a12acad

Browse files
author
stlc-bot
committed
fix(api): guarantee search descriptions and align response types (#1089)
Stainless-Generated-From: 7c35f68569d5bf7fec90ee8e651f7329920a5831
1 parent 43ced60 commit a12acad

4 files changed

Lines changed: 117 additions & 103 deletions

File tree

‎src/Brand/BrandGetResponse.php‎

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,54 @@
1313
use ContextDev\Core\Contracts\BaseModel;
1414

1515
/**
16-
* @phpstan-import-type CacheMetadataShape from \ContextDev\Brand\BrandGetResponse\CacheMetadata
1716
* @phpstan-import-type BrandShape from \ContextDev\Brand\BrandGetResponse\Brand
17+
* @phpstan-import-type CacheMetadataShape from \ContextDev\Brand\BrandGetResponse\CacheMetadata
1818
* @phpstan-import-type KeyMetadataShape from \ContextDev\Brand\BrandGetResponse\KeyMetadata
1919
*
2020
* @phpstan-type BrandGetResponseShape = array{
21+
* brand: Brand|BrandShape,
2122
* cacheMetadata: CacheMetadata|CacheMetadataShape,
23+
* code: int,
2224
* requestID: string,
23-
* brand?: null|Brand|BrandShape,
24-
* code?: int|null,
25+
* status: string,
2526
* keyMetadata?: null|KeyMetadata|KeyMetadataShape,
2627
* partial?: bool|null,
27-
* status?: string|null,
2828
* }
2929
*/
3030
final class BrandGetResponse implements BaseModel
3131
{
3232
/** @use SdkModel<BrandGetResponseShape> */
3333
use SdkModel;
3434

35+
/**
36+
* Detailed brand information.
37+
*/
38+
#[Required]
39+
public Brand $brand;
40+
3541
/**
3642
* Cache outcome for this response. Composite responses are hits only when every cache-controlled fetch contributing to the output was a hit; age_ms is the oldest contributing hit.
3743
*/
3844
#[Required('cache_metadata')]
3945
public CacheMetadata $cacheMetadata;
4046

4147
/**
42-
* Unique id of this API call, also sent in the X-Request-Id response header. Quote it when contacting support about a failed request.
48+
* HTTP status code.
4349
*/
44-
#[Required('request_id')]
45-
public string $requestID;
50+
#[Required]
51+
public int $code;
4652

4753
/**
48-
* Detailed brand information.
54+
* Unique id of this API call, also sent in the X-Request-Id response header. Quote it when contacting support about a failed request.
4955
*/
50-
#[Optional]
51-
public ?Brand $brand;
56+
#[Required('request_id')]
57+
public string $requestID;
5258

5359
/**
54-
* HTTP status code.
60+
* Status of the response, e.g., 'ok'.
5561
*/
56-
#[Optional]
57-
public ?int $code;
62+
#[Required]
63+
public string $status;
5864

5965
/**
6066
* Credit usage, included whenever a valid API key is provided.
@@ -68,24 +74,25 @@ final class BrandGetResponse implements BaseModel
6874
#[Optional]
6975
public ?bool $partial;
7076

71-
/**
72-
* Status of the response, e.g., 'ok'.
73-
*/
74-
#[Optional]
75-
public ?string $status;
76-
7777
/**
7878
* `new BrandGetResponse()` is missing required properties by the API.
7979
*
8080
* To enforce required parameters use
8181
* ```
82-
* BrandGetResponse::with(cacheMetadata: ..., requestID: ...)
82+
* BrandGetResponse::with(
83+
* brand: ..., cacheMetadata: ..., code: ..., requestID: ..., status: ...
84+
* )
8385
* ```
8486
*
8587
* Otherwise ensure the following setters are called
8688
*
8789
* ```
88-
* (new BrandGetResponse)->withCacheMetadata(...)->withRequestID(...)
90+
* (new BrandGetResponse)
91+
* ->withBrand(...)
92+
* ->withCacheMetadata(...)
93+
* ->withCode(...)
94+
* ->withRequestID(...)
95+
* ->withStatus(...)
8996
* ```
9097
*/
9198
public function __construct()
@@ -98,29 +105,42 @@ public function __construct()
98105
*
99106
* You must use named parameters to construct any parameters with a default value.
100107
*
108+
* @param Brand|BrandShape $brand
101109
* @param CacheMetadata|CacheMetadataShape $cacheMetadata
102-
* @param Brand|BrandShape|null $brand
103110
* @param KeyMetadata|KeyMetadataShape|null $keyMetadata
104111
*/
105112
public static function with(
113+
Brand|array $brand,
106114
CacheMetadata|array $cacheMetadata,
115+
int $code,
107116
string $requestID,
108-
Brand|array|null $brand = null,
109-
?int $code = null,
117+
string $status,
110118
KeyMetadata|array|null $keyMetadata = null,
111119
?bool $partial = null,
112-
?string $status = null,
113120
): self {
114121
$self = new self;
115122

123+
$self['brand'] = $brand;
116124
$self['cacheMetadata'] = $cacheMetadata;
125+
$self['code'] = $code;
117126
$self['requestID'] = $requestID;
127+
$self['status'] = $status;
118128

119-
null !== $brand && $self['brand'] = $brand;
120-
null !== $code && $self['code'] = $code;
121129
null !== $keyMetadata && $self['keyMetadata'] = $keyMetadata;
122130
null !== $partial && $self['partial'] = $partial;
123-
null !== $status && $self['status'] = $status;
131+
132+
return $self;
133+
}
134+
135+
/**
136+
* Detailed brand information.
137+
*
138+
* @param Brand|BrandShape $brand
139+
*/
140+
public function withBrand(Brand|array $brand): self
141+
{
142+
$self = clone $this;
143+
$self['brand'] = $brand;
124144

125145
return $self;
126146
}
@@ -139,36 +159,34 @@ public function withCacheMetadata(CacheMetadata|array $cacheMetadata): self
139159
}
140160

141161
/**
142-
* Unique id of this API call, also sent in the X-Request-Id response header. Quote it when contacting support about a failed request.
162+
* HTTP status code.
143163
*/
144-
public function withRequestID(string $requestID): self
164+
public function withCode(int $code): self
145165
{
146166
$self = clone $this;
147-
$self['requestID'] = $requestID;
167+
$self['code'] = $code;
148168

149169
return $self;
150170
}
151171

152172
/**
153-
* Detailed brand information.
154-
*
155-
* @param Brand|BrandShape $brand
173+
* Unique id of this API call, also sent in the X-Request-Id response header. Quote it when contacting support about a failed request.
156174
*/
157-
public function withBrand(Brand|array $brand): self
175+
public function withRequestID(string $requestID): self
158176
{
159177
$self = clone $this;
160-
$self['brand'] = $brand;
178+
$self['requestID'] = $requestID;
161179

162180
return $self;
163181
}
164182

165183
/**
166-
* HTTP status code.
184+
* Status of the response, e.g., 'ok'.
167185
*/
168-
public function withCode(int $code): self
186+
public function withStatus(string $status): self
169187
{
170188
$self = clone $this;
171-
$self['code'] = $code;
189+
$self['status'] = $status;
172190

173191
return $self;
174192
}
@@ -196,15 +214,4 @@ public function withPartial(bool $partial): self
196214

197215
return $self;
198216
}
199-
200-
/**
201-
* Status of the response, e.g., 'ok'.
202-
*/
203-
public function withStatus(string $status): self
204-
{
205-
$self = clone $this;
206-
$self['status'] = $status;
207-
208-
return $self;
209-
}
210217
}

0 commit comments

Comments
 (0)