diff --git a/.fern/metadata.json b/.fern/metadata.json index b5f734d..42f3c27 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -11,10 +11,10 @@ "homepage": "https://www.cloudpdf.com" } }, - "originGitCommit": "20cebe429411ef5019c9e31fc7841d72b7fb98a8", + "originGitCommit": "e5cd0731cb3a1f2ed5821f8d60191bd58934c3dd", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "3.0.0-alpha.8", + "requestedVersion": "3.0.0-alpha.9", "ciProvider": "github", - "sdkVersion": "3.0.0-alpha.8" + "sdkVersion": "3.0.0-alpha.9" } \ No newline at end of file diff --git a/cloudpdf-generation.json b/cloudpdf-generation.json index a0f0fde..0dc1555 100644 --- a/cloudpdf-generation.json +++ b/cloudpdf-generation.json @@ -1,12 +1,12 @@ { "language": "php", - "canonicalVersion": "3.0.0-next.8", - "sdkVersion": "3.0.0-alpha.8", + "canonicalVersion": "3.0.0-next.9", + "sdkVersion": "3.0.0-alpha.9", "source": { "repository": "embedpdf/embed-pdf-viewer", "openapi": "cloudpdf/contract/openapi.json", - "openapiSha256": "e997d51317662fe0666e6582916ded9b17a8bcd225c178548e1ff226e4d01c6d", - "gitCommit": "20cebe429411ef5019c9e31fc7841d72b7fb98a8", + "openapiSha256": "4ee27900dbb0b13408ce00a0e80d606444ab81e9d5a76186fa984c8c8dfe09fe", + "gitCommit": "e5cd0731cb3a1f2ed5821f8d60191bd58934c3dd", "gitCommitIsDirty": false }, "fern": { diff --git a/reference.md b/reference.md index e16e239..efde1ee 100644 --- a/reference.md +++ b/reference.md @@ -2776,6 +2776,94 @@ $client->doc->pages->delete( + + + + +
$client->doc->pages->extract($docId, $layerName, $request) -> string +
+
+ +#### 📝 Description + +
+
+ +
+
+ +A read, not a mutation: the source document is untouched and no event is published. Body is `{"pageObjectNumbers": number[]}`; the response body is the new PDF. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->doc->pages->extract( + 'docId', + 'layerName', + new ExtractPagesRequest([ + 'body' => [ + 'string' => [ + 'key' => "value", + ], + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$docId:** `string` + +
+
+ +
+
+ +**$layerName:** `string` + +
+
+ +
+
+ +**$documentPassword:** `?string` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead. + +
+
+ +
+
+ +**$request:** `array` + +
+
+
+
+ +
@@ -2848,6 +2936,168 @@ $client->doc->pages->flatten( + + + + +
$client->doc->pages->insert($docId, $layerName, $request) -> ?DocPagesInsert200Response +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Multipart mutation envelope: a `body` field holding `{"destIndex"?: number}` (omitted → append) plus a `resource:source` file part carrying the standalone PDF whose pages are copied in. The inserted copies get fresh page object numbers, returned in insertion order. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->doc->pages->insert( + 'docId', + 'layerName', + new InsertPagesRequest([ + 'file' => File::createFromString("example_file", "example_file"), + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$docId:** `string` + +
+
+ +
+
+ +**$layerName:** `string` + +
+
+ +
+
+ +**$documentPassword:** `?string` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead. + +
+
+
+
+ + +
+
+
+ +
$client->doc->pages->insertBlank($docId, $layerName, $request) -> ?DocPagesInsertBlank200Response +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Body is `{"size": {"width", "height"}, "count"?, "destIndex"?}` — size in PDF points, count in [1, 100], destIndex omitted → append. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```php +$client->doc->pages->insertBlank( + 'docId', + 'layerName', + new InsertBlankPagesRequest([ + 'body' => [ + 'key' => "value", + ], + ]), +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**$docId:** `string` + +
+
+ +
+
+ +**$layerName:** `string` + +
+
+ +
+
+ +**$documentPassword:** `?string` — Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead. + +
+
+ +
+
+ +**$request:** `array` + +
+
+
+
+ +
diff --git a/src/CloudPDFClient.php b/src/CloudPDFClient.php index df675d0..e189959 100644 --- a/src/CloudPDFClient.php +++ b/src/CloudPDFClient.php @@ -76,8 +76,8 @@ public function __construct( $defaultHeaders = [ 'X-Fern-Language' => 'PHP', 'X-Fern-SDK-Name' => 'CloudPDF', - 'X-Fern-SDK-Version' => '3.0.0-alpha.8', - 'User-Agent' => 'cloudpdf/sdk/3.0.0-alpha.8', + 'X-Fern-SDK-Version' => '3.0.0-alpha.9', + 'User-Agent' => 'cloudpdf/sdk/3.0.0-alpha.9', ]; if ($token != null) { $defaultHeaders['Authorization'] = "Bearer $token"; diff --git a/src/Doc/Pages/PagesClient.php b/src/Doc/Pages/PagesClient.php index 5dbc445..9762169 100644 --- a/src/Doc/Pages/PagesClient.php +++ b/src/Doc/Pages/PagesClient.php @@ -12,8 +12,15 @@ use CloudPDF\Core\Client\HttpMethod; use JsonException; use Psr\Http\Client\ClientExceptionInterface; +use CloudPDF\Doc\Pages\Requests\ExtractPagesRequest; use CloudPDF\Doc\Pages\Requests\FlattenPagesRequest; use CloudPDF\Types\DocPagesFlatten200Response; +use CloudPDF\Doc\Pages\Requests\InsertPagesRequest; +use CloudPDF\Types\DocPagesInsert200Response; +use CloudPDF\Core\Multipart\MultipartFormData; +use CloudPDF\Core\Multipart\MultipartApiRequest; +use CloudPDF\Doc\Pages\Requests\InsertBlankPagesRequest; +use CloudPDF\Types\DocPagesInsertBlank200Response; use CloudPDF\Doc\Pages\Requests\MovePagesRequest; use CloudPDF\Types\DocPagesMove200Response; use CloudPDF\Doc\Pages\Requests\RotatePagesRequest; @@ -122,6 +129,71 @@ public function delete(string $docId, string $layerName, DeletePagesRequest $req ); } + /** + * A read, not a mutation: the source document is untouched and no event is published. Body is `{"pageObjectNumbers": number[]}`; the response body is the new PDF. + * + * Example: + * ```php + * $client->doc->pages->extract( + * 'docId', + * 'layerName', + * new ExtractPagesRequest([ + * 'body' => [ + * 'string' => [ + * 'key' => "value", + * ], + * ], + * ]), + * ); + * ``` + * + * @param string $docId + * @param string $layerName + * @param ExtractPagesRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return string + * @throws CloudPDFException + * @throws CloudPDFApiException + */ + public function extract(string $docId, string $layerName, ExtractPagesRequest $request, ?array $options = null): string + { + $options = array_merge($this->options, $options ?? []); + $headers = []; + if ($request->documentPassword != null) { + $headers['X-Document-Password'] = $request->documentPassword; + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? '', + path: "v1/docs/{$docId}/layers/{$layerName}/pages/extract", + method: HttpMethod::POST, + headers: $headers, + body: $request->body, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return $response->getBody()->getContents(); + } + } catch (ClientExceptionInterface $e) { + throw new CloudPDFException(message: $e->getMessage(), previous: $e); + } + throw new CloudPDFApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * Example: * ```php @@ -189,6 +261,143 @@ public function flatten(string $docId, string $layerName, FlattenPagesRequest $r ); } + /** + * Multipart mutation envelope: a `body` field holding `{"destIndex"?: number}` (omitted → append) plus a `resource:source` file part carrying the standalone PDF whose pages are copied in. The inserted copies get fresh page object numbers, returned in insertion order. + * + * Example: + * ```php + * $client->doc->pages->insert( + * 'docId', + * 'layerName', + * new InsertPagesRequest([ + * 'file' => File::createFromString("example_file", "example_file"), + * ]), + * ); + * ``` + * + * @param string $docId + * @param string $layerName + * @param InsertPagesRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * } $options + * @return ?DocPagesInsert200Response + * @throws CloudPDFException + * @throws CloudPDFApiException + */ + public function insert(string $docId, string $layerName, InsertPagesRequest $request, ?array $options = null): ?DocPagesInsert200Response + { + $options = array_merge($this->options, $options ?? []); + $headers = []; + if ($request->documentPassword != null) { + $headers['X-Document-Password'] = $request->documentPassword; + } + $body = new MultipartFormData(); + $body->addPart($request->file->toMultipartFormDataPart('file')); + try { + $response = $this->client->sendRequest( + new MultipartApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? '', + path: "v1/docs/{$docId}/layers/{$layerName}/pages/insert", + method: HttpMethod::POST, + headers: $headers, + body: $body, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } + return DocPagesInsert200Response::fromJson($json); + } + } catch (JsonException $e) { + throw new CloudPDFException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (ClientExceptionInterface $e) { + throw new CloudPDFException(message: $e->getMessage(), previous: $e); + } + throw new CloudPDFApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Body is `{"size": {"width", "height"}, "count"?, "destIndex"?}` — size in PDF points, count in [1, 100], destIndex omitted → append. + * + * Example: + * ```php + * $client->doc->pages->insertBlank( + * 'docId', + * 'layerName', + * new InsertBlankPagesRequest([ + * 'body' => [ + * 'key' => "value", + * ], + * ]), + * ); + * ``` + * + * @param string $docId + * @param string $layerName + * @param InsertBlankPagesRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ?DocPagesInsertBlank200Response + * @throws CloudPDFException + * @throws CloudPDFApiException + */ + public function insertBlank(string $docId, string $layerName, InsertBlankPagesRequest $request, ?array $options = null): ?DocPagesInsertBlank200Response + { + $options = array_merge($this->options, $options ?? []); + $headers = []; + if ($request->documentPassword != null) { + $headers['X-Document-Password'] = $request->documentPassword; + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? '', + path: "v1/docs/{$docId}/layers/{$layerName}/pages/insert-blank", + method: HttpMethod::POST, + headers: $headers, + body: $request->body, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } + return DocPagesInsertBlank200Response::fromJson($json); + } + } catch (JsonException $e) { + throw new CloudPDFException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (ClientExceptionInterface $e) { + throw new CloudPDFException(message: $e->getMessage(), previous: $e); + } + throw new CloudPDFApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * Example: * ```php diff --git a/src/Doc/Pages/Requests/ExtractPagesRequest.php b/src/Doc/Pages/Requests/ExtractPagesRequest.php new file mode 100644 index 0000000..3a2ffdf --- /dev/null +++ b/src/Doc/Pages/Requests/ExtractPagesRequest.php @@ -0,0 +1,31 @@ + $body + */ + public array $body; + + /** + * @param array{ + * body: array, + * documentPassword?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->documentPassword = $values['documentPassword'] ?? null; + $this->body = $values['body']; + } +} diff --git a/src/Doc/Pages/Requests/InsertBlankPagesRequest.php b/src/Doc/Pages/Requests/InsertBlankPagesRequest.php new file mode 100644 index 0000000..1fb7c58 --- /dev/null +++ b/src/Doc/Pages/Requests/InsertBlankPagesRequest.php @@ -0,0 +1,31 @@ + $body + */ + public array $body; + + /** + * @param array{ + * body: array, + * documentPassword?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->documentPassword = $values['documentPassword'] ?? null; + $this->body = $values['body']; + } +} diff --git a/src/Doc/Pages/Requests/InsertPagesRequest.php b/src/Doc/Pages/Requests/InsertPagesRequest.php new file mode 100644 index 0000000..315d576 --- /dev/null +++ b/src/Doc/Pages/Requests/InsertPagesRequest.php @@ -0,0 +1,32 @@ +documentPassword = $values['documentPassword'] ?? null; + $this->file = $values['file']; + } +} diff --git a/src/Types/DocPagesExtract400Response.php b/src/Types/DocPagesExtract400Response.php new file mode 100644 index 0000000..cfa952d --- /dev/null +++ b/src/Types/DocPagesExtract400Response.php @@ -0,0 +1,59 @@ + $name + */ + #[JsonProperty('name')] + public string $name; + + /** + * @var value-of $code + */ + #[JsonProperty('code')] + public string $code; + + /** + * @var string $message + */ + #[JsonProperty('message')] + public string $message; + + /** + * @var ?array $details + */ + #[JsonProperty('details'), ArrayType(['string' => 'mixed'])] + public ?array $details; + + /** + * @param array{ + * name: value-of, + * code: value-of, + * message: string, + * details?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->name = $values['name']; + $this->code = $values['code']; + $this->message = $values['message']; + $this->details = $values['details'] ?? null; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesExtract400ResponseCode.php b/src/Types/DocPagesExtract400ResponseCode.php new file mode 100644 index 0000000..7f45099 --- /dev/null +++ b/src/Types/DocPagesExtract400ResponseCode.php @@ -0,0 +1,26 @@ + $name + */ + #[JsonProperty('name')] + public string $name; + + /** + * @var value-of $code + */ + #[JsonProperty('code')] + public string $code; + + /** + * @var string $message + */ + #[JsonProperty('message')] + public string $message; + + /** + * @var ?array $details + */ + #[JsonProperty('details'), ArrayType(['string' => 'mixed'])] + public ?array $details; + + /** + * @param array{ + * name: value-of, + * code: value-of, + * message: string, + * details?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->name = $values['name']; + $this->code = $values['code']; + $this->message = $values['message']; + $this->details = $values['details'] ?? null; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesExtract404ResponseCode.php b/src/Types/DocPagesExtract404ResponseCode.php new file mode 100644 index 0000000..1f6d96d --- /dev/null +++ b/src/Types/DocPagesExtract404ResponseCode.php @@ -0,0 +1,26 @@ +meta = $values['meta']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMeta.php b/src/Types/DocPagesInsert200ResponseMeta.php new file mode 100644 index 0000000..6c6f570 --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMeta.php @@ -0,0 +1,43 @@ + $affectedPages + */ + #[JsonProperty('affectedPages'), ArrayType([DocPagesInsert200ResponseMetaAffectedPagesItem::class])] + public array $affectedPages; + + /** + * @var ?DocPagesInsert200ResponseMetaCacheDelta $cacheDelta + */ + #[JsonProperty('cacheDelta')] + public ?DocPagesInsert200ResponseMetaCacheDelta $cacheDelta; + + /** + * @param array{ + * affectedPages: array, + * cacheDelta?: ?DocPagesInsert200ResponseMetaCacheDelta, + * } $values + */ + public function __construct( + array $values, + ) { + $this->affectedPages = $values['affectedPages']; + $this->cacheDelta = $values['cacheDelta'] ?? null; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItem.php b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItem.php new file mode 100644 index 0000000..475aba3 --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItem.php @@ -0,0 +1,50 @@ +pageObjectNumber = $values['pageObjectNumber']; + $this->revision = $values['revision']; + $this->weakAnnotationState = $values['weakAnnotationState']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemRevision.php b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemRevision.php new file mode 100644 index 0000000..5a92486 --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemRevision.php @@ -0,0 +1,50 @@ +docSessionId = $values['docSessionId']; + $this->pageObjectNumber = $values['pageObjectNumber']; + $this->generation = $values['generation']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState.php b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState.php new file mode 100644 index 0000000..329d250 --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState.php @@ -0,0 +1,196 @@ +kind = $values['kind']; + $this->value = $values['value']; + } + + /** + * @param DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown $unknown + * @return DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState + */ + public static function unknown(DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown $unknown): DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState + { + return new DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState([ + 'kind' => 'unknown', + 'value' => $unknown, + ]); + } + + /** + * @param DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown $known + * @return DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState + */ + public static function known(DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown $known): DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState + { + return new DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationState([ + 'kind' => 'known', + 'value' => $known, + ]); + } + + /** + * @return bool + */ + public function isUnknown(): bool + { + return $this->value instanceof DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown && $this->kind === 'unknown'; + } + + /** + * @return DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown + */ + public function asUnknown(): DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown + { + if (!($this->value instanceof DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown && $this->kind === 'unknown')) { + throw new Exception( + "Expected unknown; got " . $this->kind . " with value of type " . get_debug_type($this->value), + ); + } + + return $this->value; + } + + /** + * @return bool + */ + public function isKnown(): bool + { + return $this->value instanceof DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown && $this->kind === 'known'; + } + + /** + * @return DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown + */ + public function asKnown(): DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown + { + if (!($this->value instanceof DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown && $this->kind === 'known')) { + throw new Exception( + "Expected known; got " . $this->kind . " with value of type " . get_debug_type($this->value), + ); + } + + return $this->value; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } + + /** + * @return array + */ + public function jsonSerialize(): array + { + $result = []; + $result['kind'] = $this->kind; + + $base = parent::jsonSerialize(); + $result = array_merge($base, $result); + + switch ($this->kind) { + case 'unknown': + $value = $this->asUnknown()->jsonSerialize(); + $result = array_merge($value, $result); + break; + case 'known': + $value = $this->asKnown()->jsonSerialize(); + $result = array_merge($value, $result); + break; + case '_unknown': + default: + if (is_null($this->value)) { + break; + } + if ($this->value instanceof JsonSerializableType) { + $value = $this->value->jsonSerialize(); + $result = array_merge($value, $result); + } elseif (is_array($this->value)) { + $result = array_merge($this->value, $result); + } + } + + return $result; + } + + /** + * @param array $data + */ + public static function jsonDeserialize(array $data): static + { + $args = []; + if (!array_key_exists('kind', $data)) { + throw new Exception( + "JSON data is missing property 'kind'", + ); + } + $kind = $data['kind']; + if (!(is_string($kind))) { + throw new Exception( + "Expected property 'kind' in JSON data to be string, instead received " . get_debug_type($data['kind']), + ); + } + + $args['kind'] = $kind; + switch ($kind) { + case 'unknown': + $args['value'] = DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown::jsonDeserialize($data); + break; + case 'known': + $args['value'] = DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown::jsonDeserialize($data); + break; + case '_unknown': + default: + $args['kind'] = '_unknown'; + $args['value'] = $data; + } + + // @phpstan-ignore-next-line + return new static($args); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown.php b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown.php new file mode 100644 index 0000000..460409e --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown.php @@ -0,0 +1,34 @@ +hasAnyWeakAnnotations = $values['hasAnyWeakAnnotations']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown.php b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown.php new file mode 100644 index 0000000..773c809 --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown.php @@ -0,0 +1,26 @@ +toJson(); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMetaCacheDelta.php b/src/Types/DocPagesInsert200ResponseMetaCacheDelta.php new file mode 100644 index 0000000..400466f --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMetaCacheDelta.php @@ -0,0 +1,51 @@ + $pages + */ + #[JsonProperty('pages'), ArrayType([DocPagesInsert200ResponseMetaCacheDeltaPagesItem::class])] + public array $pages; + + /** + * @param array{ + * previousDocVersion: int, + * docVersion: int, + * pages: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->previousDocVersion = $values['previousDocVersion']; + $this->docVersion = $values['docVersion']; + $this->pages = $values['pages']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMetaCacheDeltaPagesItem.php b/src/Types/DocPagesInsert200ResponseMetaCacheDeltaPagesItem.php new file mode 100644 index 0000000..84325b3 --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMetaCacheDeltaPagesItem.php @@ -0,0 +1,42 @@ +pageObjectNumber = $values['pageObjectNumber']; + $this->cache = $values['cache']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert200ResponseMetaCacheDeltaPagesItemCache.php b/src/Types/DocPagesInsert200ResponseMetaCacheDeltaPagesItemCache.php new file mode 100644 index 0000000..813ad94 --- /dev/null +++ b/src/Types/DocPagesInsert200ResponseMetaCacheDeltaPagesItemCache.php @@ -0,0 +1,42 @@ +contentVersion = $values['contentVersion']; + $this->annotationVersion = $values['annotationVersion']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert400Response.php b/src/Types/DocPagesInsert400Response.php new file mode 100644 index 0000000..ef01b31 --- /dev/null +++ b/src/Types/DocPagesInsert400Response.php @@ -0,0 +1,59 @@ + $name + */ + #[JsonProperty('name')] + public string $name; + + /** + * @var value-of $code + */ + #[JsonProperty('code')] + public string $code; + + /** + * @var string $message + */ + #[JsonProperty('message')] + public string $message; + + /** + * @var ?array $details + */ + #[JsonProperty('details'), ArrayType(['string' => 'mixed'])] + public ?array $details; + + /** + * @param array{ + * name: value-of, + * code: value-of, + * message: string, + * details?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->name = $values['name']; + $this->code = $values['code']; + $this->message = $values['message']; + $this->details = $values['details'] ?? null; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert400ResponseCode.php b/src/Types/DocPagesInsert400ResponseCode.php new file mode 100644 index 0000000..0b2970c --- /dev/null +++ b/src/Types/DocPagesInsert400ResponseCode.php @@ -0,0 +1,26 @@ + $name + */ + #[JsonProperty('name')] + public string $name; + + /** + * @var value-of $code + */ + #[JsonProperty('code')] + public string $code; + + /** + * @var string $message + */ + #[JsonProperty('message')] + public string $message; + + /** + * @var ?array $details + */ + #[JsonProperty('details'), ArrayType(['string' => 'mixed'])] + public ?array $details; + + /** + * @param array{ + * name: value-of, + * code: value-of, + * message: string, + * details?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->name = $values['name']; + $this->code = $values['code']; + $this->message = $values['message']; + $this->details = $values['details'] ?? null; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsert404ResponseCode.php b/src/Types/DocPagesInsert404ResponseCode.php new file mode 100644 index 0000000..929bfb2 --- /dev/null +++ b/src/Types/DocPagesInsert404ResponseCode.php @@ -0,0 +1,26 @@ +meta = $values['meta']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMeta.php b/src/Types/DocPagesInsertBlank200ResponseMeta.php new file mode 100644 index 0000000..5842ac8 --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMeta.php @@ -0,0 +1,43 @@ + $affectedPages + */ + #[JsonProperty('affectedPages'), ArrayType([DocPagesInsertBlank200ResponseMetaAffectedPagesItem::class])] + public array $affectedPages; + + /** + * @var ?DocPagesInsertBlank200ResponseMetaCacheDelta $cacheDelta + */ + #[JsonProperty('cacheDelta')] + public ?DocPagesInsertBlank200ResponseMetaCacheDelta $cacheDelta; + + /** + * @param array{ + * affectedPages: array, + * cacheDelta?: ?DocPagesInsertBlank200ResponseMetaCacheDelta, + * } $values + */ + public function __construct( + array $values, + ) { + $this->affectedPages = $values['affectedPages']; + $this->cacheDelta = $values['cacheDelta'] ?? null; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItem.php b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItem.php new file mode 100644 index 0000000..7ebb2da --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItem.php @@ -0,0 +1,50 @@ +pageObjectNumber = $values['pageObjectNumber']; + $this->revision = $values['revision']; + $this->weakAnnotationState = $values['weakAnnotationState']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemRevision.php b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemRevision.php new file mode 100644 index 0000000..c1c3989 --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemRevision.php @@ -0,0 +1,50 @@ +docSessionId = $values['docSessionId']; + $this->pageObjectNumber = $values['pageObjectNumber']; + $this->generation = $values['generation']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState.php b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState.php new file mode 100644 index 0000000..01f0dd8 --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState.php @@ -0,0 +1,196 @@ +kind = $values['kind']; + $this->value = $values['value']; + } + + /** + * @param DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown $unknown + * @return DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState + */ + public static function unknown(DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown $unknown): DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState + { + return new DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState([ + 'kind' => 'unknown', + 'value' => $unknown, + ]); + } + + /** + * @param DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown $known + * @return DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState + */ + public static function known(DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown $known): DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState + { + return new DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationState([ + 'kind' => 'known', + 'value' => $known, + ]); + } + + /** + * @return bool + */ + public function isUnknown(): bool + { + return $this->value instanceof DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown && $this->kind === 'unknown'; + } + + /** + * @return DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown + */ + public function asUnknown(): DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown + { + if (!($this->value instanceof DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown && $this->kind === 'unknown')) { + throw new Exception( + "Expected unknown; got " . $this->kind . " with value of type " . get_debug_type($this->value), + ); + } + + return $this->value; + } + + /** + * @return bool + */ + public function isKnown(): bool + { + return $this->value instanceof DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown && $this->kind === 'known'; + } + + /** + * @return DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown + */ + public function asKnown(): DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown + { + if (!($this->value instanceof DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown && $this->kind === 'known')) { + throw new Exception( + "Expected known; got " . $this->kind . " with value of type " . get_debug_type($this->value), + ); + } + + return $this->value; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } + + /** + * @return array + */ + public function jsonSerialize(): array + { + $result = []; + $result['kind'] = $this->kind; + + $base = parent::jsonSerialize(); + $result = array_merge($base, $result); + + switch ($this->kind) { + case 'unknown': + $value = $this->asUnknown()->jsonSerialize(); + $result = array_merge($value, $result); + break; + case 'known': + $value = $this->asKnown()->jsonSerialize(); + $result = array_merge($value, $result); + break; + case '_unknown': + default: + if (is_null($this->value)) { + break; + } + if ($this->value instanceof JsonSerializableType) { + $value = $this->value->jsonSerialize(); + $result = array_merge($value, $result); + } elseif (is_array($this->value)) { + $result = array_merge($this->value, $result); + } + } + + return $result; + } + + /** + * @param array $data + */ + public static function jsonDeserialize(array $data): static + { + $args = []; + if (!array_key_exists('kind', $data)) { + throw new Exception( + "JSON data is missing property 'kind'", + ); + } + $kind = $data['kind']; + if (!(is_string($kind))) { + throw new Exception( + "Expected property 'kind' in JSON data to be string, instead received " . get_debug_type($data['kind']), + ); + } + + $args['kind'] = $kind; + switch ($kind) { + case 'unknown': + $args['value'] = DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown::jsonDeserialize($data); + break; + case 'known': + $args['value'] = DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown::jsonDeserialize($data); + break; + case '_unknown': + default: + $args['kind'] = '_unknown'; + $args['value'] = $data; + } + + // @phpstan-ignore-next-line + return new static($args); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown.php b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown.php new file mode 100644 index 0000000..9dd83b9 --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateKnown.php @@ -0,0 +1,34 @@ +hasAnyWeakAnnotations = $values['hasAnyWeakAnnotations']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown.php b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown.php new file mode 100644 index 0000000..1254fd1 --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMetaAffectedPagesItemWeakAnnotationStateUnknown.php @@ -0,0 +1,26 @@ +toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMetaCacheDelta.php b/src/Types/DocPagesInsertBlank200ResponseMetaCacheDelta.php new file mode 100644 index 0000000..6cd0a50 --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMetaCacheDelta.php @@ -0,0 +1,51 @@ + $pages + */ + #[JsonProperty('pages'), ArrayType([DocPagesInsertBlank200ResponseMetaCacheDeltaPagesItem::class])] + public array $pages; + + /** + * @param array{ + * previousDocVersion: int, + * docVersion: int, + * pages: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->previousDocVersion = $values['previousDocVersion']; + $this->docVersion = $values['docVersion']; + $this->pages = $values['pages']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMetaCacheDeltaPagesItem.php b/src/Types/DocPagesInsertBlank200ResponseMetaCacheDeltaPagesItem.php new file mode 100644 index 0000000..9139e8c --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMetaCacheDeltaPagesItem.php @@ -0,0 +1,42 @@ +pageObjectNumber = $values['pageObjectNumber']; + $this->cache = $values['cache']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank200ResponseMetaCacheDeltaPagesItemCache.php b/src/Types/DocPagesInsertBlank200ResponseMetaCacheDeltaPagesItemCache.php new file mode 100644 index 0000000..8f0b5a2 --- /dev/null +++ b/src/Types/DocPagesInsertBlank200ResponseMetaCacheDeltaPagesItemCache.php @@ -0,0 +1,42 @@ +contentVersion = $values['contentVersion']; + $this->annotationVersion = $values['annotationVersion']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank400Response.php b/src/Types/DocPagesInsertBlank400Response.php new file mode 100644 index 0000000..64d6524 --- /dev/null +++ b/src/Types/DocPagesInsertBlank400Response.php @@ -0,0 +1,59 @@ + $name + */ + #[JsonProperty('name')] + public string $name; + + /** + * @var value-of $code + */ + #[JsonProperty('code')] + public string $code; + + /** + * @var string $message + */ + #[JsonProperty('message')] + public string $message; + + /** + * @var ?array $details + */ + #[JsonProperty('details'), ArrayType(['string' => 'mixed'])] + public ?array $details; + + /** + * @param array{ + * name: value-of, + * code: value-of, + * message: string, + * details?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->name = $values['name']; + $this->code = $values['code']; + $this->message = $values['message']; + $this->details = $values['details'] ?? null; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank400ResponseCode.php b/src/Types/DocPagesInsertBlank400ResponseCode.php new file mode 100644 index 0000000..e7920f3 --- /dev/null +++ b/src/Types/DocPagesInsertBlank400ResponseCode.php @@ -0,0 +1,26 @@ + $name + */ + #[JsonProperty('name')] + public string $name; + + /** + * @var value-of $code + */ + #[JsonProperty('code')] + public string $code; + + /** + * @var string $message + */ + #[JsonProperty('message')] + public string $message; + + /** + * @var ?array $details + */ + #[JsonProperty('details'), ArrayType(['string' => 'mixed'])] + public ?array $details; + + /** + * @param array{ + * name: value-of, + * code: value-of, + * message: string, + * details?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->name = $values['name']; + $this->code = $values['code']; + $this->message = $values['message']; + $this->details = $values['details'] ?? null; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DocPagesInsertBlank404ResponseCode.php b/src/Types/DocPagesInsertBlank404ResponseCode.php new file mode 100644 index 0000000..865f265 --- /dev/null +++ b/src/Types/DocPagesInsertBlank404ResponseCode.php @@ -0,0 +1,26 @@ +