Skip to content

Commit d86b480

Browse files
author
stlc-bot
committed
Build SDK
Stainless-Generated-From: 779afedcbde4e5cbf1b27e56f3c2ce4b299188fa
1 parent b52ac18 commit d86b480

46 files changed

Lines changed: 2235 additions & 13 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $client = new Client(apiKey: getenv('CONTEXT_DEV_API_KEY') ?: 'My API Key');
3232

3333
$brand = $client->brand->retrieve(domain: 'REPLACE_ME', type: 'by_domain');
3434

35-
var_dump($brand->brand);
35+
var_dump($brand->cache_metadata);
3636
```
3737

3838
### Value Objects

‎src/AI/AIExtractProductResponse.php‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
44

55
namespace ContextDev\AI;
66

7+
use ContextDev\AI\AIExtractProductResponse\CacheMetadata;
78
use ContextDev\AI\AIExtractProductResponse\KeyMetadata;
89
use ContextDev\AI\AIExtractProductResponse\Platform;
910
use ContextDev\AI\AIExtractProductResponse\Product;
1011
use ContextDev\Core\Attributes\Optional;
12+
use ContextDev\Core\Attributes\Required;
1113
use ContextDev\Core\Concerns\SdkModel;
1214
use ContextDev\Core\Contracts\BaseModel;
1315

1416
/**
17+
* @phpstan-import-type CacheMetadataShape from \ContextDev\AI\AIExtractProductResponse\CacheMetadata
1518
* @phpstan-import-type KeyMetadataShape from \ContextDev\AI\AIExtractProductResponse\KeyMetadata
1619
* @phpstan-import-type ProductShape from \ContextDev\AI\AIExtractProductResponse\Product
1720
*
1821
* @phpstan-type AIExtractProductResponseShape = array{
22+
* cacheMetadata: CacheMetadata|CacheMetadataShape,
1923
* isProductPage?: bool|null,
2024
* keyMetadata?: null|KeyMetadata|KeyMetadataShape,
2125
* platform?: null|Platform|value-of<Platform>,
@@ -27,6 +31,12 @@ final class AIExtractProductResponse implements BaseModel
2731
/** @use SdkModel<AIExtractProductResponseShape> */
2832
use SdkModel;
2933

34+
/**
35+
* 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.
36+
*/
37+
#[Required('cache_metadata')]
38+
public CacheMetadata $cacheMetadata;
39+
3040
/**
3141
* Whether the given URL is a product detail page.
3242
*/
@@ -53,6 +63,20 @@ final class AIExtractProductResponse implements BaseModel
5363
#[Optional(nullable: true)]
5464
public ?Product $product;
5565

66+
/**
67+
* `new AIExtractProductResponse()` is missing required properties by the API.
68+
*
69+
* To enforce required parameters use
70+
* ```
71+
* AIExtractProductResponse::with(cacheMetadata: ...)
72+
* ```
73+
*
74+
* Otherwise ensure the following setters are called
75+
*
76+
* ```
77+
* (new AIExtractProductResponse)->withCacheMetadata(...)
78+
* ```
79+
*/
5680
public function __construct()
5781
{
5882
$this->initialize();
@@ -63,18 +87,22 @@ public function __construct()
6387
*
6488
* You must use named parameters to construct any parameters with a default value.
6589
*
90+
* @param CacheMetadata|CacheMetadataShape $cacheMetadata
6691
* @param KeyMetadata|KeyMetadataShape|null $keyMetadata
6792
* @param Platform|value-of<Platform>|null $platform
6893
* @param Product|ProductShape|null $product
6994
*/
7095
public static function with(
96+
CacheMetadata|array $cacheMetadata,
7197
?bool $isProductPage = null,
7298
KeyMetadata|array|null $keyMetadata = null,
7399
Platform|string|null $platform = null,
74100
Product|array|null $product = null,
75101
): self {
76102
$self = new self;
77103

104+
$self['cacheMetadata'] = $cacheMetadata;
105+
78106
null !== $isProductPage && $self['isProductPage'] = $isProductPage;
79107
null !== $keyMetadata && $self['keyMetadata'] = $keyMetadata;
80108
null !== $platform && $self['platform'] = $platform;
@@ -83,6 +111,19 @@ public static function with(
83111
return $self;
84112
}
85113

114+
/**
115+
* 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.
116+
*
117+
* @param CacheMetadata|CacheMetadataShape $cacheMetadata
118+
*/
119+
public function withCacheMetadata(CacheMetadata|array $cacheMetadata): self
120+
{
121+
$self = clone $this;
122+
$self['cacheMetadata'] = $cacheMetadata;
123+
124+
return $self;
125+
}
126+
86127
/**
87128
* Whether the given URL is a product detail page.
88129
*/
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ContextDev\AI\AIExtractProductResponse;
6+
7+
use ContextDev\AI\AIExtractProductResponse\CacheMetadata\Status;
8+
use ContextDev\Core\Attributes\Required;
9+
use ContextDev\Core\Concerns\SdkModel;
10+
use ContextDev\Core\Contracts\BaseModel;
11+
12+
/**
13+
* 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.
14+
*
15+
* @phpstan-type CacheMetadataShape = array{
16+
* ageMs: int, status: Status|value-of<Status>
17+
* }
18+
*/
19+
final class CacheMetadata implements BaseModel
20+
{
21+
/** @use SdkModel<CacheMetadataShape> */
22+
use SdkModel;
23+
24+
/**
25+
* Age of the cached data in milliseconds. Zero for miss and zdr responses.
26+
*/
27+
#[Required('age_ms')]
28+
public int $ageMs;
29+
30+
/**
31+
* Whether the response was served from cache, required fresh work, or honored zero-data-retention cache bypass.
32+
*
33+
* @var value-of<Status> $status
34+
*/
35+
#[Required(enum: Status::class)]
36+
public string $status;
37+
38+
/**
39+
* `new CacheMetadata()` is missing required properties by the API.
40+
*
41+
* To enforce required parameters use
42+
* ```
43+
* CacheMetadata::with(ageMs: ..., status: ...)
44+
* ```
45+
*
46+
* Otherwise ensure the following setters are called
47+
*
48+
* ```
49+
* (new CacheMetadata)->withAgeMs(...)->withStatus(...)
50+
* ```
51+
*/
52+
public function __construct()
53+
{
54+
$this->initialize();
55+
}
56+
57+
/**
58+
* Construct an instance from the required parameters.
59+
*
60+
* You must use named parameters to construct any parameters with a default value.
61+
*
62+
* @param Status|value-of<Status> $status
63+
*/
64+
public static function with(int $ageMs, Status|string $status): self
65+
{
66+
$self = new self;
67+
68+
$self['ageMs'] = $ageMs;
69+
$self['status'] = $status;
70+
71+
return $self;
72+
}
73+
74+
/**
75+
* Age of the cached data in milliseconds. Zero for miss and zdr responses.
76+
*/
77+
public function withAgeMs(int $ageMs): self
78+
{
79+
$self = clone $this;
80+
$self['ageMs'] = $ageMs;
81+
82+
return $self;
83+
}
84+
85+
/**
86+
* Whether the response was served from cache, required fresh work, or honored zero-data-retention cache bypass.
87+
*
88+
* @param Status|value-of<Status> $status
89+
*/
90+
public function withStatus(Status|string $status): self
91+
{
92+
$self = clone $this;
93+
$self['status'] = $status;
94+
95+
return $self;
96+
}
97+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ContextDev\AI\AIExtractProductResponse\CacheMetadata;
6+
7+
/**
8+
* Whether the response was served from cache, required fresh work, or honored zero-data-retention cache bypass.
9+
*/
10+
enum Status: string
11+
{
12+
case HIT = 'hit';
13+
14+
case MISS = 'miss';
15+
16+
case ZDR = 'zdr';
17+
}

‎src/AI/AIExtractProductsResponse.php‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44

55
namespace ContextDev\AI;
66

7+
use ContextDev\AI\AIExtractProductsResponse\CacheMetadata;
78
use ContextDev\AI\AIExtractProductsResponse\KeyMetadata;
89
use ContextDev\AI\AIExtractProductsResponse\Product;
910
use ContextDev\Core\Attributes\Optional;
11+
use ContextDev\Core\Attributes\Required;
1012
use ContextDev\Core\Concerns\SdkModel;
1113
use ContextDev\Core\Contracts\BaseModel;
1214

1315
/**
16+
* @phpstan-import-type CacheMetadataShape from \ContextDev\AI\AIExtractProductsResponse\CacheMetadata
1417
* @phpstan-import-type KeyMetadataShape from \ContextDev\AI\AIExtractProductsResponse\KeyMetadata
1518
* @phpstan-import-type ProductShape from \ContextDev\AI\AIExtractProductsResponse\Product
1619
*
1720
* @phpstan-type AIExtractProductsResponseShape = array{
21+
* cacheMetadata: CacheMetadata|CacheMetadataShape,
1822
* keyMetadata?: null|KeyMetadata|KeyMetadataShape,
1923
* products?: list<Product|ProductShape>|null,
2024
* }
@@ -24,6 +28,12 @@ final class AIExtractProductsResponse implements BaseModel
2428
/** @use SdkModel<AIExtractProductsResponseShape> */
2529
use SdkModel;
2630

31+
/**
32+
* 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.
33+
*/
34+
#[Required('cache_metadata')]
35+
public CacheMetadata $cacheMetadata;
36+
2737
/**
2838
* Metadata about the API key used for the request. Included in every response whenever a valid API key is provided, even when the response status is not 200.
2939
*/
@@ -38,6 +48,20 @@ final class AIExtractProductsResponse implements BaseModel
3848
#[Optional(list: Product::class)]
3949
public ?array $products;
4050

51+
/**
52+
* `new AIExtractProductsResponse()` is missing required properties by the API.
53+
*
54+
* To enforce required parameters use
55+
* ```
56+
* AIExtractProductsResponse::with(cacheMetadata: ...)
57+
* ```
58+
*
59+
* Otherwise ensure the following setters are called
60+
*
61+
* ```
62+
* (new AIExtractProductsResponse)->withCacheMetadata(...)
63+
* ```
64+
*/
4165
public function __construct()
4266
{
4367
$this->initialize();
@@ -48,21 +72,38 @@ public function __construct()
4872
*
4973
* You must use named parameters to construct any parameters with a default value.
5074
*
75+
* @param CacheMetadata|CacheMetadataShape $cacheMetadata
5176
* @param KeyMetadata|KeyMetadataShape|null $keyMetadata
5277
* @param list<Product|ProductShape>|null $products
5378
*/
5479
public static function with(
80+
CacheMetadata|array $cacheMetadata,
5581
KeyMetadata|array|null $keyMetadata = null,
56-
?array $products = null
82+
?array $products = null,
5783
): self {
5884
$self = new self;
5985

86+
$self['cacheMetadata'] = $cacheMetadata;
87+
6088
null !== $keyMetadata && $self['keyMetadata'] = $keyMetadata;
6189
null !== $products && $self['products'] = $products;
6290

6391
return $self;
6492
}
6593

94+
/**
95+
* 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.
96+
*
97+
* @param CacheMetadata|CacheMetadataShape $cacheMetadata
98+
*/
99+
public function withCacheMetadata(CacheMetadata|array $cacheMetadata): self
100+
{
101+
$self = clone $this;
102+
$self['cacheMetadata'] = $cacheMetadata;
103+
104+
return $self;
105+
}
106+
66107
/**
67108
* Metadata about the API key used for the request. Included in every response whenever a valid API key is provided, even when the response status is not 200.
68109
*

0 commit comments

Comments
 (0)