From 2840d6d4f9cd229847118496dff3a998c68a4379 Mon Sep 17 00:00:00 2001 From: cloudpdf-sdk-bot Date: Wed, 25 Nov 2026 14:09:46 +0000 Subject: [PATCH] chore: generate CloudPDF PHP SDK 3.4.0 --- .fern/metadata.json | 6 +- README.md | 2 +- cloudpdf-generation.json | 8 +- src/CloudPDFClient.php | 6 +- ...OpFormsSetSignatureAppearanceResources.php | 10 +- src/Types/FormFieldCheckbox.php | 8 + src/Types/FormFieldCombobox.php | 16 ++ src/Types/FormFieldDraftCheckbox.php | 8 + src/Types/FormFieldDraftCombobox.php | 16 ++ src/Types/FormFieldDraftListbox.php | 8 + src/Types/FormFieldDraftPushbutton.php | 8 + src/Types/FormFieldDraftRadio.php | 8 + src/Types/FormFieldDraftSignature.php | 8 + src/Types/FormFieldDraftText.php | 16 ++ src/Types/FormFieldFormat.php | 244 ++++++++++++++++++ src/Types/FormFieldFormatDate.php | 34 +++ src/Types/FormFieldFormatOther.php | 26 ++ src/Types/FormFieldFormatTime.php | 34 +++ src/Types/FormFieldFormatWritable.php | 196 ++++++++++++++ src/Types/FormFieldFormatWritableDate.php | 34 +++ src/Types/FormFieldFormatWritableTime.php | 34 +++ src/Types/FormFieldListbox.php | 8 + src/Types/FormFieldPatch.php | 16 ++ src/Types/FormFieldPushbutton.php | 8 + src/Types/FormFieldRadio.php | 8 + src/Types/FormFieldSignature.php | 8 + src/Types/FormFieldText.php | 16 ++ src/Types/FormFieldUnknown.php | 8 + 28 files changed, 786 insertions(+), 16 deletions(-) create mode 100644 src/Types/FormFieldFormat.php create mode 100644 src/Types/FormFieldFormatDate.php create mode 100644 src/Types/FormFieldFormatOther.php create mode 100644 src/Types/FormFieldFormatTime.php create mode 100644 src/Types/FormFieldFormatWritable.php create mode 100644 src/Types/FormFieldFormatWritableDate.php create mode 100644 src/Types/FormFieldFormatWritableTime.php diff --git a/.fern/metadata.json b/.fern/metadata.json index 7d035a7f..cd7931bd 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -11,10 +11,10 @@ "homepage": "https://www.cloudpdf.com" } }, - "originGitCommit": "4b156274cbffac1a19f266d36d27b4ed07bf2b53", + "originGitCommit": "9af4d9ee755d6e5c20a8055654e895a81b95fb83", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "3.3.0", + "requestedVersion": "3.4.0", "ciProvider": "github", - "sdkVersion": "3.3.0" + "sdkVersion": "3.4.0" } \ No newline at end of file diff --git a/README.md b/README.md index ade7e533..d440d4eb 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ use CloudPDF\Doc\Requests\DocChangesRequest; use CloudPDF\Doc\Types\DocChangesRequestChangesItem; $client = new CloudPDFClient( - embedPdfVersion: '3.3', + embedPdfVersion: '3.4', token: '', ); $client->doc->changes( diff --git a/cloudpdf-generation.json b/cloudpdf-generation.json index ab50e0d8..047f2b18 100644 --- a/cloudpdf-generation.json +++ b/cloudpdf-generation.json @@ -1,12 +1,12 @@ { "language": "php", - "canonicalVersion": "3.3.0", - "sdkVersion": "3.3.0", + "canonicalVersion": "3.4.0", + "sdkVersion": "3.4.0", "source": { "repository": "embedpdf/embed-pdf-viewer", "openapi": "cloudpdf/contract/openapi.json", - "openapiSha256": "8d6fda1d157a3f3f82d3a16835381932eaa6efe3054100bb0aa63c0ad5ac6909", - "gitCommit": "4b156274cbffac1a19f266d36d27b4ed07bf2b53", + "openapiSha256": "1416853fd5400e76cd33ffd218e90673faf6c8c8c50f86af1937ba6576efb27d", + "gitCommit": "9af4d9ee755d6e5c20a8055654e895a81b95fb83", "gitCommitIsDirty": false }, "fern": { diff --git a/src/CloudPDFClient.php b/src/CloudPDFClient.php index 11b5e3ce..a6d6a79c 100644 --- a/src/CloudPDFClient.php +++ b/src/CloudPDFClient.php @@ -82,11 +82,11 @@ public function __construct( ?array $options = null, ) { $defaultHeaders = [ - 'EmbedPDF-Version' => '3.3', + 'EmbedPDF-Version' => '3.4', 'X-Fern-Language' => 'PHP', 'X-Fern-SDK-Name' => 'CloudPDF', - 'X-Fern-SDK-Version' => '3.3.0', - 'User-Agent' => 'cloudpdf/sdk/3.3.0', + 'X-Fern-SDK-Version' => '3.4.0', + 'User-Agent' => 'cloudpdf/sdk/3.4.0', ]; if ($token != null) { $defaultHeaders['Authorization'] = "Bearer $token"; diff --git a/src/Types/ChangeOpFormsSetSignatureAppearanceResources.php b/src/Types/ChangeOpFormsSetSignatureAppearanceResources.php index 0dedf755..ee6a763d 100644 --- a/src/Types/ChangeOpFormsSetSignatureAppearanceResources.php +++ b/src/Types/ChangeOpFormsSetSignatureAppearanceResources.php @@ -8,20 +8,20 @@ class ChangeOpFormsSetSignatureAppearanceResources extends JsonSerializableType { /** - * @var string $appearance + * @var ?string $appearance */ #[JsonProperty('appearance')] - public string $appearance; + public ?string $appearance; /** * @param array{ - * appearance: string, + * appearance?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->appearance = $values['appearance']; + $this->appearance = $values['appearance'] ?? null; } /** diff --git a/src/Types/FormFieldCheckbox.php b/src/Types/FormFieldCheckbox.php index dd566657..4bd115d4 100644 --- a/src/Types/FormFieldCheckbox.php +++ b/src/Types/FormFieldCheckbox.php @@ -82,6 +82,12 @@ class FormFieldCheckbox extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?string $createdBy */ @@ -153,6 +159,7 @@ class FormFieldCheckbox extends JsonSerializableType * mappingName?: ?string, * actions?: ?PdfFieldActions, * groupId?: ?string, + * purpose?: ?string, * createdBy?: ?string, * createdAt?: ?DateTime, * filledBy?: ?string, @@ -176,6 +183,7 @@ public function __construct( $this->defaultValueEntry = $values['defaultValueEntry']; $this->actions = $values['actions'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->createdBy = $values['createdBy'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->filledBy = $values['filledBy'] ?? null; diff --git a/src/Types/FormFieldCombobox.php b/src/Types/FormFieldCombobox.php index 2ebf464b..c9313f1d 100644 --- a/src/Types/FormFieldCombobox.php +++ b/src/Types/FormFieldCombobox.php @@ -82,6 +82,12 @@ class FormFieldCombobox extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?string $createdBy */ @@ -148,6 +154,12 @@ class FormFieldCombobox extends JsonSerializableType #[JsonProperty('options'), ArrayType([FormFieldComboboxOptionsItem::class])] public array $options; + /** + * @var ?FormFieldFormat $format The shape a text field's or a dropdown's value has, by its `kind`: a date or a time with the pattern it is shown in, or `other` for a format script the engine does not recognise. A newer server can add kinds: read one your client doesn't know as `other`. + */ + #[JsonProperty('format')] + public ?FormFieldFormat $format; + /** * @param array{ * ref: FormFieldRef, @@ -167,12 +179,14 @@ class FormFieldCombobox extends JsonSerializableType * mappingName?: ?string, * actions?: ?PdfFieldActions, * groupId?: ?string, + * purpose?: ?string, * createdBy?: ?string, * createdAt?: ?DateTime, * filledBy?: ?string, * filledByName?: ?string, * filledAt?: ?DateTime, * importedBy?: ?string, + * format?: ?FormFieldFormat, * } $values */ public function __construct( @@ -190,6 +204,7 @@ public function __construct( $this->defaultValueEntry = $values['defaultValueEntry']; $this->actions = $values['actions'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->createdBy = $values['createdBy'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->filledBy = $values['filledBy'] ?? null; @@ -201,6 +216,7 @@ public function __construct( $this->defaultValue = $values['defaultValue']; $this->edit = $values['edit']; $this->options = $values['options']; + $this->format = $values['format'] ?? null; } /** diff --git a/src/Types/FormFieldDraftCheckbox.php b/src/Types/FormFieldDraftCheckbox.php index e345d88f..9e22e79d 100644 --- a/src/Types/FormFieldDraftCheckbox.php +++ b/src/Types/FormFieldDraftCheckbox.php @@ -50,6 +50,12 @@ class FormFieldDraftCheckbox extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?FieldActionsPatch $actions */ @@ -71,6 +77,7 @@ class FormFieldDraftCheckbox extends JsonSerializableType * alternateName?: ?string, * mappingName?: ?string, * groupId?: ?string, + * purpose?: ?string, * actions?: ?FieldActionsPatch, * widgets?: ?array, * } $values @@ -85,6 +92,7 @@ public function __construct( $this->alternateName = $values['alternateName'] ?? null; $this->mappingName = $values['mappingName'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->actions = $values['actions'] ?? null; $this->widgets = $values['widgets'] ?? null; } diff --git a/src/Types/FormFieldDraftCombobox.php b/src/Types/FormFieldDraftCombobox.php index 4321f69c..b5e9da00 100644 --- a/src/Types/FormFieldDraftCombobox.php +++ b/src/Types/FormFieldDraftCombobox.php @@ -50,6 +50,12 @@ class FormFieldDraftCombobox extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?FieldActionsPatch $actions */ @@ -80,6 +86,12 @@ class FormFieldDraftCombobox extends JsonSerializableType #[JsonProperty('defaultValue')] public ?string $defaultValue; + /** + * @var ?FormFieldFormatWritable $format + */ + #[JsonProperty('format')] + public ?FormFieldFormatWritable $format; + /** * @param array{ * name: string, @@ -89,11 +101,13 @@ class FormFieldDraftCombobox extends JsonSerializableType * alternateName?: ?string, * mappingName?: ?string, * groupId?: ?string, + * purpose?: ?string, * actions?: ?FieldActionsPatch, * widgets?: ?array, * edit?: ?bool, * options?: ?array, * defaultValue?: ?string, + * format?: ?FormFieldFormatWritable, * } $values */ public function __construct( @@ -106,11 +120,13 @@ public function __construct( $this->alternateName = $values['alternateName'] ?? null; $this->mappingName = $values['mappingName'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->actions = $values['actions'] ?? null; $this->widgets = $values['widgets'] ?? null; $this->edit = $values['edit'] ?? null; $this->options = $values['options'] ?? null; $this->defaultValue = $values['defaultValue'] ?? null; + $this->format = $values['format'] ?? null; } /** diff --git a/src/Types/FormFieldDraftListbox.php b/src/Types/FormFieldDraftListbox.php index 88f6ee08..0b652948 100644 --- a/src/Types/FormFieldDraftListbox.php +++ b/src/Types/FormFieldDraftListbox.php @@ -50,6 +50,12 @@ class FormFieldDraftListbox extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?FieldActionsPatch $actions */ @@ -89,6 +95,7 @@ class FormFieldDraftListbox extends JsonSerializableType * alternateName?: ?string, * mappingName?: ?string, * groupId?: ?string, + * purpose?: ?string, * actions?: ?FieldActionsPatch, * widgets?: ?array, * multiSelect?: ?bool, @@ -106,6 +113,7 @@ public function __construct( $this->alternateName = $values['alternateName'] ?? null; $this->mappingName = $values['mappingName'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->actions = $values['actions'] ?? null; $this->widgets = $values['widgets'] ?? null; $this->multiSelect = $values['multiSelect'] ?? null; diff --git a/src/Types/FormFieldDraftPushbutton.php b/src/Types/FormFieldDraftPushbutton.php index 0e239631..8fd7697f 100644 --- a/src/Types/FormFieldDraftPushbutton.php +++ b/src/Types/FormFieldDraftPushbutton.php @@ -50,6 +50,12 @@ class FormFieldDraftPushbutton extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?FieldActionsPatch $actions */ @@ -71,6 +77,7 @@ class FormFieldDraftPushbutton extends JsonSerializableType * alternateName?: ?string, * mappingName?: ?string, * groupId?: ?string, + * purpose?: ?string, * actions?: ?FieldActionsPatch, * widgets?: ?array, * } $values @@ -85,6 +92,7 @@ public function __construct( $this->alternateName = $values['alternateName'] ?? null; $this->mappingName = $values['mappingName'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->actions = $values['actions'] ?? null; $this->widgets = $values['widgets'] ?? null; } diff --git a/src/Types/FormFieldDraftRadio.php b/src/Types/FormFieldDraftRadio.php index e6c91287..d9f5152a 100644 --- a/src/Types/FormFieldDraftRadio.php +++ b/src/Types/FormFieldDraftRadio.php @@ -50,6 +50,12 @@ class FormFieldDraftRadio extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?FieldActionsPatch $actions */ @@ -83,6 +89,7 @@ class FormFieldDraftRadio extends JsonSerializableType * alternateName?: ?string, * mappingName?: ?string, * groupId?: ?string, + * purpose?: ?string, * actions?: ?FieldActionsPatch, * widgets?: ?array, * radiosInUnison?: ?bool, @@ -99,6 +106,7 @@ public function __construct( $this->alternateName = $values['alternateName'] ?? null; $this->mappingName = $values['mappingName'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->actions = $values['actions'] ?? null; $this->widgets = $values['widgets'] ?? null; $this->radiosInUnison = $values['radiosInUnison'] ?? null; diff --git a/src/Types/FormFieldDraftSignature.php b/src/Types/FormFieldDraftSignature.php index 28050b92..5e4e4ac0 100644 --- a/src/Types/FormFieldDraftSignature.php +++ b/src/Types/FormFieldDraftSignature.php @@ -50,6 +50,12 @@ class FormFieldDraftSignature extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?FieldActionsPatch $actions */ @@ -71,6 +77,7 @@ class FormFieldDraftSignature extends JsonSerializableType * alternateName?: ?string, * mappingName?: ?string, * groupId?: ?string, + * purpose?: ?string, * actions?: ?FieldActionsPatch, * widgets?: ?array, * } $values @@ -85,6 +92,7 @@ public function __construct( $this->alternateName = $values['alternateName'] ?? null; $this->mappingName = $values['mappingName'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->actions = $values['actions'] ?? null; $this->widgets = $values['widgets'] ?? null; } diff --git a/src/Types/FormFieldDraftText.php b/src/Types/FormFieldDraftText.php index 0ffdb3bd..ebbacc94 100644 --- a/src/Types/FormFieldDraftText.php +++ b/src/Types/FormFieldDraftText.php @@ -50,6 +50,12 @@ class FormFieldDraftText extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?FieldActionsPatch $actions */ @@ -92,6 +98,12 @@ class FormFieldDraftText extends JsonSerializableType #[JsonProperty('comb')] public ?bool $comb; + /** + * @var ?FormFieldFormatWritable $format + */ + #[JsonProperty('format')] + public ?FormFieldFormatWritable $format; + /** * @param array{ * name: string, @@ -101,6 +113,7 @@ class FormFieldDraftText extends JsonSerializableType * alternateName?: ?string, * mappingName?: ?string, * groupId?: ?string, + * purpose?: ?string, * actions?: ?FieldActionsPatch, * widgets?: ?array, * defaultValue?: ?string, @@ -108,6 +121,7 @@ class FormFieldDraftText extends JsonSerializableType * multiline?: ?bool, * password?: ?bool, * comb?: ?bool, + * format?: ?FormFieldFormatWritable, * } $values */ public function __construct( @@ -120,6 +134,7 @@ public function __construct( $this->alternateName = $values['alternateName'] ?? null; $this->mappingName = $values['mappingName'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->actions = $values['actions'] ?? null; $this->widgets = $values['widgets'] ?? null; $this->defaultValue = $values['defaultValue'] ?? null; @@ -127,6 +142,7 @@ public function __construct( $this->multiline = $values['multiline'] ?? null; $this->password = $values['password'] ?? null; $this->comb = $values['comb'] ?? null; + $this->format = $values['format'] ?? null; } /** diff --git a/src/Types/FormFieldFormat.php b/src/Types/FormFieldFormat.php new file mode 100644 index 00000000..88bb1f96 --- /dev/null +++ b/src/Types/FormFieldFormat.php @@ -0,0 +1,244 @@ +kind = $values['kind']; + $this->value = $values['value']; + } + + /** + * @param FormFieldFormatDate $date + * @return FormFieldFormat + */ + public static function date(FormFieldFormatDate $date): FormFieldFormat + { + return new FormFieldFormat([ + 'kind' => 'date', + 'value' => $date, + ]); + } + + /** + * @param FormFieldFormatTime $time + * @return FormFieldFormat + */ + public static function time(FormFieldFormatTime $time): FormFieldFormat + { + return new FormFieldFormat([ + 'kind' => 'time', + 'value' => $time, + ]); + } + + /** + * @param FormFieldFormatOther $other + * @return FormFieldFormat + */ + public static function other(FormFieldFormatOther $other): FormFieldFormat + { + return new FormFieldFormat([ + 'kind' => 'other', + 'value' => $other, + ]); + } + + /** + * @return bool + */ + public function isDate(): bool + { + return $this->value instanceof FormFieldFormatDate && $this->kind === 'date'; + } + + /** + * @return FormFieldFormatDate + */ + public function asDate(): FormFieldFormatDate + { + if (!($this->value instanceof FormFieldFormatDate && $this->kind === 'date')) { + throw new Exception( + "Expected date; got " . $this->kind . " with value of type " . get_debug_type($this->value), + ); + } + + return $this->value; + } + + /** + * @return bool + */ + public function isTime(): bool + { + return $this->value instanceof FormFieldFormatTime && $this->kind === 'time'; + } + + /** + * @return FormFieldFormatTime + */ + public function asTime(): FormFieldFormatTime + { + if (!($this->value instanceof FormFieldFormatTime && $this->kind === 'time')) { + throw new Exception( + "Expected time; got " . $this->kind . " with value of type " . get_debug_type($this->value), + ); + } + + return $this->value; + } + + /** + * @return bool + */ + public function isOther(): bool + { + return $this->value instanceof FormFieldFormatOther && $this->kind === 'other'; + } + + /** + * @return FormFieldFormatOther + */ + public function asOther(): FormFieldFormatOther + { + if (!($this->value instanceof FormFieldFormatOther && $this->kind === 'other')) { + throw new Exception( + "Expected other; 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 'date': + $value = $this->asDate()->jsonSerialize(); + $result = array_merge($value, $result); + break; + case 'time': + $value = $this->asTime()->jsonSerialize(); + $result = array_merge($value, $result); + break; + case 'other': + $value = $this->asOther()->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 'date': + $args['value'] = FormFieldFormatDate::jsonDeserialize($data); + break; + case 'time': + $args['value'] = FormFieldFormatTime::jsonDeserialize($data); + break; + case 'other': + $args['value'] = FormFieldFormatOther::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/FormFieldFormatDate.php b/src/Types/FormFieldFormatDate.php new file mode 100644 index 00000000..d44aa876 --- /dev/null +++ b/src/Types/FormFieldFormatDate.php @@ -0,0 +1,34 @@ +pattern = $values['pattern']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/FormFieldFormatOther.php b/src/Types/FormFieldFormatOther.php new file mode 100644 index 00000000..adaef117 --- /dev/null +++ b/src/Types/FormFieldFormatOther.php @@ -0,0 +1,26 @@ +toJson(); + } +} diff --git a/src/Types/FormFieldFormatTime.php b/src/Types/FormFieldFormatTime.php new file mode 100644 index 00000000..990520c6 --- /dev/null +++ b/src/Types/FormFieldFormatTime.php @@ -0,0 +1,34 @@ +pattern = $values['pattern']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/FormFieldFormatWritable.php b/src/Types/FormFieldFormatWritable.php new file mode 100644 index 00000000..cebd5bbd --- /dev/null +++ b/src/Types/FormFieldFormatWritable.php @@ -0,0 +1,196 @@ +kind = $values['kind']; + $this->value = $values['value']; + } + + /** + * @param FormFieldFormatWritableDate $date + * @return FormFieldFormatWritable + */ + public static function date(FormFieldFormatWritableDate $date): FormFieldFormatWritable + { + return new FormFieldFormatWritable([ + 'kind' => 'date', + 'value' => $date, + ]); + } + + /** + * @param FormFieldFormatWritableTime $time + * @return FormFieldFormatWritable + */ + public static function time(FormFieldFormatWritableTime $time): FormFieldFormatWritable + { + return new FormFieldFormatWritable([ + 'kind' => 'time', + 'value' => $time, + ]); + } + + /** + * @return bool + */ + public function isDate(): bool + { + return $this->value instanceof FormFieldFormatWritableDate && $this->kind === 'date'; + } + + /** + * @return FormFieldFormatWritableDate + */ + public function asDate(): FormFieldFormatWritableDate + { + if (!($this->value instanceof FormFieldFormatWritableDate && $this->kind === 'date')) { + throw new Exception( + "Expected date; got " . $this->kind . " with value of type " . get_debug_type($this->value), + ); + } + + return $this->value; + } + + /** + * @return bool + */ + public function isTime(): bool + { + return $this->value instanceof FormFieldFormatWritableTime && $this->kind === 'time'; + } + + /** + * @return FormFieldFormatWritableTime + */ + public function asTime(): FormFieldFormatWritableTime + { + if (!($this->value instanceof FormFieldFormatWritableTime && $this->kind === 'time')) { + throw new Exception( + "Expected time; 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 'date': + $value = $this->asDate()->jsonSerialize(); + $result = array_merge($value, $result); + break; + case 'time': + $value = $this->asTime()->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 'date': + $args['value'] = FormFieldFormatWritableDate::jsonDeserialize($data); + break; + case 'time': + $args['value'] = FormFieldFormatWritableTime::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/FormFieldFormatWritableDate.php b/src/Types/FormFieldFormatWritableDate.php new file mode 100644 index 00000000..626093ac --- /dev/null +++ b/src/Types/FormFieldFormatWritableDate.php @@ -0,0 +1,34 @@ +pattern = $values['pattern']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/FormFieldFormatWritableTime.php b/src/Types/FormFieldFormatWritableTime.php new file mode 100644 index 00000000..5fac74e2 --- /dev/null +++ b/src/Types/FormFieldFormatWritableTime.php @@ -0,0 +1,34 @@ +pattern = $values['pattern']; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/FormFieldListbox.php b/src/Types/FormFieldListbox.php index 45b18a21..76fb3c4b 100644 --- a/src/Types/FormFieldListbox.php +++ b/src/Types/FormFieldListbox.php @@ -82,6 +82,12 @@ class FormFieldListbox extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?string $createdBy */ @@ -174,6 +180,7 @@ class FormFieldListbox extends JsonSerializableType * mappingName?: ?string, * actions?: ?PdfFieldActions, * groupId?: ?string, + * purpose?: ?string, * createdBy?: ?string, * createdAt?: ?DateTime, * filledBy?: ?string, @@ -197,6 +204,7 @@ public function __construct( $this->defaultValueEntry = $values['defaultValueEntry']; $this->actions = $values['actions'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->createdBy = $values['createdBy'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->filledBy = $values['filledBy'] ?? null; diff --git a/src/Types/FormFieldPatch.php b/src/Types/FormFieldPatch.php index 9e6599c2..87e02157 100644 --- a/src/Types/FormFieldPatch.php +++ b/src/Types/FormFieldPatch.php @@ -51,6 +51,12 @@ class FormFieldPatch extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?FieldActionsPatch $actions */ @@ -126,6 +132,12 @@ class FormFieldPatch extends JsonSerializableType #[JsonProperty('options'), ArrayType([FormFieldPatchOptionsItem::class])] public ?array $options; + /** + * @var ?FormFieldFormatWritable $format + */ + #[JsonProperty('format')] + public ?FormFieldFormatWritable $format; + /** * @param array{ * name?: ?string, @@ -135,6 +147,7 @@ class FormFieldPatch extends JsonSerializableType * alternateName?: ?string, * mappingName?: ?string, * groupId?: ?string, + * purpose?: ?string, * actions?: ?FieldActionsPatch, * kind?: ?value-of, * defaultValue?: ( @@ -150,6 +163,7 @@ class FormFieldPatch extends JsonSerializableType * edit?: ?bool, * multiSelect?: ?bool, * options?: ?array, + * format?: ?FormFieldFormatWritable, * } $values */ public function __construct( @@ -162,6 +176,7 @@ public function __construct( $this->alternateName = $values['alternateName'] ?? null; $this->mappingName = $values['mappingName'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->actions = $values['actions'] ?? null; $this->kind = $values['kind'] ?? null; $this->defaultValue = $values['defaultValue'] ?? null; @@ -174,6 +189,7 @@ public function __construct( $this->edit = $values['edit'] ?? null; $this->multiSelect = $values['multiSelect'] ?? null; $this->options = $values['options'] ?? null; + $this->format = $values['format'] ?? null; } /** diff --git a/src/Types/FormFieldPushbutton.php b/src/Types/FormFieldPushbutton.php index 22cebaa8..83f80cc0 100644 --- a/src/Types/FormFieldPushbutton.php +++ b/src/Types/FormFieldPushbutton.php @@ -82,6 +82,12 @@ class FormFieldPushbutton extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?string $createdBy */ @@ -139,6 +145,7 @@ class FormFieldPushbutton extends JsonSerializableType * mappingName?: ?string, * actions?: ?PdfFieldActions, * groupId?: ?string, + * purpose?: ?string, * createdBy?: ?string, * createdAt?: ?DateTime, * filledBy?: ?string, @@ -162,6 +169,7 @@ public function __construct( $this->defaultValueEntry = $values['defaultValueEntry']; $this->actions = $values['actions'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->createdBy = $values['createdBy'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->filledBy = $values['filledBy'] ?? null; diff --git a/src/Types/FormFieldRadio.php b/src/Types/FormFieldRadio.php index bde09925..e17f2460 100644 --- a/src/Types/FormFieldRadio.php +++ b/src/Types/FormFieldRadio.php @@ -82,6 +82,12 @@ class FormFieldRadio extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?string $createdBy */ @@ -160,6 +166,7 @@ class FormFieldRadio extends JsonSerializableType * mappingName?: ?string, * actions?: ?PdfFieldActions, * groupId?: ?string, + * purpose?: ?string, * createdBy?: ?string, * createdAt?: ?DateTime, * filledBy?: ?string, @@ -183,6 +190,7 @@ public function __construct( $this->defaultValueEntry = $values['defaultValueEntry']; $this->actions = $values['actions'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->createdBy = $values['createdBy'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->filledBy = $values['filledBy'] ?? null; diff --git a/src/Types/FormFieldSignature.php b/src/Types/FormFieldSignature.php index 9e0c2f1b..f3d86021 100644 --- a/src/Types/FormFieldSignature.php +++ b/src/Types/FormFieldSignature.php @@ -82,6 +82,12 @@ class FormFieldSignature extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?string $createdBy */ @@ -139,6 +145,7 @@ class FormFieldSignature extends JsonSerializableType * mappingName?: ?string, * actions?: ?PdfFieldActions, * groupId?: ?string, + * purpose?: ?string, * createdBy?: ?string, * createdAt?: ?DateTime, * filledBy?: ?string, @@ -162,6 +169,7 @@ public function __construct( $this->defaultValueEntry = $values['defaultValueEntry']; $this->actions = $values['actions'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->createdBy = $values['createdBy'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->filledBy = $values['filledBy'] ?? null; diff --git a/src/Types/FormFieldText.php b/src/Types/FormFieldText.php index b935749c..585ac0d9 100644 --- a/src/Types/FormFieldText.php +++ b/src/Types/FormFieldText.php @@ -82,6 +82,12 @@ class FormFieldText extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?string $createdBy */ @@ -160,6 +166,12 @@ class FormFieldText extends JsonSerializableType #[JsonProperty('comb')] public bool $comb; + /** + * @var ?FormFieldFormat $format The shape a text field's or a dropdown's value has, by its `kind`: a date or a time with the pattern it is shown in, or `other` for a format script the engine does not recognise. A newer server can add kinds: read one your client doesn't know as `other`. + */ + #[JsonProperty('format')] + public ?FormFieldFormat $format; + /** * @param array{ * ref: FormFieldRef, @@ -180,6 +192,7 @@ class FormFieldText extends JsonSerializableType * mappingName?: ?string, * actions?: ?PdfFieldActions, * groupId?: ?string, + * purpose?: ?string, * createdBy?: ?string, * createdAt?: ?DateTime, * filledBy?: ?string, @@ -187,6 +200,7 @@ class FormFieldText extends JsonSerializableType * filledAt?: ?DateTime, * importedBy?: ?string, * maxLength?: ?int, + * format?: ?FormFieldFormat, * } $values */ public function __construct( @@ -204,6 +218,7 @@ public function __construct( $this->defaultValueEntry = $values['defaultValueEntry']; $this->actions = $values['actions'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->createdBy = $values['createdBy'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->filledBy = $values['filledBy'] ?? null; @@ -217,6 +232,7 @@ public function __construct( $this->multiline = $values['multiline']; $this->password = $values['password']; $this->comb = $values['comb']; + $this->format = $values['format'] ?? null; } /** diff --git a/src/Types/FormFieldUnknown.php b/src/Types/FormFieldUnknown.php index fd5cd52a..bd4279c3 100644 --- a/src/Types/FormFieldUnknown.php +++ b/src/Types/FormFieldUnknown.php @@ -82,6 +82,12 @@ class FormFieldUnknown extends JsonSerializableType #[JsonProperty('groupId')] public ?string $groupId; + /** + * @var ?string $purpose + */ + #[JsonProperty('purpose')] + public ?string $purpose; + /** * @var ?string $createdBy */ @@ -146,6 +152,7 @@ class FormFieldUnknown extends JsonSerializableType * mappingName?: ?string, * actions?: ?PdfFieldActions, * groupId?: ?string, + * purpose?: ?string, * createdBy?: ?string, * createdAt?: ?DateTime, * filledBy?: ?string, @@ -169,6 +176,7 @@ public function __construct( $this->defaultValueEntry = $values['defaultValueEntry']; $this->actions = $values['actions'] ?? null; $this->groupId = $values['groupId'] ?? null; + $this->purpose = $values['purpose'] ?? null; $this->createdBy = $values['createdBy'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->filledBy = $values['filledBy'] ?? null;