Skip to content

Commit 8628e12

Browse files
feat(api): extract UpdateFileDetailsRequest to model
1 parent 76b7d1a commit 8628e12

File tree

6 files changed

+417
-1
lines changed

6 files changed

+417
-1
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml
33
openapi_spec_hash: 1bfde02a63416c036e9545927f727459
4-
config_hash: a652d68098d82eaf611a49507fb4b831
4+
config_hash: b415c06a3b29485af4601beb94ae1aeb
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ImageKit\Files;
6+
7+
use ImageKit\Core\Concerns\SdkUnion;
8+
use ImageKit\Core\Conversion\Contracts\Converter;
9+
use ImageKit\Core\Conversion\Contracts\ConverterSource;
10+
use ImageKit\Files\UpdateFileDetailsRequest\ChangePublicationStatus;
11+
use ImageKit\Files\UpdateFileDetailsRequest\UpdateFileDetails;
12+
13+
final class UpdateFileDetailsRequest implements ConverterSource
14+
{
15+
use SdkUnion;
16+
17+
/**
18+
* @return list<string|Converter|ConverterSource>|array<string,
19+
* string|Converter|ConverterSource,>
20+
*/
21+
public static function variants(): array
22+
{
23+
return [UpdateFileDetails::class, ChangePublicationStatus::class];
24+
}
25+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ImageKit\Files\UpdateFileDetailsRequest;
6+
7+
use ImageKit\Core\Attributes\Api;
8+
use ImageKit\Core\Concerns\SdkModel;
9+
use ImageKit\Core\Contracts\BaseModel;
10+
use ImageKit\Files\UpdateFileDetailsRequest\ChangePublicationStatus\Publish;
11+
12+
/**
13+
* @phpstan-type change_publication_status = array{publish?: Publish|null}
14+
*/
15+
final class ChangePublicationStatus implements BaseModel
16+
{
17+
/** @use SdkModel<change_publication_status> */
18+
use SdkModel;
19+
20+
/**
21+
* Configure the publication status of a file and its versions.
22+
*/
23+
#[Api(optional: true)]
24+
public ?Publish $publish;
25+
26+
public function __construct()
27+
{
28+
$this->initialize();
29+
}
30+
31+
/**
32+
* Construct an instance from the required parameters.
33+
*
34+
* You must use named parameters to construct any parameters with a default value.
35+
*/
36+
public static function with(?Publish $publish = null): self
37+
{
38+
$obj = new self;
39+
40+
null !== $publish && $obj->publish = $publish;
41+
42+
return $obj;
43+
}
44+
45+
/**
46+
* Configure the publication status of a file and its versions.
47+
*/
48+
public function withPublish(Publish $publish): self
49+
{
50+
$obj = clone $this;
51+
$obj->publish = $publish;
52+
53+
return $obj;
54+
}
55+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ImageKit\Files\UpdateFileDetailsRequest\ChangePublicationStatus;
6+
7+
use ImageKit\Core\Attributes\Api;
8+
use ImageKit\Core\Concerns\SdkModel;
9+
use ImageKit\Core\Contracts\BaseModel;
10+
11+
/**
12+
* Configure the publication status of a file and its versions.
13+
*
14+
* @phpstan-type publish_alias = array{
15+
* isPublished: bool, includeFileVersions?: bool|null
16+
* }
17+
*/
18+
final class Publish implements BaseModel
19+
{
20+
/** @use SdkModel<publish_alias> */
21+
use SdkModel;
22+
23+
/**
24+
* Set to `true` to publish the file. Set to `false` to unpublish the file.
25+
*/
26+
#[Api]
27+
public bool $isPublished;
28+
29+
/**
30+
* Set to `true` to publish/unpublish all versions of the file. Set to `false` to publish/unpublish only the current version of the file.
31+
*/
32+
#[Api(optional: true)]
33+
public ?bool $includeFileVersions;
34+
35+
/**
36+
* `new Publish()` is missing required properties by the API.
37+
*
38+
* To enforce required parameters use
39+
* ```
40+
* Publish::with(isPublished: ...)
41+
* ```
42+
*
43+
* Otherwise ensure the following setters are called
44+
*
45+
* ```
46+
* (new Publish)->withIsPublished(...)
47+
* ```
48+
*/
49+
public function __construct()
50+
{
51+
$this->initialize();
52+
}
53+
54+
/**
55+
* Construct an instance from the required parameters.
56+
*
57+
* You must use named parameters to construct any parameters with a default value.
58+
*/
59+
public static function with(
60+
bool $isPublished,
61+
?bool $includeFileVersions = null
62+
): self {
63+
$obj = new self;
64+
65+
$obj->isPublished = $isPublished;
66+
67+
null !== $includeFileVersions && $obj->includeFileVersions = $includeFileVersions;
68+
69+
return $obj;
70+
}
71+
72+
/**
73+
* Set to `true` to publish the file. Set to `false` to unpublish the file.
74+
*/
75+
public function withIsPublished(bool $isPublished): self
76+
{
77+
$obj = clone $this;
78+
$obj->isPublished = $isPublished;
79+
80+
return $obj;
81+
}
82+
83+
/**
84+
* Set to `true` to publish/unpublish all versions of the file. Set to `false` to publish/unpublish only the current version of the file.
85+
*/
86+
public function withIncludeFileVersions(bool $includeFileVersions): self
87+
{
88+
$obj = clone $this;
89+
$obj->includeFileVersions = $includeFileVersions;
90+
91+
return $obj;
92+
}
93+
}
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ImageKit\Files\UpdateFileDetailsRequest;
6+
7+
use ImageKit\Core\Attributes\Api;
8+
use ImageKit\Core\Concerns\SdkModel;
9+
use ImageKit\Core\Contracts\BaseModel;
10+
use ImageKit\ExtensionItem;
11+
use ImageKit\ExtensionItem\AIAutoDescription;
12+
use ImageKit\ExtensionItem\AutoTaggingExtension;
13+
use ImageKit\ExtensionItem\RemoveBg;
14+
use ImageKit\Files\UpdateFileDetailsRequest\UpdateFileDetails\RemoveAITags;
15+
16+
/**
17+
* @phpstan-type update_file_details = array{
18+
* customCoordinates?: string|null,
19+
* customMetadata?: array<string, mixed>|null,
20+
* description?: string|null,
21+
* extensions?: list<RemoveBg|AutoTaggingExtension|AIAutoDescription>|null,
22+
* removeAITags?: string|null|list<string>,
23+
* tags?: list<string>|null,
24+
* webhookURL?: string|null,
25+
* }
26+
*/
27+
final class UpdateFileDetails implements BaseModel
28+
{
29+
/** @use SdkModel<update_file_details> */
30+
use SdkModel;
31+
32+
/**
33+
* Define an important area in the image in the format `x,y,width,height` e.g. `10,10,100,100`. Send `null` to unset this value.
34+
*/
35+
#[Api(nullable: true, optional: true)]
36+
public ?string $customCoordinates;
37+
38+
/**
39+
* A key-value data to be associated with the asset. To unset a key, send `null` value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API.
40+
*
41+
* @var array<string, mixed>|null $customMetadata
42+
*/
43+
#[Api(map: 'mixed', optional: true)]
44+
public ?array $customMetadata;
45+
46+
/**
47+
* Optional text to describe the contents of the file.
48+
*/
49+
#[Api(optional: true)]
50+
public ?string $description;
51+
52+
/**
53+
* Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.
54+
*
55+
* @var list<RemoveBg|AutoTaggingExtension|AIAutoDescription>|null $extensions
56+
*/
57+
#[Api(list: ExtensionItem::class, optional: true)]
58+
public ?array $extensions;
59+
60+
/**
61+
* An array of AITags associated with the file that you want to remove, e.g. `["car", "vehicle", "motorsports"]`.
62+
*
63+
* If you want to remove all AITags associated with the file, send a string - "all".
64+
*
65+
* Note: The remove operation for `AITags` executes before any of the `extensions` are processed.
66+
*
67+
* @var string|list<string>|null $removeAITags
68+
*/
69+
#[Api(union: RemoveAITags::class, optional: true)]
70+
public string|array|null $removeAITags;
71+
72+
/**
73+
* An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to unset all tags associated with the file.
74+
*
75+
* @var list<string>|null $tags
76+
*/
77+
#[Api(list: 'string', nullable: true, optional: true)]
78+
public ?array $tags;
79+
80+
/**
81+
* The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.
82+
*/
83+
#[Api('webhookUrl', optional: true)]
84+
public ?string $webhookURL;
85+
86+
public function __construct()
87+
{
88+
$this->initialize();
89+
}
90+
91+
/**
92+
* Construct an instance from the required parameters.
93+
*
94+
* You must use named parameters to construct any parameters with a default value.
95+
*
96+
* @param array<string, mixed> $customMetadata
97+
* @param list<RemoveBg|AutoTaggingExtension|AIAutoDescription> $extensions
98+
* @param string|list<string> $removeAITags
99+
* @param list<string>|null $tags
100+
*/
101+
public static function with(
102+
?string $customCoordinates = null,
103+
?array $customMetadata = null,
104+
?string $description = null,
105+
?array $extensions = null,
106+
string|array|null $removeAITags = null,
107+
?array $tags = null,
108+
?string $webhookURL = null,
109+
): self {
110+
$obj = new self;
111+
112+
null !== $customCoordinates && $obj->customCoordinates = $customCoordinates;
113+
null !== $customMetadata && $obj->customMetadata = $customMetadata;
114+
null !== $description && $obj->description = $description;
115+
null !== $extensions && $obj->extensions = $extensions;
116+
null !== $removeAITags && $obj->removeAITags = $removeAITags;
117+
null !== $tags && $obj->tags = $tags;
118+
null !== $webhookURL && $obj->webhookURL = $webhookURL;
119+
120+
return $obj;
121+
}
122+
123+
/**
124+
* Define an important area in the image in the format `x,y,width,height` e.g. `10,10,100,100`. Send `null` to unset this value.
125+
*/
126+
public function withCustomCoordinates(?string $customCoordinates): self
127+
{
128+
$obj = clone $this;
129+
$obj->customCoordinates = $customCoordinates;
130+
131+
return $obj;
132+
}
133+
134+
/**
135+
* A key-value data to be associated with the asset. To unset a key, send `null` value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API.
136+
*
137+
* @param array<string, mixed> $customMetadata
138+
*/
139+
public function withCustomMetadata(array $customMetadata): self
140+
{
141+
$obj = clone $this;
142+
$obj->customMetadata = $customMetadata;
143+
144+
return $obj;
145+
}
146+
147+
/**
148+
* Optional text to describe the contents of the file.
149+
*/
150+
public function withDescription(string $description): self
151+
{
152+
$obj = clone $this;
153+
$obj->description = $description;
154+
155+
return $obj;
156+
}
157+
158+
/**
159+
* Array of extensions to be applied to the asset. Each extension can be configured with specific parameters based on the extension type.
160+
*
161+
* @param list<RemoveBg|AutoTaggingExtension|AIAutoDescription> $extensions
162+
*/
163+
public function withExtensions(array $extensions): self
164+
{
165+
$obj = clone $this;
166+
$obj->extensions = $extensions;
167+
168+
return $obj;
169+
}
170+
171+
/**
172+
* An array of AITags associated with the file that you want to remove, e.g. `["car", "vehicle", "motorsports"]`.
173+
*
174+
* If you want to remove all AITags associated with the file, send a string - "all".
175+
*
176+
* Note: The remove operation for `AITags` executes before any of the `extensions` are processed.
177+
*
178+
* @param string|list<string> $removeAITags
179+
*/
180+
public function withRemoveAITags(string|array $removeAITags): self
181+
{
182+
$obj = clone $this;
183+
$obj->removeAITags = $removeAITags;
184+
185+
return $obj;
186+
}
187+
188+
/**
189+
* An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to unset all tags associated with the file.
190+
*
191+
* @param list<string>|null $tags
192+
*/
193+
public function withTags(?array $tags): self
194+
{
195+
$obj = clone $this;
196+
$obj->tags = $tags;
197+
198+
return $obj;
199+
}
200+
201+
/**
202+
* The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) about the webhook payload structure.
203+
*/
204+
public function withWebhookURL(string $webhookURL): self
205+
{
206+
$obj = clone $this;
207+
$obj->webhookURL = $webhookURL;
208+
209+
return $obj;
210+
}
211+
}

0 commit comments

Comments
 (0)