diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 2b3ce48..9c530e9 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -17,3 +17,6 @@ jobs: - name: Check release environment run: | bash ./bin/check-release-environment + env: + PACKAGIST_USERNAME: ${{ secrets.LEGALESIGN_SDK_PACKAGIST_USERNAME || secrets.PACKAGIST_USERNAME }} + PACKAGIST_SAFE_KEY: ${{ secrets.LEGALESIGN_SDK_PACKAGIST_SAFE_KEY || secrets.PACKAGIST_SAFE_KEY }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c7159c1..3d2ac0b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.0.2" + ".": "0.1.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index cb8a481..0698fce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 0.1.0 (2025-11-21) + +Full Changelog: [v0.0.2...v0.1.0](https://github.com/legalesign/legalesign-rest-php/compare/v0.0.2...v0.1.0) + +### ⚠ BREAKING CHANGES + +* **client:** redesign methods +* remove confusing `toArray()` alias to `__serialize()` in favour of `toProperties()` + +### Features + +* **client:** redesign methods ([b87bd20](https://github.com/legalesign/legalesign-rest-php/commit/b87bd20ef5c1ea5acb9b93afe2444a891fb815ec)) +* remove confusing `toArray()` alias to `__serialize()` in favour of `toProperties()` ([bf37591](https://github.com/legalesign/legalesign-rest-php/commit/bf3759140c9a01bcb0fbe3146c287dc2b017b5dd)) + + +### Bug Fixes + +* **ci:** release doctor workflow ([310295d](https://github.com/legalesign/legalesign-rest-php/commit/310295d4faf056e60db3bea642b56ede1fbe94ae)) +* ensure auth methods return non-nullable arrays ([50fd6a3](https://github.com/legalesign/legalesign-rest-php/commit/50fd6a367f425117f47c55fc4c45d1d484b2f2ae)) +* inverted retry condition ([4dc29ef](https://github.com/legalesign/legalesign-rest-php/commit/4dc29ef02033890b21b15568dc0ddc46c2720d04)) +* rename invalid types ([48928d5](https://github.com/legalesign/legalesign-rest-php/commit/48928d511add9acafeaa99ab8f50f964dc1793fb)) + + +### Chores + +* add license ([3260f92](https://github.com/legalesign/legalesign-rest-php/commit/3260f921032f819561e6f7d92c4b22e2efb88604)) +* **client:** refactor error type constructors ([e4b55a3](https://github.com/legalesign/legalesign-rest-php/commit/e4b55a33b54d105319eec00954fb07aed25c708f)) +* **client:** send metadata headers ([e8c30b5](https://github.com/legalesign/legalesign-rest-php/commit/e8c30b5349cae440f50c79ed0a5652dbaf546baa)) +* **internal:** codegen related update ([0c8a123](https://github.com/legalesign/legalesign-rest-php/commit/0c8a123285894fa8f9990f3d2a79061c05cee492)) +* refactor methods ([9db1cb8](https://github.com/legalesign/legalesign-rest-php/commit/9db1cb856e0e6a5aac3e724c16f95f10ac28762e)) +* use pascal case for phpstan typedefs ([be21370](https://github.com/legalesign/legalesign-rest-php/commit/be213708da8645553228ed4814d20d1b9292b443)) + ## 0.0.2 (2025-09-23) Full Changelog: [v0.0.1...v0.0.2](https://github.com/legalesign/legalesign-rest-php/compare/v0.0.1...v0.0.2) diff --git a/README.md b/README.md index fbb973a..8f9123b 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ use LegalesignSDK\Client; $client = new Client(apiKey: getenv("LEGALESIGN_SDK_API_KEY") ?: "My API Key"); -$documents = $client->document->list(group: "REPLACE_ME"); +$documents = $client->document->list(["group" => "REPLACE_ME"]); var_dump($documents->meta); ``` @@ -71,7 +71,7 @@ When the library is unable to connect to the API, or if the API returns a non-su use LegalesignSDK\Core\Exceptions\APIConnectionException; try { - $documents = $client->document->list(group: "REPLACE_ME"); + $documents = $client->document->list(["group" => "REPLACE_ME"]); } catch (APIConnectionException $e) { echo "The server could not be reached", PHP_EOL; var_dump($e->getPrevious()); @@ -118,7 +118,7 @@ $client = new Client(maxRetries: 0); // Or, configure per-request: $result = $client->document->list( - group: "REPLACE_ME", requestOptions: RequestOptions::with(maxRetries: 5) + ["group" => "REPLACE_ME"], RequestOptions::with(maxRetries: 5) ); ``` @@ -138,15 +138,13 @@ Note: the `extra*` parameters of the same name overrides the documented paramete use LegalesignSDK\RequestOptions; $documents = $client->document->list( - group: "REPLACE_ME", - requestOptions: RequestOptions::with( + ["group" => "REPLACE_ME"], + RequestOptions::with( extraQueryParams: ["my_query_parameter" => "value"], extraBodyParams: ["my_body_parameter" => "value"], extraHeaders: ["my-header" => "value"], ), ); - -var_dump($documents["my_undocumented_property"]); ``` #### Undocumented request params diff --git a/composer.json b/composer.json index 2cd74e8..b073dde 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,11 @@ { "$schema": "https://getcomposer.org/schema.json", + "license": "Apache-2.0", "autoload": { - "files": ["src/Core.php", "src/Client.php"], + "files": [ + "src/Core.php", + "src/Client.php" + ], "psr-4": { "LegalesignSDK\\": "src/" } diff --git a/release-please-config.json b/release-please-config.json index 1891660..5c15181 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -61,6 +61,7 @@ ], "release-type": "php", "extra-files": [ - "README.md" + "README.md", + "src/Client.php" ] } \ No newline at end of file diff --git a/scripts/lint b/scripts/lint index 6d629c2..13f2f01 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,4 +5,4 @@ set -e cd -- "$(dirname -- "$0")/.." echo "==> Running PHPStan" -exec -- ./vendor/bin/phpstan analyse --memory-limit=1G +exec -- ./vendor/bin/phpstan analyse --memory-limit=2G diff --git a/src/Client.php b/src/Client.php index 111be34..b0a3420 100644 --- a/src/Client.php +++ b/src/Client.php @@ -58,7 +58,7 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) { $this->apiKey = (string) ($apiKey ?? getenv('LEGALESIGN_SDK_API_KEY')); - $base = $baseUrl ?? getenv( + $baseUrl ??= getenv( 'LEGALESIGN_SDK_BASE_URL' ) ?: 'https://eu-api.legalesign.com/api/v1'; @@ -70,10 +70,20 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) ); parent::__construct( + // x-release-please-start-version headers: [ - 'Content-Type' => 'application/json', 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'User-Agent' => sprintf('legalesign-sdk/PHP %s', '0.1.0'), + 'X-Stainless-Lang' => 'php', + 'X-Stainless-Package-Version' => '0.1.0', + 'X-Stainless-OS' => $this->getNormalizedOS(), + 'X-Stainless-Arch' => $this->getNormalizedArchitecture(), + 'X-Stainless-Runtime' => 'php', + 'X-Stainless-Runtime-Version' => phpversion(), ], - baseUrl: $base, + // x-release-please-end + baseUrl: $baseUrl, options: $options, ); @@ -86,9 +96,9 @@ public function __construct(?string $apiKey = null, ?string $baseUrl = null) $this->templatepdf = new TemplatepdfService($this); } - /** @return array */ + /** @return array */ protected function authHeaders(): array { - return ['Authorization' => $this->apiKey]; + return $this->apiKey ? ['Authorization' => $this->apiKey] : []; } } diff --git a/src/Core/BaseClient.php b/src/Core/BaseClient.php index b2869e4..1f294b7 100644 --- a/src/Core/BaseClient.php +++ b/src/Core/BaseClient.php @@ -24,19 +24,19 @@ * @phpstan-type normalized_request = array{ * method: string, * path: string, - * query: array, - * headers: array>, + * query: array, + * headers: array>, * body: mixed, * } */ -class BaseClient +abstract class BaseClient { protected UriInterface $baseUrl; /** * @internal * - * @param array|null> $headers + * @param array|null> $headers */ public function __construct( protected array $headers, @@ -49,11 +49,11 @@ public function __construct( /** * @param string|list $path - * @param array $query - * @param array $headers + * @param array $query + * @param array $headers * @param class-string> $page * @param class-string> $stream - * @param RequestOptions|array|null $options + * @param RequestOptions|array|null $options */ public function request( string $method, @@ -77,14 +77,11 @@ public function request( // @phpstan-ignore-next-line $rsp = $this->sendRequest($opts, req: $request, data: $body, redirectCount: 0, retryCount: 0); - $decoded = Util::decodeContent($rsp); - if (!is_null($stream)) { return new $stream( convert: $convert, request: $request, - response: $rsp, - stream: $decoded + response: $rsp ); } @@ -93,37 +90,84 @@ public function request( convert: $convert, client: $this, request: $req, + response: $rsp, options: $opts, - data: $decoded, ); } if (!is_null($convert)) { - return Conversion::coerce($convert, value: $decoded); + return Conversion::coerceResponse($convert, response: $rsp); } - return $decoded; + return Util::decodeContent($rsp); } - /** @return array */ - protected function authHeaders(): array + /** @return array */ + abstract protected function authHeaders(): array; + + protected function getNormalizedOS(): string { - return []; + $os = strtolower(PHP_OS_FAMILY); + + switch ($os) { + case 'windows': + return 'Windows'; + + case 'darwin': + return 'MacOS'; + + case 'linux': + return 'Linux'; + + case 'bsd': + case 'freebsd': + case 'openbsd': + return 'BSD'; + + case 'solaris': + return 'Solaris'; + + case 'unix': + case 'unknown': + return 'Unknown'; + + default: + return 'Other:'.$os; + } + } + + protected function getNormalizedArchitecture(): string + { + $arch = php_uname('m'); + if (false !== strpos($arch, 'x86_64') || false !== strpos($arch, 'amd64')) { + return 'x64'; + } + if (false !== strpos($arch, 'i386') || false !== strpos($arch, 'i686')) { + return 'x32'; + } + if (false !== strpos($arch, 'aarch64') || false !== strpos($arch, 'arm64')) { + return 'arm64'; + } + if (false !== strpos($arch, 'arm')) { + return 'arm'; + } + + return 'unknown'; } /** * @internal * * @param string|list $path - * @param array $query - * @param array|null> $headers + * @param array $query + * @param array|null> $headers * @param array{ * timeout?: float|null, * maxRetries?: int|null, * initialRetryDelay?: float|null, * maxRetryDelay?: float|null, - * extraHeaders?: array|null>|null, - * extraQueryParams?: array|null, + * extraHeaders?: array|null>|null, + * extraQueryParams?: array|null, * extraBodyParams?: mixed, * transporter?: ClientInterface|null, * uriFactory?: UriFactoryInterface|null, @@ -145,14 +189,14 @@ protected function buildRequest( $parsedPath = Util::parsePath($path); - /** @var array $mergedQuery */ + /** @var array $mergedQuery */ $mergedQuery = array_merge_recursive( $query, $options->extraQueryParams ?? [], ); $uri = Util::joinUri($this->baseUrl, path: $parsedPath, query: $mergedQuery)->__toString(); - /** @var array|null> $mergedHeaders */ + /** @var array|null> $mergedHeaders */ $mergedHeaders = [...$this->headers, ...$this->authHeaders(), ...$headers, @@ -232,8 +276,7 @@ protected function retryDelay( /** * @internal * - * @param bool|int|float|string|resource|\Traversable|array|null $data + * @param bool|int|float|string|resource|\Traversable|array|null $data */ protected function sendRequest( RequestOptions $opts, @@ -244,6 +287,8 @@ protected function sendRequest( ): ResponseInterface { assert(null !== $opts->streamFactory && null !== $opts->transporter); + $req = $req->withHeader('X-Stainless-Retry-Count', strval($retryCount)); + $req = Util::withSetBody($opts->streamFactory, req: $req, body: $data); $rsp = null; @@ -270,7 +315,7 @@ protected function sendRequest( } if ($code >= 400 || is_null($rsp)) { - if ($this->shouldRetry($opts, retryCount: $retryCount, rsp: $rsp)) { + if (!$this->shouldRetry($opts, retryCount: $retryCount, rsp: $rsp)) { $exn = is_null($rsp) ? new APIConnectionException($req, previous: $err) : APIStatusException::from(request: $req, response: $rsp); throw $exn; diff --git a/src/Core/Concerns/SdkModel.php b/src/Core/Concerns/SdkModel.php index 9b6f141..9553a28 100644 --- a/src/Core/Concerns/SdkModel.php +++ b/src/Core/Concerns/SdkModel.php @@ -32,9 +32,9 @@ trait SdkModel */ public function __serialize(): array { - $rows = [...Util::get_object_vars($this), ...$this->_data]; // @phpstan-ignore-line + $properties = $this->toProperties(); // @phpstan-ignore-line - return array_map(static fn ($v) => self::serialize($v), array: $rows); + return array_map(static fn ($v) => self::serialize($v), array: $properties); } /** @@ -98,11 +98,13 @@ public function __get(string $key): mixed } /** + * @internal + * * @return Shape */ - public function toArray(): array + public function toProperties(): array { - return $this->__serialize(); // @phpstan-ignore-line + return [...Util::get_object_vars($this), ...$this->_data]; // @phpstan-ignore-line } /** @@ -257,7 +259,7 @@ private function initialize(): void private static function serialize(mixed $value): mixed { if ($value instanceof BaseModel) { - return $value->toArray(); + return $value->toProperties(); } if (is_array($value)) { diff --git a/src/Core/Concerns/SdkResponse.php b/src/Core/Concerns/SdkResponse.php new file mode 100644 index 0000000..c8466ae --- /dev/null +++ b/src/Core/Concerns/SdkResponse.php @@ -0,0 +1,29 @@ +_rawResponse = $response; + $instance->__unserialize(Util::decodeContent($response)); // @phpstan-ignore-line + + return $instance; + } + + public function getRawResponse(): ?ResponseInterface + { + return $this->_rawResponse; + } +} diff --git a/src/Core/Contracts/BaseModel.php b/src/Core/Contracts/BaseModel.php index 65b979c..a4d03cf 100644 --- a/src/Core/Contracts/BaseModel.php +++ b/src/Core/Contracts/BaseModel.php @@ -14,5 +14,5 @@ interface BaseModel extends \ArrayAccess, \JsonSerializable, \Stringable, ConverterSource { /** @return array */ - public function toArray(): array; + public function toProperties(): array; } diff --git a/src/Core/Contracts/BasePage.php b/src/Core/Contracts/BasePage.php index 8644885..2bd71a8 100644 --- a/src/Core/Contracts/BasePage.php +++ b/src/Core/Contracts/BasePage.php @@ -8,6 +8,7 @@ use LegalesignSDK\Core\Conversion\Contracts\Converter; use LegalesignSDK\Core\Conversion\Contracts\ConverterSource; use LegalesignSDK\RequestOptions; +use Psr\Http\Message\ResponseInterface; /** * @internal @@ -30,7 +31,7 @@ public function __construct( Client $client, array $request, RequestOptions $options, - mixed $data, + ResponseInterface $response, ); public function hasNextPage(): bool; diff --git a/src/Core/Contracts/BaseStream.php b/src/Core/Contracts/BaseStream.php index d099d1e..e290ac6 100644 --- a/src/Core/Contracts/BaseStream.php +++ b/src/Core/Contracts/BaseStream.php @@ -18,14 +18,10 @@ */ interface BaseStream extends \IteratorAggregate { - /** - * @param \Generator $stream - */ public function __construct( Converter|ConverterSource|string $convert, RequestInterface $request, ResponseInterface $response, - \Generator $stream, ); /** diff --git a/src/Core/Conversion.php b/src/Core/Conversion.php index 770bddc..5ad4752 100644 --- a/src/Core/Conversion.php +++ b/src/Core/Conversion.php @@ -7,8 +7,13 @@ use LegalesignSDK\Core\Conversion\CoerceState; use LegalesignSDK\Core\Conversion\Contracts\Converter; use LegalesignSDK\Core\Conversion\Contracts\ConverterSource; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; use LegalesignSDK\Core\Conversion\DumpState; +use Psr\Http\Message\ResponseInterface; +/** + * @internal + */ final class Conversion { public static function dump_unknown(mixed $value, DumpState $state): mixed @@ -38,6 +43,15 @@ public static function dump_unknown(mixed $value, DumpState $state): mixed return $value; } + public static function coerceResponse(Converter|ConverterSource|string $target, ResponseInterface $response): mixed + { + if (is_a($target, ResponseConverter::class, allow_string: true)) { + return $target::fromResponse($response); + } + + return self::coerce($target, Util::decodeContent($response)); + } + public static function coerce(Converter|ConverterSource|string $target, mixed $value, CoerceState $state = new CoerceState): mixed { if ($value instanceof $target) { diff --git a/src/Core/Conversion/Contracts/ResponseConverter.php b/src/Core/Conversion/Contracts/ResponseConverter.php new file mode 100644 index 0000000..af1595e --- /dev/null +++ b/src/Core/Conversion/Contracts/ResponseConverter.php @@ -0,0 +1,18 @@ +toArray(); + $value = $value->toProperties(); } if (is_array($value)) { diff --git a/src/Core/Exceptions/APITimeoutException.php b/src/Core/Exceptions/APITimeoutException.php index a782474..b088ebf 100644 --- a/src/Core/Exceptions/APITimeoutException.php +++ b/src/Core/Exceptions/APITimeoutException.php @@ -10,7 +10,7 @@ class APITimeoutException extends APIConnectionException protected const DESC = 'LegalesignSDK API Timeout Exception'; public function __construct( - public RequestInterface $request, + RequestInterface $request, ?\Throwable $previous = null, string $message = 'Request timed out.', ) { diff --git a/src/Core/Implementation/HasRawResponse.php b/src/Core/Implementation/HasRawResponse.php deleted file mode 100644 index 611dcd9..0000000 --- a/src/Core/Implementation/HasRawResponse.php +++ /dev/null @@ -1,10 +0,0 @@ - + * @return array */ - public static function get_object_vars(object $object1): array + public static function get_object_vars(object $object): array { - return get_object_vars($object1); + return get_object_vars($object); } /** * @template T * - * @param array $array - * @param array $map + * @param array $array + * @param array $map * - * @return array + * @return array */ public static function array_transform_keys(array $array, array $map): array { @@ -52,9 +52,9 @@ public static function array_transform_keys(array $array, array $map): array } /** - * @param array $arr + * @param array $arr * - * @return array + * @return array */ public static function array_filter_omit(array $arr): array { @@ -106,7 +106,7 @@ public static function parsePath(string|array $path): string } /** - * @param array $query + * @param array $query */ public static function joinUri( UriInterface $base, @@ -141,7 +141,7 @@ public static function joinUri( } /** - * @param array|null> $headers + * @param array|null> $headers */ public static function withSetHeaders( RequestInterface $req, @@ -182,8 +182,7 @@ public static function streamIterator(StreamInterface $stream): \Iterator } /** - * @param bool|int|float|string|resource|\Traversable|array|null $body + * @param bool|int|float|string|resource|\Traversable|array|null $body */ public static function withSetBody( StreamFactoryInterface $factory, @@ -409,8 +408,7 @@ private static function writeMultipartChunk( } /** - * @param bool|int|float|string|resource|\Traversable|array|null $body + * @param bool|int|float|string|resource|\Traversable|array|null $body * * @return array{string, \Generator} */ diff --git a/src/Document/DocumentCreateParams.php b/src/Document/DocumentCreateParams.php index bcb99f3..aa68e46 100644 --- a/src/Document/DocumentCreateParams.php +++ b/src/Document/DocumentCreateParams.php @@ -8,48 +8,36 @@ use LegalesignSDK\Core\Concerns\SdkModel; use LegalesignSDK\Core\Concerns\SdkParams; use LegalesignSDK\Core\Contracts\BaseModel; -use LegalesignSDK\Document\DocumentCreateParams\PdfPasswordType; use LegalesignSDK\Document\DocumentCreateParams\Signer; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new DocumentCreateParams); // set properties as needed - * $client->document->create(...$params->toArray()); - * ``` * Create signing document. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\DocumentService::create() * - * `$client->document->create(...$params->toArray());` - * - * @see LegalesignSDK\Document->create - * - * @phpstan-type document_create_params = array{ + * @phpstan-type DocumentCreateParamsShape = array{ * group: string, * name: string, * signers: list, - * appendPdf?: bool, - * autoArchive?: bool, - * ccEmails?: string, - * convertSenderToSigner?: bool, - * doEmail?: bool, + * append_pdf?: bool, + * auto_archive?: bool, + * cc_emails?: string, + * convert_sender_to_signer?: bool, + * do_email?: bool, * footer?: string, - * footerHeight?: int, + * footer_height?: int, * header?: string, - * headerHeight?: int, - * pdfPassword?: string, - * pdfPasswordType?: PdfPasswordType|value-of, - * pdftext?: array, + * header_height?: int, + * pdf_password?: string, + * pdf_password_type?: 1|2, + * pdftext?: array, * redirect?: string, * reminders?: string, - * returnSignerLinks?: bool, - * signatureType?: int, - * signersInOrder?: bool, - * signertext?: array, - * strictFields?: bool, + * return_signer_links?: bool, + * signature_type?: int, + * signers_in_order?: bool, + * signertext?: array, + * strict_fields?: bool, * tag?: string, * tag1?: string, * tag2?: string, @@ -61,7 +49,7 @@ */ final class DocumentCreateParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -78,32 +66,32 @@ final class DocumentCreateParams implements BaseModel /** * Append Legalesign validation info to final PDF. If not included uses the group default. */ - #[Api('append_pdf', optional: true)] - public ?bool $appendPdf; + #[Api(optional: true)] + public ?bool $append_pdf; /** * Send to archive soon after signing. Keeps web app clutter free. */ - #[Api('auto_archive', optional: true)] - public ?bool $autoArchive; + #[Api(optional: true)] + public ?bool $auto_archive; /** * Comma delimited string of email addresses that are notified of signing or rejection. */ - #[Api('cc_emails', optional: true)] - public ?string $ccEmails; + #[Api(optional: true)] + public ?string $cc_emails; /** * If any sender fields are left blank, convert them to fields for the first recipient. */ - #[Api('convert_sender_to_signer', optional: true)] - public ?bool $convertSenderToSigner; + #[Api(optional: true)] + public ?bool $convert_sender_to_signer; /** * Use Legalesign email to send notification emails. If false suppresses all emails. */ - #[Api('do_email', optional: true)] - public ?bool $doEmail; + #[Api(optional: true)] + public ?bool $do_email; /** * Text doc only. The footer for the final pdf. Use keyword \"default\" to use group default footer. @@ -114,8 +102,8 @@ final class DocumentCreateParams implements BaseModel /** * Text based doc only. Pixel height of PDF footer, if used. 1px = 0.025cm. */ - #[Api('footer_height', optional: true)] - public ?int $footerHeight; + #[Api(optional: true)] + public ?int $footer_height; /** * Text based doc only. The header for the final pdf. Use keyword \"default\" to use group header footer. @@ -126,27 +114,27 @@ final class DocumentCreateParams implements BaseModel /** * Text based doc only. Pixel height of final PDF footer, if used. 1px = 0.025cm. */ - #[Api('header_height', optional: true)] - public ?int $headerHeight; + #[Api(optional: true)] + public ?int $header_height; /** * Set a password. Must be ascii encode-able, you must also set signature_type to 4 and choose a pdf_password_type. */ - #[Api('pdf_password', optional: true)] - public ?string $pdfPassword; + #[Api(optional: true)] + public ?string $pdf_password; /** * 1 to store password, 2 for to delete from our records upon final signing. * - * @var value-of|null $pdfPasswordType + * @var 1|2|null $pdf_password_type */ - #[Api('pdf_password_type', enum: PdfPasswordType::class, optional: true)] - public ?int $pdfPasswordType; + #[Api(optional: true)] + public ?int $pdf_password_type; /** * Assign values to PDF sender fields, use field labels as keys. Requires unique fields labels. See also strict_fields. * - * @var array|null $pdftext + * @var array|null $pdftext */ #[Api(map: 'string', optional: true)] public ?array $pdftext; @@ -166,25 +154,25 @@ final class DocumentCreateParams implements BaseModel /** * Return document links for signers in the response BODY. */ - #[Api('return_signer_links', optional: true)] - public ?bool $returnSignerLinks; + #[Api(optional: true)] + public ?bool $return_signer_links; /** * Use 4 to get your executed PDF Certified. Recommended. Defaults to 1 (uses a sha256 hash for document integrity). */ - #[Api('signature_type', optional: true)] - public ?int $signatureType; + #[Api(optional: true)] + public ?int $signature_type; /** * Notify signers in their order sequence. If false all are notified simulataneously. */ - #[Api('signers_in_order', optional: true)] - public ?bool $signersInOrder; + #[Api(optional: true)] + public ?bool $signers_in_order; /** * Add custom placeholders to signer fields, using labels as keys in an object (as for pdftext). Relies on unique labelling. * - * @var array|null $signertext + * @var array|null $signertext */ #[Api(map: 'string', optional: true)] public ?array $signertext; @@ -192,8 +180,8 @@ final class DocumentCreateParams implements BaseModel /** * pdftext fails silently for invalid field value, set to true to return an error. */ - #[Api('strict_fields', optional: true)] - public ?bool $strictFields; + #[Api(optional: true)] + public ?bool $strict_fields; #[Api(optional: true)] public ?string $tag; @@ -253,33 +241,33 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param list $signers - * @param PdfPasswordType|value-of $pdfPasswordType - * @param array $pdftext - * @param array $signertext + * @param 1|2 $pdf_password_type + * @param array $pdftext + * @param array $signertext */ public static function with( string $group, string $name, array $signers, - ?bool $appendPdf = null, - ?bool $autoArchive = null, - ?string $ccEmails = null, - ?bool $convertSenderToSigner = null, - ?bool $doEmail = null, + ?bool $append_pdf = null, + ?bool $auto_archive = null, + ?string $cc_emails = null, + ?bool $convert_sender_to_signer = null, + ?bool $do_email = null, ?string $footer = null, - ?int $footerHeight = null, + ?int $footer_height = null, ?string $header = null, - ?int $headerHeight = null, - ?string $pdfPassword = null, - PdfPasswordType|int|null $pdfPasswordType = null, + ?int $header_height = null, + ?string $pdf_password = null, + ?int $pdf_password_type = null, ?array $pdftext = null, ?string $redirect = null, ?string $reminders = null, - ?bool $returnSignerLinks = null, - ?int $signatureType = null, - ?bool $signersInOrder = null, + ?bool $return_signer_links = null, + ?int $signature_type = null, + ?bool $signers_in_order = null, ?array $signertext = null, - ?bool $strictFields = null, + ?bool $strict_fields = null, ?string $tag = null, ?string $tag1 = null, ?string $tag2 = null, @@ -294,25 +282,25 @@ public static function with( $obj->name = $name; $obj->signers = $signers; - null !== $appendPdf && $obj->appendPdf = $appendPdf; - null !== $autoArchive && $obj->autoArchive = $autoArchive; - null !== $ccEmails && $obj->ccEmails = $ccEmails; - null !== $convertSenderToSigner && $obj->convertSenderToSigner = $convertSenderToSigner; - null !== $doEmail && $obj->doEmail = $doEmail; + null !== $append_pdf && $obj->append_pdf = $append_pdf; + null !== $auto_archive && $obj->auto_archive = $auto_archive; + null !== $cc_emails && $obj->cc_emails = $cc_emails; + null !== $convert_sender_to_signer && $obj->convert_sender_to_signer = $convert_sender_to_signer; + null !== $do_email && $obj->do_email = $do_email; null !== $footer && $obj->footer = $footer; - null !== $footerHeight && $obj->footerHeight = $footerHeight; + null !== $footer_height && $obj->footer_height = $footer_height; null !== $header && $obj->header = $header; - null !== $headerHeight && $obj->headerHeight = $headerHeight; - null !== $pdfPassword && $obj->pdfPassword = $pdfPassword; - null !== $pdfPasswordType && $obj->pdfPasswordType = $pdfPasswordType instanceof PdfPasswordType ? $pdfPasswordType->value : $pdfPasswordType; + null !== $header_height && $obj->header_height = $header_height; + null !== $pdf_password && $obj->pdf_password = $pdf_password; + null !== $pdf_password_type && $obj->pdf_password_type = $pdf_password_type; null !== $pdftext && $obj->pdftext = $pdftext; null !== $redirect && $obj->redirect = $redirect; null !== $reminders && $obj->reminders = $reminders; - null !== $returnSignerLinks && $obj->returnSignerLinks = $returnSignerLinks; - null !== $signatureType && $obj->signatureType = $signatureType; - null !== $signersInOrder && $obj->signersInOrder = $signersInOrder; + null !== $return_signer_links && $obj->return_signer_links = $return_signer_links; + null !== $signature_type && $obj->signature_type = $signature_type; + null !== $signers_in_order && $obj->signers_in_order = $signers_in_order; null !== $signertext && $obj->signertext = $signertext; - null !== $strictFields && $obj->strictFields = $strictFields; + null !== $strict_fields && $obj->strict_fields = $strict_fields; null !== $tag && $obj->tag = $tag; null !== $tag1 && $obj->tag1 = $tag1; null !== $tag2 && $obj->tag2 = $tag2; @@ -357,7 +345,7 @@ public function withSigners(array $signers): self public function withAppendPdf(bool $appendPdf): self { $obj = clone $this; - $obj->appendPdf = $appendPdf; + $obj->append_pdf = $appendPdf; return $obj; } @@ -368,7 +356,7 @@ public function withAppendPdf(bool $appendPdf): self public function withAutoArchive(bool $autoArchive): self { $obj = clone $this; - $obj->autoArchive = $autoArchive; + $obj->auto_archive = $autoArchive; return $obj; } @@ -379,7 +367,7 @@ public function withAutoArchive(bool $autoArchive): self public function withCcEmails(string $ccEmails): self { $obj = clone $this; - $obj->ccEmails = $ccEmails; + $obj->cc_emails = $ccEmails; return $obj; } @@ -390,7 +378,7 @@ public function withCcEmails(string $ccEmails): self public function withConvertSenderToSigner(bool $convertSenderToSigner): self { $obj = clone $this; - $obj->convertSenderToSigner = $convertSenderToSigner; + $obj->convert_sender_to_signer = $convertSenderToSigner; return $obj; } @@ -401,7 +389,7 @@ public function withConvertSenderToSigner(bool $convertSenderToSigner): self public function withDoEmail(bool $doEmail): self { $obj = clone $this; - $obj->doEmail = $doEmail; + $obj->do_email = $doEmail; return $obj; } @@ -423,7 +411,7 @@ public function withFooter(string $footer): self public function withFooterHeight(int $footerHeight): self { $obj = clone $this; - $obj->footerHeight = $footerHeight; + $obj->footer_height = $footerHeight; return $obj; } @@ -445,7 +433,7 @@ public function withHeader(string $header): self public function withHeaderHeight(int $headerHeight): self { $obj = clone $this; - $obj->headerHeight = $headerHeight; + $obj->header_height = $headerHeight; return $obj; } @@ -456,7 +444,7 @@ public function withHeaderHeight(int $headerHeight): self public function withPdfPassword(string $pdfPassword): self { $obj = clone $this; - $obj->pdfPassword = $pdfPassword; + $obj->pdf_password = $pdfPassword; return $obj; } @@ -464,13 +452,12 @@ public function withPdfPassword(string $pdfPassword): self /** * 1 to store password, 2 for to delete from our records upon final signing. * - * @param PdfPasswordType|value-of $pdfPasswordType + * @param 1|2 $pdfPasswordType */ - public function withPdfPasswordType( - PdfPasswordType|int $pdfPasswordType - ): self { + public function withPdfPasswordType(int $pdfPasswordType): self + { $obj = clone $this; - $obj->pdfPasswordType = $pdfPasswordType instanceof PdfPasswordType ? $pdfPasswordType->value : $pdfPasswordType; + $obj->pdf_password_type = $pdfPasswordType; return $obj; } @@ -478,7 +465,7 @@ public function withPdfPasswordType( /** * Assign values to PDF sender fields, use field labels as keys. Requires unique fields labels. See also strict_fields. * - * @param array $pdftext + * @param array $pdftext */ public function withPdftext(array $pdftext): self { @@ -516,7 +503,7 @@ public function withReminders(string $reminders): self public function withReturnSignerLinks(bool $returnSignerLinks): self { $obj = clone $this; - $obj->returnSignerLinks = $returnSignerLinks; + $obj->return_signer_links = $returnSignerLinks; return $obj; } @@ -527,7 +514,7 @@ public function withReturnSignerLinks(bool $returnSignerLinks): self public function withSignatureType(int $signatureType): self { $obj = clone $this; - $obj->signatureType = $signatureType; + $obj->signature_type = $signatureType; return $obj; } @@ -538,7 +525,7 @@ public function withSignatureType(int $signatureType): self public function withSignersInOrder(bool $signersInOrder): self { $obj = clone $this; - $obj->signersInOrder = $signersInOrder; + $obj->signers_in_order = $signersInOrder; return $obj; } @@ -546,7 +533,7 @@ public function withSignersInOrder(bool $signersInOrder): self /** * Add custom placeholders to signer fields, using labels as keys in an object (as for pdftext). Relies on unique labelling. * - * @param array $signertext + * @param array $signertext */ public function withSignertext(array $signertext): self { @@ -562,7 +549,7 @@ public function withSignertext(array $signertext): self public function withStrictFields(bool $strictFields): self { $obj = clone $this; - $obj->strictFields = $strictFields; + $obj->strict_fields = $strictFields; return $obj; } diff --git a/src/Document/DocumentCreateParams/PdfPasswordType.php b/src/Document/DocumentCreateParams/PdfPasswordType.php deleted file mode 100644 index c02c411..0000000 --- a/src/Document/DocumentCreateParams/PdfPasswordType.php +++ /dev/null @@ -1,15 +0,0 @@ -, - * behalfof?: string, - * decideLater?: bool, + * attachments?: list|null, + * behalfof?: string|null, + * decide_later?: bool|null, * expires?: \DateTimeInterface|null, - * message?: string, - * order?: int, - * reviewers?: list, - * role?: value-of, - * sms?: string, - * subject?: string, - * timezone?: string, + * message?: string|null, + * order?: int|null, + * reviewers?: list|null, + * role?: value-of|null, + * sms?: string|null, + * subject?: string|null, + * timezone?: string|null, * } */ final class Signer implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api] @@ -61,8 +61,8 @@ final class Signer implements BaseModel /** * Add this you want the previous signer or approver to decide who the next person should be. Commonly used for witnesses (see \"role\"). If you use this leave all other attributes blank. First signer cannot use this attribute. */ - #[Api('decide_later', optional: true)] - public ?bool $decideLater; + #[Api(optional: true)] + public ?bool $decide_later; /** * ISO8601 formed datetime, set to TZ of sender or timezone if used. @@ -150,7 +150,7 @@ public static function with( string $lastname, ?array $attachments = null, ?string $behalfof = null, - ?bool $decideLater = null, + ?bool $decide_later = null, ?\DateTimeInterface $expires = null, ?string $message = null, ?int $order = null, @@ -168,12 +168,12 @@ public static function with( null !== $attachments && $obj->attachments = $attachments; null !== $behalfof && $obj->behalfof = $behalfof; - null !== $decideLater && $obj->decideLater = $decideLater; + null !== $decide_later && $obj->decide_later = $decide_later; null !== $expires && $obj->expires = $expires; null !== $message && $obj->message = $message; null !== $order && $obj->order = $order; null !== $reviewers && $obj->reviewers = $reviewers; - null !== $role && $obj->role = $role instanceof Role ? $role->value : $role; + null !== $role && $obj['role'] = $role; null !== $sms && $obj->sms = $sms; null !== $subject && $obj->subject = $subject; null !== $timezone && $obj->timezone = $timezone; @@ -235,7 +235,7 @@ public function withBehalfof(string $behalfof): self public function withDecideLater(bool $decideLater): self { $obj = clone $this; - $obj->decideLater = $decideLater; + $obj->decide_later = $decideLater; return $obj; } @@ -292,7 +292,7 @@ public function withReviewers(array $reviewers): self public function withRole(Role|string $role): self { $obj = clone $this; - $obj->role = $role instanceof Role ? $role->value : $role; + $obj['role'] = $role; return $obj; } diff --git a/src/Document/DocumentCreateParams/Signer/Reviewer.php b/src/Document/DocumentCreateParams/Signer/Reviewer.php index 5724b2b..9764d91 100644 --- a/src/Document/DocumentCreateParams/Signer/Reviewer.php +++ b/src/Document/DocumentCreateParams/Signer/Reviewer.php @@ -11,13 +11,16 @@ /** * Create a reviewer. A reviewer is linked to a signer and receives emailed copies of draft and signed documents. N.B. they only receive them if their associated signer does. Therefore make sure your admin/experience settings are set to attach PDFs to your signer emails. You can set to include the signing link to a reviewer, and thereby hit the use case to send a document to a group of people where the first who signs, signs. * - * @phpstan-type reviewer_alias = array{ - * email: string, firstname?: string, includeLink?: bool, lastname?: string + * @phpstan-type ReviewerShape = array{ + * email: string, + * firstname?: string|null, + * include_link?: bool|null, + * lastname?: string|null, * } */ final class Reviewer implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api] @@ -29,8 +32,8 @@ final class Reviewer implements BaseModel /** * include a link to the signing pages enabling a reviewer to signer. */ - #[Api('include_link', optional: true)] - public ?bool $includeLink; + #[Api(optional: true)] + public ?bool $include_link; #[Api(optional: true)] public ?string $lastname; @@ -62,7 +65,7 @@ public function __construct() public static function with( string $email, ?string $firstname = null, - ?bool $includeLink = null, + ?bool $include_link = null, ?string $lastname = null, ): self { $obj = new self; @@ -70,7 +73,7 @@ public static function with( $obj->email = $email; null !== $firstname && $obj->firstname = $firstname; - null !== $includeLink && $obj->includeLink = $includeLink; + null !== $include_link && $obj->include_link = $include_link; null !== $lastname && $obj->lastname = $lastname; return $obj; @@ -98,7 +101,7 @@ public function withFirstname(string $firstname): self public function withIncludeLink(bool $includeLink): self { $obj = clone $this; - $obj->includeLink = $includeLink; + $obj->include_link = $includeLink; return $obj; } diff --git a/src/Document/DocumentGetFieldsResponseItem.php b/src/Document/DocumentGetFieldsResponseItem.php index 03d65c4..e143296 100644 --- a/src/Document/DocumentGetFieldsResponseItem.php +++ b/src/Document/DocumentGetFieldsResponseItem.php @@ -10,25 +10,25 @@ use LegalesignSDK\Document\DocumentGetFieldsResponseItem\ElementType; /** - * @phpstan-type document_get_fields_response_item = array{ - * elementType?: value-of, + * @phpstan-type DocumentGetFieldsResponseItemShape = array{ + * element_type?: value-of|null, * fieldorder?: int|null, - * label?: string, - * labelExtra?: string|null, - * signer?: int, - * state?: bool, - * validation?: value-of|null, - * value?: string, + * label?: string|null, + * label_extra?: string|null, + * signer?: int|null, + * state?: bool|null, + * validation?: null|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92, + * value?: string|null, * } */ final class DocumentGetFieldsResponseItem implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; - /** @var value-of|null $elementType */ - #[Api('element_type', enum: ElementType::class, optional: true)] - public ?string $elementType; + /** @var value-of|null $element_type */ + #[Api(enum: ElementType::class, optional: true)] + public ?string $element_type; #[Api(nullable: true, optional: true)] public ?int $fieldorder; @@ -36,8 +36,8 @@ final class DocumentGetFieldsResponseItem implements BaseModel #[Api(optional: true)] public ?string $label; - #[Api('label_extra', nullable: true, optional: true)] - public ?string $labelExtra; + #[Api(nullable: true, optional: true)] + public ?string $label_extra; #[Api(optional: true)] public ?int $signer; @@ -132,7 +132,7 @@ final class DocumentGetFieldsResponseItem implements BaseModel * * 91 - countries list * * 92 - honorifics list * - * @var value-of|null $validation + * @var 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ #[Api(enum: PdfFieldValidationEnum::class, nullable: true, optional: true)] public ?int $validation; @@ -150,28 +150,28 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ElementType|value-of $elementType - * @param PdfFieldValidationEnum|value-of|null $validation + * @param ElementType|value-of $element_type + * @param 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ public static function with( - ElementType|string|null $elementType = null, + ElementType|string|null $element_type = null, ?int $fieldorder = null, ?string $label = null, - ?string $labelExtra = null, + ?string $label_extra = null, ?int $signer = null, ?bool $state = null, - PdfFieldValidationEnum|int|null $validation = null, + ?int $validation = null, ?string $value = null, ): self { $obj = new self; - null !== $elementType && $obj->elementType = $elementType instanceof ElementType ? $elementType->value : $elementType; + null !== $element_type && $obj['element_type'] = $element_type; null !== $fieldorder && $obj->fieldorder = $fieldorder; null !== $label && $obj->label = $label; - null !== $labelExtra && $obj->labelExtra = $labelExtra; + null !== $label_extra && $obj->label_extra = $label_extra; null !== $signer && $obj->signer = $signer; null !== $state && $obj->state = $state; - null !== $validation && $obj->validation = $validation instanceof PdfFieldValidationEnum ? $validation->value : $validation; + null !== $validation && $obj->validation = $validation; null !== $value && $obj->value = $value; return $obj; @@ -183,7 +183,7 @@ public static function with( public function withElementType(ElementType|string $elementType): self { $obj = clone $this; - $obj->elementType = $elementType instanceof ElementType ? $elementType->value : $elementType; + $obj['element_type'] = $elementType; return $obj; } @@ -207,7 +207,7 @@ public function withLabel(string $label): self public function withLabelExtra(?string $labelExtra): self { $obj = clone $this; - $obj->labelExtra = $labelExtra; + $obj->label_extra = $labelExtra; return $obj; } @@ -315,13 +315,12 @@ public function withState(bool $state): self * * 91 - countries list * * 92 - honorifics list * - * @param PdfFieldValidationEnum|value-of|null $validation + * @param 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ - public function withValidation( - PdfFieldValidationEnum|int|null $validation - ): self { + public function withValidation(?int $validation): self + { $obj = clone $this; - $obj->validation = $validation instanceof PdfFieldValidationEnum ? $validation->value : $validation; + $obj->validation = $validation; return $obj; } diff --git a/src/Document/DocumentGetResponse.php b/src/Document/DocumentGetResponse.php index 14b342f..cb2dd23 100644 --- a/src/Document/DocumentGetResponse.php +++ b/src/Document/DocumentGetResponse.php @@ -6,86 +6,86 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; use LegalesignSDK\Core\Conversion\ListOf; /** - * @phpstan-type document_get_response = array{ - * archived?: bool, - * autoArchive?: bool, - * ccEmails?: string, - * created?: \DateTimeInterface, - * doEmail?: bool, - * downloadFinal?: bool, - * footer?: string, - * footerHeight?: int, - * group?: string, - * hasFields?: bool, - * hashValue?: string, - * header?: string, - * headerHeight?: int, - * modified?: \DateTimeInterface, - * name?: string, - * pdfPassword?: string, - * pdfPasswordType?: string, - * pdftext?: string, - * redirect?: string, - * resourceUri?: string, - * returnSignerLinks?: bool, - * signMouse?: bool, - * signTime?: \DateTimeInterface, - * signType?: bool, - * signUpload?: bool, - * signaturePlacement?: int, - * signatureType?: int, - * signers?: list>, - * signersInOrder?: bool, - * status?: value-of, - * tag?: string, - * tag1?: string, - * tag2?: string, - * template?: string, - * templatepdf?: string, - * text?: string, - * user?: string, - * uuid?: string, + * @phpstan-type DocumentGetResponseShape = array{ + * archived?: bool|null, + * auto_archive?: bool|null, + * cc_emails?: string|null, + * created?: \DateTimeInterface|null, + * do_email?: bool|null, + * download_final?: bool|null, + * footer?: string|null, + * footer_height?: int|null, + * group?: string|null, + * has_fields?: bool|null, + * hash_value?: string|null, + * header?: string|null, + * header_height?: int|null, + * modified?: \DateTimeInterface|null, + * name?: string|null, + * pdf_password?: string|null, + * pdf_password_type?: string|null, + * pdftext?: string|null, + * redirect?: string|null, + * resource_uri?: string|null, + * return_signer_links?: bool|null, + * sign_mouse?: bool|null, + * sign_time?: \DateTimeInterface|null, + * sign_type?: bool|null, + * sign_upload?: bool|null, + * signature_placement?: int|null, + * signature_type?: int|null, + * signers?: list>|null, + * signers_in_order?: bool|null, + * status?: null|10|20|30|40|50, + * tag?: string|null, + * tag1?: string|null, + * tag2?: string|null, + * template?: string|null, + * templatepdf?: string|null, + * text?: string|null, + * user?: string|null, + * uuid?: string|null, * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class DocumentGetResponse implements BaseModel +final class DocumentGetResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?bool $archived; /** * Send document archive very soon after signing. */ - #[Api('auto_archive', optional: true)] - public ?bool $autoArchive; + #[Api(optional: true)] + public ?bool $auto_archive; /** * who will be cc'd with sender on email notification when signed. */ - #[Api('cc_emails', optional: true)] - public ?string $ccEmails; + #[Api(optional: true)] + public ?string $cc_emails; #[Api(optional: true)] public ?\DateTimeInterface $created; - #[Api('do_email', optional: true)] - public ?bool $doEmail; + #[Api(optional: true)] + public ?bool $do_email; /** * Final PDF is available to download. */ - #[Api('download_final', optional: true)] - public ?bool $downloadFinal; + #[Api(optional: true)] + public ?bool $download_final; /** * HTML docs - text for footer if used. @@ -96,8 +96,8 @@ final class DocumentGetResponse implements BaseModel /** * HTMl docs - px height of footer if used. */ - #[Api('footer_height', optional: true)] - public ?int $footerHeight; + #[Api(optional: true)] + public ?int $footer_height; /** * Resource URI of group. @@ -105,14 +105,14 @@ final class DocumentGetResponse implements BaseModel #[Api(optional: true)] public ?string $group; - #[Api('has_fields', optional: true)] - public ?bool $hasFields; + #[Api(optional: true)] + public ?bool $has_fields; /** * SHA256 checksum of final doc, use this to validate your final PDF download. */ - #[Api('hash_value', optional: true)] - public ?string $hashValue; + #[Api(optional: true)] + public ?string $hash_value; /** * HTML docs - text for header if used. @@ -123,8 +123,8 @@ final class DocumentGetResponse implements BaseModel /** * HTMl docs - px height of header if used. */ - #[Api('header_height', optional: true)] - public ?int $headerHeight; + #[Api(optional: true)] + public ?int $header_height; #[Api(optional: true)] public ?\DateTimeInterface $modified; @@ -135,14 +135,14 @@ final class DocumentGetResponse implements BaseModel /** * PDF password if used and if save-able. */ - #[Api('pdf_password', optional: true)] - public ?string $pdfPassword; + #[Api(optional: true)] + public ?string $pdf_password; /** * how pdf password is retained. */ - #[Api('pdf_password_type', optional: true)] - public ?string $pdfPasswordType; + #[Api(optional: true)] + public ?string $pdf_password_type; /** * ignore this. @@ -156,47 +156,47 @@ final class DocumentGetResponse implements BaseModel #[Api(optional: true)] public ?string $redirect; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; /** * ignore. */ - #[Api('return_signer_links', optional: true)] - public ?bool $returnSignerLinks; + #[Api(optional: true)] + public ?bool $return_signer_links; /** * legacy. */ - #[Api('sign_mouse', optional: true)] - public ?bool $signMouse; + #[Api(optional: true)] + public ?bool $sign_mouse; - #[Api('sign_time', optional: true)] - public ?\DateTimeInterface $signTime; + #[Api(optional: true)] + public ?\DateTimeInterface $sign_time; /** * legacy. */ - #[Api('sign_type', optional: true)] - public ?bool $signType; + #[Api(optional: true)] + public ?bool $sign_type; /** * legacy. */ - #[Api('sign_upload', optional: true)] - public ?bool $signUpload; + #[Api(optional: true)] + public ?bool $sign_upload; /** * legacy. */ - #[Api('signature_placement', optional: true)] - public ?int $signaturePlacement; + #[Api(optional: true)] + public ?int $signature_placement; /** * legacy - always 4. */ - #[Api('signature_type', optional: true)] - public ?int $signatureType; + #[Api(optional: true)] + public ?int $signature_type; /** * nested arrays with signer details. @@ -206,8 +206,8 @@ final class DocumentGetResponse implements BaseModel #[Api(list: new ListOf('string'), optional: true)] public ?array $signers; - #[Api('signers_in_order', optional: true)] - public ?bool $signersInOrder; + #[Api(optional: true)] + public ?bool $signers_in_order; /** * Document status options: @@ -217,7 +217,7 @@ final class DocumentGetResponse implements BaseModel * * 40 - Removed (before signing) * * 50 - Rejected * - * @var value-of|null $status + * @var 10|20|30|40|50|null $status */ #[Api(enum: DocumentStatusEnum::class, optional: true)] public ?int $status; @@ -272,39 +272,39 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param list> $signers - * @param DocumentStatusEnum|value-of $status + * @param 10|20|30|40|50 $status */ public static function with( ?bool $archived = null, - ?bool $autoArchive = null, - ?string $ccEmails = null, + ?bool $auto_archive = null, + ?string $cc_emails = null, ?\DateTimeInterface $created = null, - ?bool $doEmail = null, - ?bool $downloadFinal = null, + ?bool $do_email = null, + ?bool $download_final = null, ?string $footer = null, - ?int $footerHeight = null, + ?int $footer_height = null, ?string $group = null, - ?bool $hasFields = null, - ?string $hashValue = null, + ?bool $has_fields = null, + ?string $hash_value = null, ?string $header = null, - ?int $headerHeight = null, + ?int $header_height = null, ?\DateTimeInterface $modified = null, ?string $name = null, - ?string $pdfPassword = null, - ?string $pdfPasswordType = null, + ?string $pdf_password = null, + ?string $pdf_password_type = null, ?string $pdftext = null, ?string $redirect = null, - ?string $resourceUri = null, - ?bool $returnSignerLinks = null, - ?bool $signMouse = null, - ?\DateTimeInterface $signTime = null, - ?bool $signType = null, - ?bool $signUpload = null, - ?int $signaturePlacement = null, - ?int $signatureType = null, + ?string $resource_uri = null, + ?bool $return_signer_links = null, + ?bool $sign_mouse = null, + ?\DateTimeInterface $sign_time = null, + ?bool $sign_type = null, + ?bool $sign_upload = null, + ?int $signature_placement = null, + ?int $signature_type = null, ?array $signers = null, - ?bool $signersInOrder = null, - DocumentStatusEnum|int|null $status = null, + ?bool $signers_in_order = null, + ?int $status = null, ?string $tag = null, ?string $tag1 = null, ?string $tag2 = null, @@ -317,35 +317,35 @@ public static function with( $obj = new self; null !== $archived && $obj->archived = $archived; - null !== $autoArchive && $obj->autoArchive = $autoArchive; - null !== $ccEmails && $obj->ccEmails = $ccEmails; + null !== $auto_archive && $obj->auto_archive = $auto_archive; + null !== $cc_emails && $obj->cc_emails = $cc_emails; null !== $created && $obj->created = $created; - null !== $doEmail && $obj->doEmail = $doEmail; - null !== $downloadFinal && $obj->downloadFinal = $downloadFinal; + null !== $do_email && $obj->do_email = $do_email; + null !== $download_final && $obj->download_final = $download_final; null !== $footer && $obj->footer = $footer; - null !== $footerHeight && $obj->footerHeight = $footerHeight; + null !== $footer_height && $obj->footer_height = $footer_height; null !== $group && $obj->group = $group; - null !== $hasFields && $obj->hasFields = $hasFields; - null !== $hashValue && $obj->hashValue = $hashValue; + null !== $has_fields && $obj->has_fields = $has_fields; + null !== $hash_value && $obj->hash_value = $hash_value; null !== $header && $obj->header = $header; - null !== $headerHeight && $obj->headerHeight = $headerHeight; + null !== $header_height && $obj->header_height = $header_height; null !== $modified && $obj->modified = $modified; null !== $name && $obj->name = $name; - null !== $pdfPassword && $obj->pdfPassword = $pdfPassword; - null !== $pdfPasswordType && $obj->pdfPasswordType = $pdfPasswordType; + null !== $pdf_password && $obj->pdf_password = $pdf_password; + null !== $pdf_password_type && $obj->pdf_password_type = $pdf_password_type; null !== $pdftext && $obj->pdftext = $pdftext; null !== $redirect && $obj->redirect = $redirect; - null !== $resourceUri && $obj->resourceUri = $resourceUri; - null !== $returnSignerLinks && $obj->returnSignerLinks = $returnSignerLinks; - null !== $signMouse && $obj->signMouse = $signMouse; - null !== $signTime && $obj->signTime = $signTime; - null !== $signType && $obj->signType = $signType; - null !== $signUpload && $obj->signUpload = $signUpload; - null !== $signaturePlacement && $obj->signaturePlacement = $signaturePlacement; - null !== $signatureType && $obj->signatureType = $signatureType; + null !== $resource_uri && $obj->resource_uri = $resource_uri; + null !== $return_signer_links && $obj->return_signer_links = $return_signer_links; + null !== $sign_mouse && $obj->sign_mouse = $sign_mouse; + null !== $sign_time && $obj->sign_time = $sign_time; + null !== $sign_type && $obj->sign_type = $sign_type; + null !== $sign_upload && $obj->sign_upload = $sign_upload; + null !== $signature_placement && $obj->signature_placement = $signature_placement; + null !== $signature_type && $obj->signature_type = $signature_type; null !== $signers && $obj->signers = $signers; - null !== $signersInOrder && $obj->signersInOrder = $signersInOrder; - null !== $status && $obj->status = $status instanceof DocumentStatusEnum ? $status->value : $status; + null !== $signers_in_order && $obj->signers_in_order = $signers_in_order; + null !== $status && $obj->status = $status; null !== $tag && $obj->tag = $tag; null !== $tag1 && $obj->tag1 = $tag1; null !== $tag2 && $obj->tag2 = $tag2; @@ -372,7 +372,7 @@ public function withArchived(bool $archived): self public function withAutoArchive(bool $autoArchive): self { $obj = clone $this; - $obj->autoArchive = $autoArchive; + $obj->auto_archive = $autoArchive; return $obj; } @@ -383,7 +383,7 @@ public function withAutoArchive(bool $autoArchive): self public function withCcEmails(string $ccEmails): self { $obj = clone $this; - $obj->ccEmails = $ccEmails; + $obj->cc_emails = $ccEmails; return $obj; } @@ -399,7 +399,7 @@ public function withCreated(\DateTimeInterface $created): self public function withDoEmail(bool $doEmail): self { $obj = clone $this; - $obj->doEmail = $doEmail; + $obj->do_email = $doEmail; return $obj; } @@ -410,7 +410,7 @@ public function withDoEmail(bool $doEmail): self public function withDownloadFinal(bool $downloadFinal): self { $obj = clone $this; - $obj->downloadFinal = $downloadFinal; + $obj->download_final = $downloadFinal; return $obj; } @@ -432,7 +432,7 @@ public function withFooter(string $footer): self public function withFooterHeight(int $footerHeight): self { $obj = clone $this; - $obj->footerHeight = $footerHeight; + $obj->footer_height = $footerHeight; return $obj; } @@ -451,7 +451,7 @@ public function withGroup(string $group): self public function withHasFields(bool $hasFields): self { $obj = clone $this; - $obj->hasFields = $hasFields; + $obj->has_fields = $hasFields; return $obj; } @@ -462,7 +462,7 @@ public function withHasFields(bool $hasFields): self public function withHashValue(string $hashValue): self { $obj = clone $this; - $obj->hashValue = $hashValue; + $obj->hash_value = $hashValue; return $obj; } @@ -484,7 +484,7 @@ public function withHeader(string $header): self public function withHeaderHeight(int $headerHeight): self { $obj = clone $this; - $obj->headerHeight = $headerHeight; + $obj->header_height = $headerHeight; return $obj; } @@ -511,7 +511,7 @@ public function withName(string $name): self public function withPdfPassword(string $pdfPassword): self { $obj = clone $this; - $obj->pdfPassword = $pdfPassword; + $obj->pdf_password = $pdfPassword; return $obj; } @@ -522,7 +522,7 @@ public function withPdfPassword(string $pdfPassword): self public function withPdfPasswordType(string $pdfPasswordType): self { $obj = clone $this; - $obj->pdfPasswordType = $pdfPasswordType; + $obj->pdf_password_type = $pdfPasswordType; return $obj; } @@ -552,7 +552,7 @@ public function withRedirect(string $redirect): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -563,7 +563,7 @@ public function withResourceUri(string $resourceUri): self public function withReturnSignerLinks(bool $returnSignerLinks): self { $obj = clone $this; - $obj->returnSignerLinks = $returnSignerLinks; + $obj->return_signer_links = $returnSignerLinks; return $obj; } @@ -574,7 +574,7 @@ public function withReturnSignerLinks(bool $returnSignerLinks): self public function withSignMouse(bool $signMouse): self { $obj = clone $this; - $obj->signMouse = $signMouse; + $obj->sign_mouse = $signMouse; return $obj; } @@ -582,7 +582,7 @@ public function withSignMouse(bool $signMouse): self public function withSignTime(\DateTimeInterface $signTime): self { $obj = clone $this; - $obj->signTime = $signTime; + $obj->sign_time = $signTime; return $obj; } @@ -593,7 +593,7 @@ public function withSignTime(\DateTimeInterface $signTime): self public function withSignType(bool $signType): self { $obj = clone $this; - $obj->signType = $signType; + $obj->sign_type = $signType; return $obj; } @@ -604,7 +604,7 @@ public function withSignType(bool $signType): self public function withSignUpload(bool $signUpload): self { $obj = clone $this; - $obj->signUpload = $signUpload; + $obj->sign_upload = $signUpload; return $obj; } @@ -615,7 +615,7 @@ public function withSignUpload(bool $signUpload): self public function withSignaturePlacement(int $signaturePlacement): self { $obj = clone $this; - $obj->signaturePlacement = $signaturePlacement; + $obj->signature_placement = $signaturePlacement; return $obj; } @@ -626,7 +626,7 @@ public function withSignaturePlacement(int $signaturePlacement): self public function withSignatureType(int $signatureType): self { $obj = clone $this; - $obj->signatureType = $signatureType; + $obj->signature_type = $signatureType; return $obj; } @@ -647,7 +647,7 @@ public function withSigners(array $signers): self public function withSignersInOrder(bool $signersInOrder): self { $obj = clone $this; - $obj->signersInOrder = $signersInOrder; + $obj->signers_in_order = $signersInOrder; return $obj; } @@ -660,12 +660,12 @@ public function withSignersInOrder(bool $signersInOrder): self * * 40 - Removed (before signing) * * 50 - Rejected * - * @param DocumentStatusEnum|value-of $status + * @param 10|20|30|40|50 $status */ - public function withStatus(DocumentStatusEnum|int $status): self + public function withStatus(int $status): self { $obj = clone $this; - $obj->status = $status instanceof DocumentStatusEnum ? $status->value : $status; + $obj->status = $status; return $obj; } diff --git a/src/Document/DocumentListParams.php b/src/Document/DocumentListParams.php index c19d621..b3206aa 100644 --- a/src/Document/DocumentListParams.php +++ b/src/Document/DocumentListParams.php @@ -10,28 +10,17 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new DocumentListParams); // set properties as needed - * $client->document->list(...$params->toArray()); - * ``` * List (unarchived) signing documents. Use /status/ if you need high-level information. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\DocumentService::list() * - * `$client->document->list(...$params->toArray());` - * - * @see LegalesignSDK\Document->list - * - * @phpstan-type document_list_params = array{ + * @phpstan-type DocumentListParamsShape = array{ * group: string, * archived?: string, - * createdGt?: \DateTimeInterface, + * created_gt?: \DateTimeInterface, * email?: string, * limit?: int, - * modifiedGt?: \DateTimeInterface, + * modified_gt?: \DateTimeInterface, * nosigners?: string, * offset?: int, * status?: int, @@ -39,7 +28,7 @@ */ final class DocumentListParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -59,7 +48,7 @@ final class DocumentListParams implements BaseModel * Filter for those documents created after a certain time. */ #[Api(optional: true)] - public ?\DateTimeInterface $createdGt; + public ?\DateTimeInterface $created_gt; /** * Filter by signer email. @@ -77,7 +66,7 @@ final class DocumentListParams implements BaseModel * Filter for those documents modified after a certain time. */ #[Api(optional: true)] - public ?\DateTimeInterface $modifiedGt; + public ?\DateTimeInterface $modified_gt; /** * Add value '1' to remove signers information for a faster query. @@ -124,10 +113,10 @@ public function __construct() public static function with( string $group, ?string $archived = null, - ?\DateTimeInterface $createdGt = null, + ?\DateTimeInterface $created_gt = null, ?string $email = null, ?int $limit = null, - ?\DateTimeInterface $modifiedGt = null, + ?\DateTimeInterface $modified_gt = null, ?string $nosigners = null, ?int $offset = null, ?int $status = null, @@ -137,10 +126,10 @@ public static function with( $obj->group = $group; null !== $archived && $obj->archived = $archived; - null !== $createdGt && $obj->createdGt = $createdGt; + null !== $created_gt && $obj->created_gt = $created_gt; null !== $email && $obj->email = $email; null !== $limit && $obj->limit = $limit; - null !== $modifiedGt && $obj->modifiedGt = $modifiedGt; + null !== $modified_gt && $obj->modified_gt = $modified_gt; null !== $nosigners && $obj->nosigners = $nosigners; null !== $offset && $obj->offset = $offset; null !== $status && $obj->status = $status; @@ -176,7 +165,7 @@ public function withArchived(string $archived): self public function withCreatedGt(\DateTimeInterface $createdGt): self { $obj = clone $this; - $obj->createdGt = $createdGt; + $obj->created_gt = $createdGt; return $obj; } @@ -209,7 +198,7 @@ public function withLimit(int $limit): self public function withModifiedGt(\DateTimeInterface $modifiedGt): self { $obj = clone $this; - $obj->modifiedGt = $modifiedGt; + $obj->modified_gt = $modifiedGt; return $obj; } diff --git a/src/Document/DocumentListResponse.php b/src/Document/DocumentListResponse.php index 455c4da..840f30f 100644 --- a/src/Document/DocumentListResponse.php +++ b/src/Document/DocumentListResponse.php @@ -6,23 +6,23 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; use LegalesignSDK\Document\DocumentListResponse\Object1; /** - * @phpstan-type document_list_response = array{ - * meta?: ListMeta, objects?: list + * @phpstan-type DocumentListResponseShape = array{ + * meta?: ListMeta|null, objects?: list|null * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class DocumentListResponse implements BaseModel +final class DocumentListResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?ListMeta $meta; diff --git a/src/Document/DocumentListResponse/Object1.php b/src/Document/DocumentListResponse/Object1.php index 9e5be77..6505add 100644 --- a/src/Document/DocumentListResponse/Object1.php +++ b/src/Document/DocumentListResponse/Object1.php @@ -8,59 +8,58 @@ use LegalesignSDK\Core\Concerns\SdkModel; use LegalesignSDK\Core\Contracts\BaseModel; use LegalesignSDK\Core\Conversion\ListOf; -use LegalesignSDK\Document\DocumentListResponse\Object1\SignersInOrder; use LegalesignSDK\Document\DocumentStatusEnum; /** - * @phpstan-type object1_alias = array{ - * archived?: bool, - * autoArchive?: bool, - * ccEmails?: string, - * created?: \DateTimeInterface, - * doEmail?: bool, - * downloadFinal?: bool, - * group?: string, - * modified?: \DateTimeInterface, - * name?: string, - * pdftext?: string, - * redirect?: string, - * resourceUri?: string, - * returnSignerLinks?: bool, - * signers?: list>, - * signersInOrder?: value-of, - * status?: value-of, - * tag?: string, - * tag1?: string, - * tag2?: string, + * @phpstan-type Object1Shape = array{ + * archived?: bool|null, + * auto_archive?: bool|null, + * cc_emails?: string|null, + * created?: \DateTimeInterface|null, + * do_email?: bool|null, + * download_final?: bool|null, + * group?: string|null, + * modified?: \DateTimeInterface|null, + * name?: string|null, + * pdftext?: string|null, + * redirect?: string|null, + * resource_uri?: string|null, + * return_signer_links?: bool|null, + * signers?: list>|null, + * signers_in_order?: null|0|1, + * status?: null|10|20|30|40|50, + * tag?: string|null, + * tag1?: string|null, + * tag2?: string|null, * template?: string|null, * templatepdf?: string|null, * text?: string|null, - * user?: string, - * uuid?: string, + * user?: string|null, + * uuid?: string|null, * } */ final class Object1 implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(optional: true)] public ?bool $archived; - #[Api('auto_archive', optional: true)] - public ?bool $autoArchive; + #[Api(optional: true)] + public ?bool $auto_archive; - #[Api('cc_emails', optional: true)] - public ?string $ccEmails; + #[Api(optional: true)] + public ?string $cc_emails; #[Api(optional: true)] public ?\DateTimeInterface $created; - #[Api('do_email', optional: true)] - public ?bool $doEmail; + #[Api(optional: true)] + public ?bool $do_email; - #[Api('download_final', optional: true)] - public ?bool $downloadFinal; + #[Api(optional: true)] + public ?bool $download_final; #[Api(optional: true)] public ?string $group; @@ -77,11 +76,11 @@ final class Object1 implements BaseModel #[Api(optional: true)] public ?string $redirect; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; - #[Api('return_signer_links', optional: true)] - public ?bool $returnSignerLinks; + #[Api(optional: true)] + public ?bool $return_signer_links; /** * nested arrays with signer details. @@ -91,9 +90,9 @@ final class Object1 implements BaseModel #[Api(list: new ListOf('string'), optional: true)] public ?array $signers; - /** @var value-of|null $signersInOrder */ - #[Api('signers_in_order', enum: SignersInOrder::class, optional: true)] - public ?int $signersInOrder; + /** @var 0|1|null $signers_in_order */ + #[Api(optional: true)] + public ?int $signers_in_order; /** * Document status options: @@ -103,7 +102,7 @@ final class Object1 implements BaseModel * * 40 - Removed (before signing) * * 50 - Rejected * - * @var value-of|null $status + * @var 10|20|30|40|50|null $status */ #[Api(enum: DocumentStatusEnum::class, optional: true)] public ?int $status; @@ -143,26 +142,26 @@ public function __construct() * You must use named parameters to construct any parameters with a default value. * * @param list> $signers - * @param SignersInOrder|value-of $signersInOrder - * @param DocumentStatusEnum|value-of $status + * @param 0|1 $signers_in_order + * @param 10|20|30|40|50 $status */ public static function with( ?bool $archived = null, - ?bool $autoArchive = null, - ?string $ccEmails = null, + ?bool $auto_archive = null, + ?string $cc_emails = null, ?\DateTimeInterface $created = null, - ?bool $doEmail = null, - ?bool $downloadFinal = null, + ?bool $do_email = null, + ?bool $download_final = null, ?string $group = null, ?\DateTimeInterface $modified = null, ?string $name = null, ?string $pdftext = null, ?string $redirect = null, - ?string $resourceUri = null, - ?bool $returnSignerLinks = null, + ?string $resource_uri = null, + ?bool $return_signer_links = null, ?array $signers = null, - SignersInOrder|int|null $signersInOrder = null, - DocumentStatusEnum|int|null $status = null, + ?int $signers_in_order = null, + ?int $status = null, ?string $tag = null, ?string $tag1 = null, ?string $tag2 = null, @@ -175,21 +174,21 @@ public static function with( $obj = new self; null !== $archived && $obj->archived = $archived; - null !== $autoArchive && $obj->autoArchive = $autoArchive; - null !== $ccEmails && $obj->ccEmails = $ccEmails; + null !== $auto_archive && $obj->auto_archive = $auto_archive; + null !== $cc_emails && $obj->cc_emails = $cc_emails; null !== $created && $obj->created = $created; - null !== $doEmail && $obj->doEmail = $doEmail; - null !== $downloadFinal && $obj->downloadFinal = $downloadFinal; + null !== $do_email && $obj->do_email = $do_email; + null !== $download_final && $obj->download_final = $download_final; null !== $group && $obj->group = $group; null !== $modified && $obj->modified = $modified; null !== $name && $obj->name = $name; null !== $pdftext && $obj->pdftext = $pdftext; null !== $redirect && $obj->redirect = $redirect; - null !== $resourceUri && $obj->resourceUri = $resourceUri; - null !== $returnSignerLinks && $obj->returnSignerLinks = $returnSignerLinks; + null !== $resource_uri && $obj->resource_uri = $resource_uri; + null !== $return_signer_links && $obj->return_signer_links = $return_signer_links; null !== $signers && $obj->signers = $signers; - null !== $signersInOrder && $obj->signersInOrder = $signersInOrder instanceof SignersInOrder ? $signersInOrder->value : $signersInOrder; - null !== $status && $obj->status = $status instanceof DocumentStatusEnum ? $status->value : $status; + null !== $signers_in_order && $obj->signers_in_order = $signers_in_order; + null !== $status && $obj->status = $status; null !== $tag && $obj->tag = $tag; null !== $tag1 && $obj->tag1 = $tag1; null !== $tag2 && $obj->tag2 = $tag2; @@ -213,7 +212,7 @@ public function withArchived(bool $archived): self public function withAutoArchive(bool $autoArchive): self { $obj = clone $this; - $obj->autoArchive = $autoArchive; + $obj->auto_archive = $autoArchive; return $obj; } @@ -221,7 +220,7 @@ public function withAutoArchive(bool $autoArchive): self public function withCcEmails(string $ccEmails): self { $obj = clone $this; - $obj->ccEmails = $ccEmails; + $obj->cc_emails = $ccEmails; return $obj; } @@ -237,7 +236,7 @@ public function withCreated(\DateTimeInterface $created): self public function withDoEmail(bool $doEmail): self { $obj = clone $this; - $obj->doEmail = $doEmail; + $obj->do_email = $doEmail; return $obj; } @@ -245,7 +244,7 @@ public function withDoEmail(bool $doEmail): self public function withDownloadFinal(bool $downloadFinal): self { $obj = clone $this; - $obj->downloadFinal = $downloadFinal; + $obj->download_final = $downloadFinal; return $obj; } @@ -293,7 +292,7 @@ public function withRedirect(string $redirect): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -301,7 +300,7 @@ public function withResourceUri(string $resourceUri): self public function withReturnSignerLinks(bool $returnSignerLinks): self { $obj = clone $this; - $obj->returnSignerLinks = $returnSignerLinks; + $obj->return_signer_links = $returnSignerLinks; return $obj; } @@ -320,12 +319,12 @@ public function withSigners(array $signers): self } /** - * @param SignersInOrder|value-of $signersInOrder + * @param 0|1 $signersInOrder */ - public function withSignersInOrder(SignersInOrder|int $signersInOrder): self + public function withSignersInOrder(int $signersInOrder): self { $obj = clone $this; - $obj->signersInOrder = $signersInOrder instanceof SignersInOrder ? $signersInOrder->value : $signersInOrder; + $obj->signers_in_order = $signersInOrder; return $obj; } @@ -338,12 +337,12 @@ public function withSignersInOrder(SignersInOrder|int $signersInOrder): self * * 40 - Removed (before signing) * * 50 - Rejected * - * @param DocumentStatusEnum|value-of $status + * @param 10|20|30|40|50 $status */ - public function withStatus(DocumentStatusEnum|int $status): self + public function withStatus(int $status): self { $obj = clone $this; - $obj->status = $status instanceof DocumentStatusEnum ? $status->value : $status; + $obj->status = $status; return $obj; } diff --git a/src/Document/DocumentListResponse/Object1/SignersInOrder.php b/src/Document/DocumentListResponse/Object1/SignersInOrder.php deleted file mode 100644 index 0428ede..0000000 --- a/src/Document/DocumentListResponse/Object1/SignersInOrder.php +++ /dev/null @@ -1,12 +0,0 @@ - */ + /** @use SdkModel */ use SdkModel; - #[Api('signer_1', optional: true)] - public ?string $signer1; + use SdkResponse; + + #[Api(optional: true)] + public ?string $signer_1; public function __construct() { @@ -33,11 +33,11 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(?string $signer1 = null): self + public static function with(?string $signer_1 = null): self { $obj = new self; - null !== $signer1 && $obj->signer1 = $signer1; + null !== $signer_1 && $obj->signer_1 = $signer_1; return $obj; } @@ -45,7 +45,7 @@ public static function with(?string $signer1 = null): self public function withSigner1(string $signer1): self { $obj = clone $this; - $obj->signer1 = $signer1; + $obj->signer_1 = $signer1; return $obj; } diff --git a/src/Document/DocumentStatusEnum.php b/src/Document/DocumentStatusEnum.php index f184372..61871fe 100644 --- a/src/Document/DocumentStatusEnum.php +++ b/src/Document/DocumentStatusEnum.php @@ -14,13 +14,13 @@ */ enum DocumentStatusEnum: int { - case DOCUMENT_STATUS_ENUM_10 = 10; + case _10 = 10; - case DOCUMENT_STATUS_ENUM_20 = 20; + case _20 = 20; - case DOCUMENT_STATUS_ENUM_30 = 30; + case _30 = 30; - case DOCUMENT_STATUS_ENUM_40 = 40; + case _40 = 40; - case DOCUMENT_STATUS_ENUM_50 = 50; + case _50 = 50; } diff --git a/src/Document/ListMeta.php b/src/Document/ListMeta.php index b084083..8e61ded 100644 --- a/src/Document/ListMeta.php +++ b/src/Document/ListMeta.php @@ -9,17 +9,17 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * @phpstan-type list_meta = array{ - * limit?: int, + * @phpstan-type ListMetaShape = array{ + * limit?: int|null, * next?: string|null, - * offset?: int, + * offset?: int|null, * previous?: string|null, - * totalCount?: int, + * total_count?: int|null, * } */ final class ListMeta implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(optional: true)] @@ -37,8 +37,8 @@ final class ListMeta implements BaseModel /** * total number of objects. */ - #[Api('total_count', optional: true)] - public ?int $totalCount; + #[Api(optional: true)] + public ?int $total_count; public function __construct() { @@ -55,7 +55,7 @@ public static function with( ?string $next = null, ?int $offset = null, ?string $previous = null, - ?int $totalCount = null, + ?int $total_count = null, ): self { $obj = new self; @@ -63,7 +63,7 @@ public static function with( null !== $next && $obj->next = $next; null !== $offset && $obj->offset = $offset; null !== $previous && $obj->previous = $previous; - null !== $totalCount && $obj->totalCount = $totalCount; + null !== $total_count && $obj->total_count = $total_count; return $obj; } @@ -106,7 +106,7 @@ public function withPrevious(?string $previous): self public function withTotalCount(int $totalCount): self { $obj = clone $this; - $obj->totalCount = $totalCount; + $obj->total_count = $totalCount; return $obj; } diff --git a/src/Document/PdfFieldValidationEnum.php b/src/Document/PdfFieldValidationEnum.php index becfecf..f71507c 100644 --- a/src/Document/PdfFieldValidationEnum.php +++ b/src/Document/PdfFieldValidationEnum.php @@ -90,165 +90,165 @@ */ enum PdfFieldValidationEnum: int { - case PDF_FIELD_VALIDATION_ENUM_1 = 1; + case _1 = 1; - case PDF_FIELD_VALIDATION_ENUM_2 = 2; + case _2 = 2; - case PDF_FIELD_VALIDATION_ENUM_3 = 3; + case _3 = 3; - case PDF_FIELD_VALIDATION_ENUM_4 = 4; + case _4 = 4; - case PDF_FIELD_VALIDATION_ENUM_5 = 5; + case _5 = 5; - case PDF_FIELD_VALIDATION_ENUM_6 = 6; + case _6 = 6; - case PDF_FIELD_VALIDATION_ENUM_7 = 7; + case _7 = 7; - case PDF_FIELD_VALIDATION_ENUM_8 = 8; + case _8 = 8; - case PDF_FIELD_VALIDATION_ENUM_9 = 9; + case _9 = 9; - case PDF_FIELD_VALIDATION_ENUM_10 = 10; + case _10 = 10; - case PDF_FIELD_VALIDATION_ENUM_11 = 11; + case _11 = 11; - case PDF_FIELD_VALIDATION_ENUM_12 = 12; + case _12 = 12; - case PDF_FIELD_VALIDATION_ENUM_13 = 13; + case _13 = 13; - case PDF_FIELD_VALIDATION_ENUM_14 = 14; + case _14 = 14; - case PDF_FIELD_VALIDATION_ENUM_15 = 15; + case _15 = 15; - case PDF_FIELD_VALIDATION_ENUM_16 = 16; + case _16 = 16; - case PDF_FIELD_VALIDATION_ENUM_17 = 17; + case _17 = 17; - case PDF_FIELD_VALIDATION_ENUM_18 = 18; + case _18 = 18; - case PDF_FIELD_VALIDATION_ENUM_19 = 19; + case _19 = 19; - case PDF_FIELD_VALIDATION_ENUM_20 = 20; + case _20 = 20; - case PDF_FIELD_VALIDATION_ENUM_24 = 24; + case _24 = 24; - case PDF_FIELD_VALIDATION_ENUM_25 = 25; + case _25 = 25; - case PDF_FIELD_VALIDATION_ENUM_26 = 26; + case _26 = 26; - case PDF_FIELD_VALIDATION_ENUM_30 = 30; + case _30 = 30; - case PDF_FIELD_VALIDATION_ENUM_31 = 31; + case _31 = 31; - case PDF_FIELD_VALIDATION_ENUM_32 = 32; + case _32 = 32; - case PDF_FIELD_VALIDATION_ENUM_33 = 33; + case _33 = 33; - case PDF_FIELD_VALIDATION_ENUM_34 = 34; + case _34 = 34; - case PDF_FIELD_VALIDATION_ENUM_35 = 35; + case _35 = 35; - case PDF_FIELD_VALIDATION_ENUM_36 = 36; + case _36 = 36; - case PDF_FIELD_VALIDATION_ENUM_37 = 37; + case _37 = 37; - case PDF_FIELD_VALIDATION_ENUM_38 = 38; + case _38 = 38; - case PDF_FIELD_VALIDATION_ENUM_39 = 39; + case _39 = 39; - case PDF_FIELD_VALIDATION_ENUM_40 = 40; + case _40 = 40; - case PDF_FIELD_VALIDATION_ENUM_41 = 41; + case _41 = 41; - case PDF_FIELD_VALIDATION_ENUM_42 = 42; + case _42 = 42; - case PDF_FIELD_VALIDATION_ENUM_43 = 43; + case _43 = 43; - case PDF_FIELD_VALIDATION_ENUM_44 = 44; + case _44 = 44; - case PDF_FIELD_VALIDATION_ENUM_45 = 45; + case _45 = 45; - case PDF_FIELD_VALIDATION_ENUM_46 = 46; + case _46 = 46; - case PDF_FIELD_VALIDATION_ENUM_47 = 47; + case _47 = 47; - case PDF_FIELD_VALIDATION_ENUM_48 = 48; + case _48 = 48; - case PDF_FIELD_VALIDATION_ENUM_50 = 50; + case _50 = 50; - case PDF_FIELD_VALIDATION_ENUM_51 = 51; + case _51 = 51; - case PDF_FIELD_VALIDATION_ENUM_52 = 52; + case _52 = 52; - case PDF_FIELD_VALIDATION_ENUM_53 = 53; + case _53 = 53; - case PDF_FIELD_VALIDATION_ENUM_54 = 54; + case _54 = 54; - case PDF_FIELD_VALIDATION_ENUM_55 = 55; + case _55 = 55; - case PDF_FIELD_VALIDATION_ENUM_56 = 56; + case _56 = 56; - case PDF_FIELD_VALIDATION_ENUM_57 = 57; + case _57 = 57; - case PDF_FIELD_VALIDATION_ENUM_58 = 58; + case _58 = 58; - case PDF_FIELD_VALIDATION_ENUM_59 = 59; + case _59 = 59; - case PDF_FIELD_VALIDATION_ENUM_60 = 60; + case _60 = 60; - case PDF_FIELD_VALIDATION_ENUM_61 = 61; + case _61 = 61; - case PDF_FIELD_VALIDATION_ENUM_62 = 62; + case _62 = 62; - case PDF_FIELD_VALIDATION_ENUM_63 = 63; + case _63 = 63; - case PDF_FIELD_VALIDATION_ENUM_64 = 64; + case _64 = 64; - case PDF_FIELD_VALIDATION_ENUM_65 = 65; + case _65 = 65; - case PDF_FIELD_VALIDATION_ENUM_66 = 66; + case _66 = 66; - case PDF_FIELD_VALIDATION_ENUM_67 = 67; + case _67 = 67; - case PDF_FIELD_VALIDATION_ENUM_68 = 68; + case _68 = 68; - case PDF_FIELD_VALIDATION_ENUM_69 = 69; + case _69 = 69; - case PDF_FIELD_VALIDATION_ENUM_70 = 70; + case _70 = 70; - case PDF_FIELD_VALIDATION_ENUM_71 = 71; + case _71 = 71; - case PDF_FIELD_VALIDATION_ENUM_72 = 72; + case _72 = 72; - case PDF_FIELD_VALIDATION_ENUM_73 = 73; + case _73 = 73; - case PDF_FIELD_VALIDATION_ENUM_74 = 74; + case _74 = 74; - case PDF_FIELD_VALIDATION_ENUM_75 = 75; + case _75 = 75; - case PDF_FIELD_VALIDATION_ENUM_76 = 76; + case _76 = 76; - case PDF_FIELD_VALIDATION_ENUM_77 = 77; + case _77 = 77; - case PDF_FIELD_VALIDATION_ENUM_78 = 78; + case _78 = 78; - case PDF_FIELD_VALIDATION_ENUM_79 = 79; + case _79 = 79; - case PDF_FIELD_VALIDATION_ENUM_80 = 80; + case _80 = 80; - case PDF_FIELD_VALIDATION_ENUM_81 = 81; + case _81 = 81; - case PDF_FIELD_VALIDATION_ENUM_82 = 82; + case _82 = 82; - case PDF_FIELD_VALIDATION_ENUM_83 = 83; + case _83 = 83; - case PDF_FIELD_VALIDATION_ENUM_84 = 84; + case _84 = 84; - case PDF_FIELD_VALIDATION_ENUM_85 = 85; + case _85 = 85; - case PDF_FIELD_VALIDATION_ENUM_90 = 90; + case _90 = 90; - case PDF_FIELD_VALIDATION_ENUM_91 = 91; + case _91 = 91; - case PDF_FIELD_VALIDATION_ENUM_92 = 92; + case _92 = 92; } diff --git a/src/Group/GroupCreateParams.php b/src/Group/GroupCreateParams.php index 836a95a..7fbcdcc 100644 --- a/src/Group/GroupCreateParams.php +++ b/src/Group/GroupCreateParams.php @@ -10,26 +10,15 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new GroupCreateParams); // set properties as needed - * $client->group->create(...$params->toArray()); - * ``` * Create group. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\GroupService::create() * - * `$client->group->create(...$params->toArray());` - * - * @see LegalesignSDK\Group->create - * - * @phpstan-type group_create_params = array{name: string, xframeAllow?: bool} + * @phpstan-type GroupCreateParamsShape = array{name: string, xframe_allow?: bool} */ final class GroupCreateParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -39,8 +28,8 @@ final class GroupCreateParams implements BaseModel /** * Set to true if you want to embed your signing page. */ - #[Api('xframe_allow', optional: true)] - public ?bool $xframeAllow; + #[Api(optional: true)] + public ?bool $xframe_allow; /** * `new GroupCreateParams()` is missing required properties by the API. @@ -66,13 +55,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. */ - public static function with(string $name, ?bool $xframeAllow = null): self + public static function with(string $name, ?bool $xframe_allow = null): self { $obj = new self; $obj->name = $name; - null !== $xframeAllow && $obj->xframeAllow = $xframeAllow; + null !== $xframe_allow && $obj->xframe_allow = $xframe_allow; return $obj; } @@ -91,7 +80,7 @@ public function withName(string $name): self public function withXframeAllow(bool $xframeAllow): self { $obj = clone $this; - $obj->xframeAllow = $xframeAllow; + $obj->xframe_allow = $xframeAllow; return $obj; } diff --git a/src/Group/GroupGetResponse.php b/src/Group/GroupGetResponse.php index 49a7342..b1876ae 100644 --- a/src/Group/GroupGetResponse.php +++ b/src/Group/GroupGetResponse.php @@ -6,46 +6,46 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; /** - * @phpstan-type group_get_response = array{ - * created?: \DateTimeInterface, - * defaultEmail?: string, - * defaultExtraemail?: string, - * footer?: string, - * footerHeight?: int, - * header?: string, - * isActive?: bool, - * members?: list, - * modified?: \DateTimeInterface, - * name?: string, - * pagesize?: int, - * publicName?: string, - * resourceUri?: string, - * slug?: string, - * user?: string, - * xframeAllow?: bool, - * xframeAllowPdfEdit?: bool, + * @phpstan-type GroupGetResponseShape = array{ + * created?: \DateTimeInterface|null, + * default_email?: string|null, + * default_extraemail?: string|null, + * footer?: string|null, + * footer_height?: int|null, + * header?: string|null, + * is_active?: bool|null, + * members?: list|null, + * modified?: \DateTimeInterface|null, + * name?: string|null, + * pagesize?: int|null, + * public_name?: string|null, + * resource_uri?: string|null, + * slug?: string|null, + * user?: string|null, + * xframe_allow?: bool|null, + * xframe_allow_pdf_edit?: bool|null, * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class GroupGetResponse implements BaseModel +final class GroupGetResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?\DateTimeInterface $created; - #[Api('default_email', optional: true)] - public ?string $defaultEmail; + #[Api(optional: true)] + public ?string $default_email; - #[Api('default_extraemail', optional: true)] - public ?string $defaultExtraemail; + #[Api(optional: true)] + public ?string $default_extraemail; /** * html of content. @@ -53,14 +53,14 @@ final class GroupGetResponse implements BaseModel #[Api(optional: true)] public ?string $footer; - #[Api('footer_height', optional: true)] - public ?int $footerHeight; + #[Api(optional: true)] + public ?int $footer_height; #[Api(optional: true)] public ?string $header; - #[Api('is_active', optional: true)] - public ?bool $isActive; + #[Api(optional: true)] + public ?bool $is_active; /** * list of members uris. @@ -79,11 +79,11 @@ final class GroupGetResponse implements BaseModel #[Api(optional: true)] public ?int $pagesize; - #[Api('public_name', optional: true)] - public ?string $publicName; + #[Api(optional: true)] + public ?string $public_name; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; #[Api(optional: true)] public ?string $slug; @@ -91,11 +91,11 @@ final class GroupGetResponse implements BaseModel #[Api(optional: true)] public ?string $user; - #[Api('xframe_allow', optional: true)] - public ?bool $xframeAllow; + #[Api(optional: true)] + public ?bool $xframe_allow; - #[Api('xframe_allow_pdf_edit', optional: true)] - public ?bool $xframeAllowPdfEdit; + #[Api(optional: true)] + public ?bool $xframe_allow_pdf_edit; public function __construct() { @@ -111,42 +111,42 @@ public function __construct() */ public static function with( ?\DateTimeInterface $created = null, - ?string $defaultEmail = null, - ?string $defaultExtraemail = null, + ?string $default_email = null, + ?string $default_extraemail = null, ?string $footer = null, - ?int $footerHeight = null, + ?int $footer_height = null, ?string $header = null, - ?bool $isActive = null, + ?bool $is_active = null, ?array $members = null, ?\DateTimeInterface $modified = null, ?string $name = null, ?int $pagesize = null, - ?string $publicName = null, - ?string $resourceUri = null, + ?string $public_name = null, + ?string $resource_uri = null, ?string $slug = null, ?string $user = null, - ?bool $xframeAllow = null, - ?bool $xframeAllowPdfEdit = null, + ?bool $xframe_allow = null, + ?bool $xframe_allow_pdf_edit = null, ): self { $obj = new self; null !== $created && $obj->created = $created; - null !== $defaultEmail && $obj->defaultEmail = $defaultEmail; - null !== $defaultExtraemail && $obj->defaultExtraemail = $defaultExtraemail; + null !== $default_email && $obj->default_email = $default_email; + null !== $default_extraemail && $obj->default_extraemail = $default_extraemail; null !== $footer && $obj->footer = $footer; - null !== $footerHeight && $obj->footerHeight = $footerHeight; + null !== $footer_height && $obj->footer_height = $footer_height; null !== $header && $obj->header = $header; - null !== $isActive && $obj->isActive = $isActive; + null !== $is_active && $obj->is_active = $is_active; null !== $members && $obj->members = $members; null !== $modified && $obj->modified = $modified; null !== $name && $obj->name = $name; null !== $pagesize && $obj->pagesize = $pagesize; - null !== $publicName && $obj->publicName = $publicName; - null !== $resourceUri && $obj->resourceUri = $resourceUri; + null !== $public_name && $obj->public_name = $public_name; + null !== $resource_uri && $obj->resource_uri = $resource_uri; null !== $slug && $obj->slug = $slug; null !== $user && $obj->user = $user; - null !== $xframeAllow && $obj->xframeAllow = $xframeAllow; - null !== $xframeAllowPdfEdit && $obj->xframeAllowPdfEdit = $xframeAllowPdfEdit; + null !== $xframe_allow && $obj->xframe_allow = $xframe_allow; + null !== $xframe_allow_pdf_edit && $obj->xframe_allow_pdf_edit = $xframe_allow_pdf_edit; return $obj; } @@ -162,7 +162,7 @@ public function withCreated(\DateTimeInterface $created): self public function withDefaultEmail(string $defaultEmail): self { $obj = clone $this; - $obj->defaultEmail = $defaultEmail; + $obj->default_email = $defaultEmail; return $obj; } @@ -170,7 +170,7 @@ public function withDefaultEmail(string $defaultEmail): self public function withDefaultExtraemail(string $defaultExtraemail): self { $obj = clone $this; - $obj->defaultExtraemail = $defaultExtraemail; + $obj->default_extraemail = $defaultExtraemail; return $obj; } @@ -189,7 +189,7 @@ public function withFooter(string $footer): self public function withFooterHeight(int $footerHeight): self { $obj = clone $this; - $obj->footerHeight = $footerHeight; + $obj->footer_height = $footerHeight; return $obj; } @@ -205,7 +205,7 @@ public function withHeader(string $header): self public function withIsActive(bool $isActive): self { $obj = clone $this; - $obj->isActive = $isActive; + $obj->is_active = $isActive; return $obj; } @@ -250,7 +250,7 @@ public function withPagesize(int $pagesize): self public function withPublicName(string $publicName): self { $obj = clone $this; - $obj->publicName = $publicName; + $obj->public_name = $publicName; return $obj; } @@ -258,7 +258,7 @@ public function withPublicName(string $publicName): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -282,7 +282,7 @@ public function withUser(string $user): self public function withXframeAllow(bool $xframeAllow): self { $obj = clone $this; - $obj->xframeAllow = $xframeAllow; + $obj->xframe_allow = $xframeAllow; return $obj; } @@ -290,7 +290,7 @@ public function withXframeAllow(bool $xframeAllow): self public function withXframeAllowPdfEdit(bool $xframeAllowPdfEdit): self { $obj = clone $this; - $obj->xframeAllowPdfEdit = $xframeAllowPdfEdit; + $obj->xframe_allow_pdf_edit = $xframeAllowPdfEdit; return $obj; } diff --git a/src/Group/GroupListParams.php b/src/Group/GroupListParams.php index f5513e2..6bf4fe5 100644 --- a/src/Group/GroupListParams.php +++ b/src/Group/GroupListParams.php @@ -10,26 +10,15 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new GroupListParams); // set properties as needed - * $client->group->list(...$params->toArray()); - * ``` * List groups the api user belongs to. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\GroupService::list() * - * `$client->group->list(...$params->toArray());` - * - * @see LegalesignSDK\Group->list - * - * @phpstan-type group_list_params = array{limit?: int, offset?: int} + * @phpstan-type GroupListParamsShape = array{limit?: int, offset?: int} */ final class GroupListParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/Group/GroupListResponse.php b/src/Group/GroupListResponse.php index 2f6739c..90d2f0b 100644 --- a/src/Group/GroupListResponse.php +++ b/src/Group/GroupListResponse.php @@ -6,24 +6,24 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; use LegalesignSDK\Document\ListMeta; use LegalesignSDK\Group\GroupListResponse\Object1; /** - * @phpstan-type group_list_response = array{ - * meta?: ListMeta, objects?: list + * @phpstan-type GroupListResponseShape = array{ + * meta?: ListMeta|null, objects?: list|null * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class GroupListResponse implements BaseModel +final class GroupListResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?ListMeta $meta; diff --git a/src/Group/GroupListResponse/Object1.php b/src/Group/GroupListResponse/Object1.php index 2c98fb0..17cf215 100644 --- a/src/Group/GroupListResponse/Object1.php +++ b/src/Group/GroupListResponse/Object1.php @@ -9,29 +9,29 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * @phpstan-type object1_alias = array{ - * created?: \DateTimeInterface, - * isActive?: bool, - * modified?: \DateTimeInterface, - * name?: string, - * publicName?: string, - * resourceUri?: string, - * slug?: string, - * user?: string, - * xframeAllow?: bool, - * xframeAllowPdfEdit?: bool, + * @phpstan-type Object1Shape = array{ + * created?: \DateTimeInterface|null, + * is_active?: bool|null, + * modified?: \DateTimeInterface|null, + * name?: string|null, + * public_name?: string|null, + * resource_uri?: string|null, + * slug?: string|null, + * user?: string|null, + * xframe_allow?: bool|null, + * xframe_allow_pdf_edit?: bool|null, * } */ final class Object1 implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(optional: true)] public ?\DateTimeInterface $created; - #[Api('is_active', optional: true)] - public ?bool $isActive; + #[Api(optional: true)] + public ?bool $is_active; #[Api(optional: true)] public ?\DateTimeInterface $modified; @@ -39,11 +39,11 @@ final class Object1 implements BaseModel #[Api(optional: true)] public ?string $name; - #[Api('public_name', optional: true)] - public ?string $publicName; + #[Api(optional: true)] + public ?string $public_name; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; #[Api(optional: true)] public ?string $slug; @@ -51,11 +51,11 @@ final class Object1 implements BaseModel #[Api(optional: true)] public ?string $user; - #[Api('xframe_allow', optional: true)] - public ?bool $xframeAllow; + #[Api(optional: true)] + public ?bool $xframe_allow; - #[Api('xframe_allow_pdf_edit', optional: true)] - public ?bool $xframeAllowPdfEdit; + #[Api(optional: true)] + public ?bool $xframe_allow_pdf_edit; public function __construct() { @@ -69,28 +69,28 @@ public function __construct() */ public static function with( ?\DateTimeInterface $created = null, - ?bool $isActive = null, + ?bool $is_active = null, ?\DateTimeInterface $modified = null, ?string $name = null, - ?string $publicName = null, - ?string $resourceUri = null, + ?string $public_name = null, + ?string $resource_uri = null, ?string $slug = null, ?string $user = null, - ?bool $xframeAllow = null, - ?bool $xframeAllowPdfEdit = null, + ?bool $xframe_allow = null, + ?bool $xframe_allow_pdf_edit = null, ): self { $obj = new self; null !== $created && $obj->created = $created; - null !== $isActive && $obj->isActive = $isActive; + null !== $is_active && $obj->is_active = $is_active; null !== $modified && $obj->modified = $modified; null !== $name && $obj->name = $name; - null !== $publicName && $obj->publicName = $publicName; - null !== $resourceUri && $obj->resourceUri = $resourceUri; + null !== $public_name && $obj->public_name = $public_name; + null !== $resource_uri && $obj->resource_uri = $resource_uri; null !== $slug && $obj->slug = $slug; null !== $user && $obj->user = $user; - null !== $xframeAllow && $obj->xframeAllow = $xframeAllow; - null !== $xframeAllowPdfEdit && $obj->xframeAllowPdfEdit = $xframeAllowPdfEdit; + null !== $xframe_allow && $obj->xframe_allow = $xframe_allow; + null !== $xframe_allow_pdf_edit && $obj->xframe_allow_pdf_edit = $xframe_allow_pdf_edit; return $obj; } @@ -106,7 +106,7 @@ public function withCreated(\DateTimeInterface $created): self public function withIsActive(bool $isActive): self { $obj = clone $this; - $obj->isActive = $isActive; + $obj->is_active = $isActive; return $obj; } @@ -130,7 +130,7 @@ public function withName(string $name): self public function withPublicName(string $publicName): self { $obj = clone $this; - $obj->publicName = $publicName; + $obj->public_name = $publicName; return $obj; } @@ -138,7 +138,7 @@ public function withPublicName(string $publicName): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -162,7 +162,7 @@ public function withUser(string $user): self public function withXframeAllow(bool $xframeAllow): self { $obj = clone $this; - $obj->xframeAllow = $xframeAllow; + $obj->xframe_allow = $xframeAllow; return $obj; } @@ -170,7 +170,7 @@ public function withXframeAllow(bool $xframeAllow): self public function withXframeAllowPdfEdit(bool $xframeAllowPdfEdit): self { $obj = clone $this; - $obj->xframeAllowPdfEdit = $xframeAllowPdfEdit; + $obj->xframe_allow_pdf_edit = $xframeAllowPdfEdit; return $obj; } diff --git a/src/RequestOptions.php b/src/RequestOptions.php index 0372cf5..adccfab 100644 --- a/src/RequestOptions.php +++ b/src/RequestOptions.php @@ -21,8 +21,8 @@ * maxRetries?: int|null, * initialRetryDelay?: float|null, * maxRetryDelay?: float|null, - * extraHeaders?: array>|null, - * extraQueryParams?: array|null, + * extraHeaders?: array>|null, + * extraQueryParams?: array|null, * extraBodyParams?: mixed, * transporter?: ClientInterface|null, * uriFactory?: UriFactoryInterface|null, @@ -48,11 +48,11 @@ final class RequestOptions implements BaseModel #[Property] public float $maxRetryDelay = 8.0; - /** @var array|null>|null $extraHeaders */ + /** @var array|null>|null $extraHeaders */ #[Property(optional: true)] public ?array $extraHeaders; - /** @var array|null $extraQueryParams */ + /** @var array|null $extraQueryParams */ #[Property(optional: true)] public ?array $extraQueryParams; @@ -81,14 +81,14 @@ public function __construct() */ public static function parse(RequestOptions|array|null ...$options): self { - $parsed = array_map(static fn ($o) => $o instanceof self ? $o->toArray() : $o ?? [], array: $options); + $parsed = array_map(static fn ($o) => $o instanceof self ? $o->toProperties() : $o ?? [], array: $options); return self::with(...array_merge(...$parsed)); // @phpstan-ignore-line } /** - * @param array|null>|null $extraHeaders - * @param array|null $extraQueryParams + * @param array|null>|null $extraHeaders + * @param array|null $extraQueryParams * @param mixed|Omit $extraBodyParams */ public static function with( @@ -154,7 +154,7 @@ public function withMaxRetryDelay(float $maxRetryDelay): self } /** - * @param array|null> $extraHeaders + * @param array|null> $extraHeaders */ public function withExtraHeaders(array $extraHeaders): self { @@ -165,7 +165,7 @@ public function withExtraHeaders(array $extraHeaders): self } /** - * @param array $extraQueryParams + * @param array $extraQueryParams */ public function withExtraQueryParams(array $extraQueryParams): self { diff --git a/src/ServiceContracts/DocumentContract.php b/src/ServiceContracts/DocumentContract.php index 6cb6596..ffb6530 100644 --- a/src/ServiceContracts/DocumentContract.php +++ b/src/ServiceContracts/DocumentContract.php @@ -5,110 +5,31 @@ namespace LegalesignSDK\ServiceContracts; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; -use LegalesignSDK\Document\DocumentCreateParams\PdfPasswordType; -use LegalesignSDK\Document\DocumentCreateParams\Signer; +use LegalesignSDK\Document\DocumentCreateParams; use LegalesignSDK\Document\DocumentGetFieldsResponseItem; use LegalesignSDK\Document\DocumentGetResponse; +use LegalesignSDK\Document\DocumentListParams; use LegalesignSDK\Document\DocumentListResponse; use LegalesignSDK\Document\DocumentNewResponse; use LegalesignSDK\RequestOptions; -use const LegalesignSDK\Core\OMIT as omit; - interface DocumentContract { /** * @api * - * @param string $group - * @param string $name - * @param list $signers - * @param bool $appendPdf Append Legalesign validation info to final PDF. If not included uses the group default. - * @param bool $autoArchive Send to archive soon after signing. Keeps web app clutter free - * @param string $ccEmails comma delimited string of email addresses that are notified of signing or rejection - * @param bool $convertSenderToSigner if any sender fields are left blank, convert them to fields for the first recipient - * @param bool $doEmail Use Legalesign email to send notification emails. If false suppresses all emails. - * @param string $footer Text doc only. The footer for the final pdf. Use keyword \"default\" to use group default footer. - * @param int $footerHeight Text based doc only. Pixel height of PDF footer, if used. 1px = 0.025cm - * @param string $header Text based doc only. The header for the final pdf. Use keyword \"default\" to use group header footer. - * @param int $headerHeight Text based doc only. Pixel height of final PDF footer, if used. 1px = 0.025cm - * @param string $pdfPassword Set a password. Must be ascii encode-able, you must also set signature_type to 4 and choose a pdf_password_type. - * @param PdfPasswordType|value-of $pdfPasswordType 1 to store password, 2 for to delete from our records upon final signing - * @param array $pdftext Assign values to PDF sender fields, use field labels as keys. Requires unique fields labels. See also strict_fields. - * @param string $redirect URL to send the signer to after signing (instead of download page). Your URL will include query parameters with ID and state information as follows: YOUR-URL?signer=[signer_uid]&doc=[doc_id]&group=[group_id]&signer_state=[signer_status]&doc_state=[doc_status] - * @param string $reminders Put 'default' if you wish to use the default reminder schedule in the group (go to web app to set default schedule) - * @param bool $returnSignerLinks return document links for signers in the response BODY - * @param int $signatureType Use 4 to get your executed PDF Certified. Recommended. Defaults to 1 (uses a sha256 hash for document integrity). - * @param bool $signersInOrder Notify signers in their order sequence. If false all are notified simulataneously. - * @param array $signertext Add custom placeholders to signer fields, using labels as keys in an object (as for pdftext). Relies on unique labelling. - * @param bool $strictFields pdftext fails silently for invalid field value, set to true to return an error - * @param string $tag - * @param string $tag1 - * @param string $tag2 - * @param string $template Resource URI of text template object. This call must contain either one of the attributes text, templatepdf, template. - * @param string $templatepdf Resource URI of templatepdf object. This API call must contain either one of the attributes text, templatepdf, template. - * @param string $text Raw html. This API call must contain either one of the attributes text, templatepdf, template. - * @param string $user Assign document another user in the group. Defaults to API - * - * @return DocumentNewResponse + * @param array|DocumentCreateParams $params * * @throws APIException */ public function create( - $group, - $name, - $signers, - $appendPdf = omit, - $autoArchive = omit, - $ccEmails = omit, - $convertSenderToSigner = omit, - $doEmail = omit, - $footer = omit, - $footerHeight = omit, - $header = omit, - $headerHeight = omit, - $pdfPassword = omit, - $pdfPasswordType = omit, - $pdftext = omit, - $redirect = omit, - $reminders = omit, - $returnSignerLinks = omit, - $signatureType = omit, - $signersInOrder = omit, - $signertext = omit, - $strictFields = omit, - $tag = omit, - $tag1 = omit, - $tag2 = omit, - $template = omit, - $templatepdf = omit, - $text = omit, - $user = omit, + array|DocumentCreateParams $params, ?RequestOptions $requestOptions = null, ): DocumentNewResponse; /** * @api * - * @param array $params - * - * @return DocumentNewResponse - * - * @throws APIException - */ - public function createRaw( - array $params, - ?RequestOptions $requestOptions = null - ): DocumentNewResponse; - - /** - * @api - * - * @return DocumentGetResponse - * * @throws APIException */ public function retrieve( @@ -119,57 +40,12 @@ public function retrieve( /** * @api * - * @return DocumentGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null - ): DocumentGetResponse; - - /** - * @api - * - * @param string $group filter by a specific group, required - * @param string $archived Filter on archived status, default is false - * @param \DateTimeInterface $createdGt Filter for those documents created after a certain time - * @param string $email Filter by signer email - * @param int $limit Length of dataset to return. Use with offset query to iterate through results. - * @param \DateTimeInterface $modifiedGt Filter for those documents modified after a certain time - * @param string $nosigners Add value '1' to remove signers information for a faster query - * @param int $offset Offset from start of dataset. Use with the limit query to iterate through dataset. - * @param int $status Filter on document status - * - * @return DocumentListResponse + * @param array|DocumentListParams $params * * @throws APIException */ public function list( - $group, - $archived = omit, - $createdGt = omit, - $email = omit, - $limit = omit, - $modifiedGt = omit, - $nosigners = omit, - $offset = omit, - $status = omit, - ?RequestOptions $requestOptions = null, - ): DocumentListResponse; - - /** - * @api - * - * @param array $params - * - * @return DocumentListResponse - * - * @throws APIException - */ - public function listRaw( - array $params, + array|DocumentListParams $params, ?RequestOptions $requestOptions = null ): DocumentListResponse; @@ -183,17 +59,6 @@ public function archive( ?RequestOptions $requestOptions = null ): mixed; - /** - * @api - * - * @throws APIException - */ - public function archiveRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null - ): mixed; - /** * @api * @@ -206,19 +71,6 @@ public function getFields( ?RequestOptions $requestOptions = null ): array; - /** - * @api - * - * @return list - * - * @throws APIException - */ - public function getFieldsRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null - ): array; - /** * @api * @@ -228,15 +80,4 @@ public function permanentlyDelete( string $docID, ?RequestOptions $requestOptions = null ): mixed; - - /** - * @api - * - * @throws APIException - */ - public function permanentlyDeleteRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null - ): mixed; } diff --git a/src/ServiceContracts/GroupContract.php b/src/ServiceContracts/GroupContract.php index 7a7d65e..c0b328c 100644 --- a/src/ServiceContracts/GroupContract.php +++ b/src/ServiceContracts/GroupContract.php @@ -5,46 +5,29 @@ namespace LegalesignSDK\ServiceContracts; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; +use LegalesignSDK\Group\GroupCreateParams; use LegalesignSDK\Group\GroupGetResponse; +use LegalesignSDK\Group\GroupListParams; use LegalesignSDK\Group\GroupListResponse; use LegalesignSDK\RequestOptions; -use const LegalesignSDK\Core\OMIT as omit; - interface GroupContract { /** * @api * - * @param string $name - * @param bool $xframeAllow set to true if you want to embed your signing page + * @param array|GroupCreateParams $params * * @throws APIException */ public function create( - $name, - $xframeAllow = omit, - ?RequestOptions $requestOptions = null - ): mixed; - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function createRaw( - array $params, + array|GroupCreateParams $params, ?RequestOptions $requestOptions = null ): mixed; /** * @api * - * @return GroupGetResponse - * * @throws APIException */ public function retrieve( @@ -55,43 +38,12 @@ public function retrieve( /** * @api * - * @return GroupGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $groupID, - mixed $params, - ?RequestOptions $requestOptions = null - ): GroupGetResponse; - - /** - * @api - * - * @param int $limit Length of dataset to return. Use with offset query to iterate through results. - * @param int $offset Offset from start of dataset. Use with the limit query to iterate through dataset. - * - * @return GroupListResponse + * @param array|GroupListParams $params * * @throws APIException */ public function list( - $limit = omit, - $offset = omit, - ?RequestOptions $requestOptions = null - ): GroupListResponse; - - /** - * @api - * - * @param array $params - * - * @return GroupListResponse - * - * @throws APIException - */ - public function listRaw( - array $params, + array|GroupListParams $params, ?RequestOptions $requestOptions = null ): GroupListResponse; } diff --git a/src/ServiceContracts/PdfContract.php b/src/ServiceContracts/PdfContract.php index ceb2a17..c15a345 100644 --- a/src/ServiceContracts/PdfContract.php +++ b/src/ServiceContracts/PdfContract.php @@ -18,15 +18,4 @@ public function retrieve( string $docID, ?RequestOptions $requestOptions = null ): string; - - /** - * @api - * - * @throws APIException - */ - public function retrieveRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null - ): string; } diff --git a/src/ServiceContracts/SignerContract.php b/src/ServiceContracts/SignerContract.php index 5a86957..64983ca 100644 --- a/src/ServiceContracts/SignerContract.php +++ b/src/ServiceContracts/SignerContract.php @@ -5,20 +5,16 @@ namespace LegalesignSDK\ServiceContracts; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\Signer\SignerGetFieldsResponseItem; use LegalesignSDK\Signer\SignerGetResponse; - -use const LegalesignSDK\Core\OMIT as omit; +use LegalesignSDK\Signer\SignerSendReminderParams; interface SignerContract { /** * @api * - * @return SignerGetResponse - * * @throws APIException */ public function retrieve( @@ -26,19 +22,6 @@ public function retrieve( ?RequestOptions $requestOptions = null ): SignerGetResponse; - /** - * @api - * - * @return SignerGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $signerID, - mixed $params, - ?RequestOptions $requestOptions = null - ): SignerGetResponse; - /** * @api * @@ -49,17 +32,6 @@ public function getAccessLink( ?RequestOptions $requestOptions = null ): mixed; - /** - * @api - * - * @throws APIException - */ - public function getAccessLinkRaw( - string $signerID, - mixed $params, - ?RequestOptions $requestOptions = null - ): mixed; - /** * @api * @@ -75,39 +47,13 @@ public function retrieveFields( /** * @api * - * @return list - * - * @throws APIException - */ - public function retrieveFieldsRaw( - string $signerID, - mixed $params, - ?RequestOptions $requestOptions = null - ): array; - - /** - * @api - * - * @param string $text custom message text, html will be stripped + * @param array|SignerSendReminderParams $params * * @throws APIException */ public function sendReminder( string $signerID, - $text = omit, - ?RequestOptions $requestOptions = null - ): mixed; - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function sendReminderRaw( - string $signerID, - array $params, - ?RequestOptions $requestOptions = null + array|SignerSendReminderParams $params, + ?RequestOptions $requestOptions = null, ): mixed; } diff --git a/src/ServiceContracts/StatusContract.php b/src/ServiceContracts/StatusContract.php index 93c67b6..63ae37c 100644 --- a/src/ServiceContracts/StatusContract.php +++ b/src/ServiceContracts/StatusContract.php @@ -5,7 +5,6 @@ namespace LegalesignSDK\ServiceContracts; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\Status\StatusGetResponse; @@ -14,25 +13,10 @@ interface StatusContract /** * @api * - * @return StatusGetResponse - * * @throws APIException */ public function retrieve( string $docID, ?RequestOptions $requestOptions = null ): StatusGetResponse; - - /** - * @api - * - * @return StatusGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null - ): StatusGetResponse; } diff --git a/src/ServiceContracts/TemplateContract.php b/src/ServiceContracts/TemplateContract.php index 812f225..316c7d5 100644 --- a/src/ServiceContracts/TemplateContract.php +++ b/src/ServiceContracts/TemplateContract.php @@ -5,50 +5,29 @@ namespace LegalesignSDK\ServiceContracts; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; +use LegalesignSDK\Template\TemplateCreateParams; use LegalesignSDK\Template\TemplateGetResponse; +use LegalesignSDK\Template\TemplateListParams; use LegalesignSDK\Template\TemplateListResponse; -use const LegalesignSDK\Core\OMIT as omit; - interface TemplateContract { /** * @api * - * @param string $group - * @param string $latestText text/html for template - * @param string $title - * @param string $user assign to a user if not api user + * @param array|TemplateCreateParams $params * * @throws APIException */ public function create( - $group, - $latestText, - $title, - $user = omit, + array|TemplateCreateParams $params, ?RequestOptions $requestOptions = null, ): mixed; /** * @api * - * @param array $params - * - * @throws APIException - */ - public function createRaw( - array $params, - ?RequestOptions $requestOptions = null - ): mixed; - - /** - * @api - * - * @return TemplateGetResponse - * * @throws APIException */ public function retrieve( @@ -59,73 +38,23 @@ public function retrieve( /** * @api * - * @return TemplateGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $templateID, - mixed $params, - ?RequestOptions $requestOptions = null, - ): TemplateGetResponse; - - /** - * @api - * - * @param string $body json with any fields to update - * * @throws APIException */ public function update( string $templateID, - $body, - ?RequestOptions $requestOptions = null - ): mixed; - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function updateRaw( - string $templateID, - array $params, + string $params, ?RequestOptions $requestOptions = null, ): mixed; /** * @api * - * @param string $archive - * @param string $group can be full resource_uri or only id - * @param int $limit Length of dataset to return. Use with offset query to iterate through results. - * @param int $offset Offset from start of dataset. Use with the limit query to iterate through dataset. - * - * @return TemplateListResponse + * @param array|TemplateListParams $params * * @throws APIException */ public function list( - $archive = omit, - $group = omit, - $limit = omit, - $offset = omit, - ?RequestOptions $requestOptions = null, - ): TemplateListResponse; - - /** - * @api - * - * @param array $params - * - * @return TemplateListResponse - * - * @throws APIException - */ - public function listRaw( - array $params, + array|TemplateListParams $params, ?RequestOptions $requestOptions = null ): TemplateListResponse; } diff --git a/src/ServiceContracts/Templatepdf/FieldsContract.php b/src/ServiceContracts/Templatepdf/FieldsContract.php index 65dee99..1f37b43 100644 --- a/src/ServiceContracts/Templatepdf/FieldsContract.php +++ b/src/ServiceContracts/Templatepdf/FieldsContract.php @@ -5,7 +5,6 @@ namespace LegalesignSDK\ServiceContracts\Templatepdf; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\Templatepdf\Fields\FieldCreateParams\Body; use LegalesignSDK\Templatepdf\Fields\FieldListResponse; @@ -15,24 +14,11 @@ interface FieldsContract /** * @api * - * @param list $body + * @param list $params * * @throws APIException */ public function create( - string $pdfID, - $body, - ?RequestOptions $requestOptions = null - ): mixed; - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function createRaw( string $pdfID, array $params, ?RequestOptions $requestOptions = null @@ -41,25 +27,10 @@ public function createRaw( /** * @api * - * @return FieldListResponse - * * @throws APIException */ public function list( string $pdfID, ?RequestOptions $requestOptions = null ): FieldListResponse; - - /** - * @api - * - * @return FieldListResponse - * - * @throws APIException - */ - public function listRaw( - string $pdfID, - mixed $params, - ?RequestOptions $requestOptions = null - ): FieldListResponse; } diff --git a/src/ServiceContracts/TemplatepdfContract.php b/src/ServiceContracts/TemplatepdfContract.php index 8cc4ac2..84ca83e 100644 --- a/src/ServiceContracts/TemplatepdfContract.php +++ b/src/ServiceContracts/TemplatepdfContract.php @@ -5,54 +5,29 @@ namespace LegalesignSDK\ServiceContracts; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\Templatepdf\TemplatePdf; +use LegalesignSDK\Templatepdf\TemplatepdfCreateParams; +use LegalesignSDK\Templatepdf\TemplatepdfListParams; use LegalesignSDK\Templatepdf\TemplatepdfListResponse; -use const LegalesignSDK\Core\OMIT as omit; - interface TemplatepdfContract { /** * @api * - * @param string $group - * @param string $pdfFile base64 encoded PDF file data - * @param bool $archiveUponSend archive PDF when sent - * @param bool $processTags - * @param string $title - * @param string $user assign to group member if not api user + * @param array|TemplatepdfCreateParams $params * * @throws APIException */ public function create( - $group, - $pdfFile, - $archiveUponSend = omit, - $processTags = omit, - $title = omit, - $user = omit, + array|TemplatepdfCreateParams $params, ?RequestOptions $requestOptions = null, ): mixed; /** * @api * - * @param array $params - * - * @throws APIException - */ - public function createRaw( - array $params, - ?RequestOptions $requestOptions = null - ): mixed; - - /** - * @api - * - * @return TemplatePdf - * * @throws APIException */ public function retrieve( @@ -63,50 +38,15 @@ public function retrieve( /** * @api * - * @return TemplatePdf - * - * @throws APIException - */ - public function retrieveRaw( - string $pdfID, - mixed $params, - ?RequestOptions $requestOptions = null - ): TemplatePdf; - - /** - * @api - * - * @param string $archive - * @param string $group can be full resource_uri or only id - * @param int $limit Length of dataset to return. Use with offset query to iterate through results. - * @param int $offset Offset from start of dataset. Use with the limit query to iterate through dataset. - * - * @return TemplatepdfListResponse + * @param array|TemplatepdfListParams $params * * @throws APIException */ public function list( - $archive = omit, - $group = omit, - $limit = omit, - $offset = omit, + array|TemplatepdfListParams $params, ?RequestOptions $requestOptions = null, ): TemplatepdfListResponse; - /** - * @api - * - * @param array $params - * - * @return TemplatepdfListResponse - * - * @throws APIException - */ - public function listRaw( - array $params, - ?RequestOptions $requestOptions = null - ): TemplatepdfListResponse; - /** * @api * @@ -116,15 +56,4 @@ public function getEditLink( string $pdfID, ?RequestOptions $requestOptions = null ): string; - - /** - * @api - * - * @throws APIException - */ - public function getEditLinkRaw( - string $pdfID, - mixed $params, - ?RequestOptions $requestOptions = null - ): string; } diff --git a/src/Services/DocumentService.php b/src/Services/DocumentService.php index 8b6f3bd..347d64b 100644 --- a/src/Services/DocumentService.php +++ b/src/Services/DocumentService.php @@ -7,10 +7,7 @@ use LegalesignSDK\Client; use LegalesignSDK\Core\Conversion\ListOf; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\Document\DocumentCreateParams; -use LegalesignSDK\Document\DocumentCreateParams\PdfPasswordType; -use LegalesignSDK\Document\DocumentCreateParams\Signer; use LegalesignSDK\Document\DocumentGetFieldsResponseItem; use LegalesignSDK\Document\DocumentGetResponse; use LegalesignSDK\Document\DocumentListParams; @@ -19,8 +16,6 @@ use LegalesignSDK\RequestOptions; use LegalesignSDK\ServiceContracts\DocumentContract; -use const LegalesignSDK\Core\OMIT as omit; - final class DocumentService implements DocumentContract { /** @@ -33,125 +28,62 @@ public function __construct(private Client $client) {} * * Create signing document * - * @param string $group - * @param string $name - * @param list $signers - * @param bool $appendPdf Append Legalesign validation info to final PDF. If not included uses the group default. - * @param bool $autoArchive Send to archive soon after signing. Keeps web app clutter free - * @param string $ccEmails comma delimited string of email addresses that are notified of signing or rejection - * @param bool $convertSenderToSigner if any sender fields are left blank, convert them to fields for the first recipient - * @param bool $doEmail Use Legalesign email to send notification emails. If false suppresses all emails. - * @param string $footer Text doc only. The footer for the final pdf. Use keyword \"default\" to use group default footer. - * @param int $footerHeight Text based doc only. Pixel height of PDF footer, if used. 1px = 0.025cm - * @param string $header Text based doc only. The header for the final pdf. Use keyword \"default\" to use group header footer. - * @param int $headerHeight Text based doc only. Pixel height of final PDF footer, if used. 1px = 0.025cm - * @param string $pdfPassword Set a password. Must be ascii encode-able, you must also set signature_type to 4 and choose a pdf_password_type. - * @param PdfPasswordType|value-of $pdfPasswordType 1 to store password, 2 for to delete from our records upon final signing - * @param array $pdftext Assign values to PDF sender fields, use field labels as keys. Requires unique fields labels. See also strict_fields. - * @param string $redirect URL to send the signer to after signing (instead of download page). Your URL will include query parameters with ID and state information as follows: YOUR-URL?signer=[signer_uid]&doc=[doc_id]&group=[group_id]&signer_state=[signer_status]&doc_state=[doc_status] - * @param string $reminders Put 'default' if you wish to use the default reminder schedule in the group (go to web app to set default schedule) - * @param bool $returnSignerLinks return document links for signers in the response BODY - * @param int $signatureType Use 4 to get your executed PDF Certified. Recommended. Defaults to 1 (uses a sha256 hash for document integrity). - * @param bool $signersInOrder Notify signers in their order sequence. If false all are notified simulataneously. - * @param array $signertext Add custom placeholders to signer fields, using labels as keys in an object (as for pdftext). Relies on unique labelling. - * @param bool $strictFields pdftext fails silently for invalid field value, set to true to return an error - * @param string $tag - * @param string $tag1 - * @param string $tag2 - * @param string $template Resource URI of text template object. This call must contain either one of the attributes text, templatepdf, template. - * @param string $templatepdf Resource URI of templatepdf object. This API call must contain either one of the attributes text, templatepdf, template. - * @param string $text Raw html. This API call must contain either one of the attributes text, templatepdf, template. - * @param string $user Assign document another user in the group. Defaults to API - * - * @return DocumentNewResponse + * @param array{ + * group: string, + * name: string, + * signers: list, + * behalfof?: string, + * decide_later?: bool, + * expires?: string|\DateTimeInterface|null, + * message?: string, + * order?: int, + * reviewers?: list>, + * role?: "witness"|"approver", + * sms?: string, + * subject?: string, + * timezone?: string, + * }>, + * append_pdf?: bool, + * auto_archive?: bool, + * cc_emails?: string, + * convert_sender_to_signer?: bool, + * do_email?: bool, + * footer?: string, + * footer_height?: int, + * header?: string, + * header_height?: int, + * pdf_password?: string, + * pdf_password_type?: 1|2, + * pdftext?: array, + * redirect?: string, + * reminders?: string, + * return_signer_links?: bool, + * signature_type?: int, + * signers_in_order?: bool, + * signertext?: array, + * strict_fields?: bool, + * tag?: string, + * tag1?: string, + * tag2?: string, + * template?: string, + * templatepdf?: string, + * text?: string, + * user?: string, + * }|DocumentCreateParams $params * * @throws APIException */ public function create( - $group, - $name, - $signers, - $appendPdf = omit, - $autoArchive = omit, - $ccEmails = omit, - $convertSenderToSigner = omit, - $doEmail = omit, - $footer = omit, - $footerHeight = omit, - $header = omit, - $headerHeight = omit, - $pdfPassword = omit, - $pdfPasswordType = omit, - $pdftext = omit, - $redirect = omit, - $reminders = omit, - $returnSignerLinks = omit, - $signatureType = omit, - $signersInOrder = omit, - $signertext = omit, - $strictFields = omit, - $tag = omit, - $tag1 = omit, - $tag2 = omit, - $template = omit, - $templatepdf = omit, - $text = omit, - $user = omit, - ?RequestOptions $requestOptions = null, - ): DocumentNewResponse { - $params = [ - 'group' => $group, - 'name' => $name, - 'signers' => $signers, - 'appendPdf' => $appendPdf, - 'autoArchive' => $autoArchive, - 'ccEmails' => $ccEmails, - 'convertSenderToSigner' => $convertSenderToSigner, - 'doEmail' => $doEmail, - 'footer' => $footer, - 'footerHeight' => $footerHeight, - 'header' => $header, - 'headerHeight' => $headerHeight, - 'pdfPassword' => $pdfPassword, - 'pdfPasswordType' => $pdfPasswordType, - 'pdftext' => $pdftext, - 'redirect' => $redirect, - 'reminders' => $reminders, - 'returnSignerLinks' => $returnSignerLinks, - 'signatureType' => $signatureType, - 'signersInOrder' => $signersInOrder, - 'signertext' => $signertext, - 'strictFields' => $strictFields, - 'tag' => $tag, - 'tag1' => $tag1, - 'tag2' => $tag2, - 'template' => $template, - 'templatepdf' => $templatepdf, - 'text' => $text, - 'user' => $user, - ]; - - return $this->createRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return DocumentNewResponse - * - * @throws APIException - */ - public function createRaw( - array $params, + array|DocumentCreateParams $params, ?RequestOptions $requestOptions = null ): DocumentNewResponse { [$parsed, $options] = DocumentCreateParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -169,30 +101,11 @@ public function createRaw( * * Get document * - * @return DocumentGetResponse - * * @throws APIException */ public function retrieve( string $docID, ?RequestOptions $requestOptions = null - ): DocumentGetResponse { - $params = []; - - return $this->retrieveRaw($docID, $params, $requestOptions); - } - - /** - * @api - * - * @return DocumentGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null ): DocumentGetResponse { // @phpstan-ignore-next-line; return $this->client->request( @@ -208,63 +121,27 @@ public function retrieveRaw( * * List (unarchived) signing documents. Use /status/ if you need high-level information. * - * @param string $group filter by a specific group, required - * @param string $archived Filter on archived status, default is false - * @param \DateTimeInterface $createdGt Filter for those documents created after a certain time - * @param string $email Filter by signer email - * @param int $limit Length of dataset to return. Use with offset query to iterate through results. - * @param \DateTimeInterface $modifiedGt Filter for those documents modified after a certain time - * @param string $nosigners Add value '1' to remove signers information for a faster query - * @param int $offset Offset from start of dataset. Use with the limit query to iterate through dataset. - * @param int $status Filter on document status - * - * @return DocumentListResponse + * @param array{ + * group: string, + * archived?: string, + * created_gt?: string|\DateTimeInterface, + * email?: string, + * limit?: int, + * modified_gt?: string|\DateTimeInterface, + * nosigners?: string, + * offset?: int, + * status?: int, + * }|DocumentListParams $params * * @throws APIException */ public function list( - $group, - $archived = omit, - $createdGt = omit, - $email = omit, - $limit = omit, - $modifiedGt = omit, - $nosigners = omit, - $offset = omit, - $status = omit, - ?RequestOptions $requestOptions = null, - ): DocumentListResponse { - $params = [ - 'group' => $group, - 'archived' => $archived, - 'createdGt' => $createdGt, - 'email' => $email, - 'limit' => $limit, - 'modifiedGt' => $modifiedGt, - 'nosigners' => $nosigners, - 'offset' => $offset, - 'status' => $status, - ]; - - return $this->listRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return DocumentListResponse - * - * @throws APIException - */ - public function listRaw( - array $params, + array|DocumentListParams $params, ?RequestOptions $requestOptions = null ): DocumentListResponse { [$parsed, $options] = DocumentListParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -287,21 +164,6 @@ public function listRaw( public function archive( string $docID, ?RequestOptions $requestOptions = null - ): mixed { - $params = []; - - return $this->archiveRaw($docID, $params, $requestOptions); - } - - /** - * @api - * - * @throws APIException - */ - public function archiveRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null ): mixed { // @phpstan-ignore-next-line; return $this->client->request( @@ -324,23 +186,6 @@ public function archiveRaw( public function getFields( string $docID, ?RequestOptions $requestOptions = null - ): array { - $params = []; - - return $this->getFieldsRaw($docID, $params, $requestOptions); - } - - /** - * @api - * - * @return list - * - * @throws APIException - */ - public function getFieldsRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null ): array { // @phpstan-ignore-next-line; return $this->client->request( @@ -361,21 +206,6 @@ public function getFieldsRaw( public function permanentlyDelete( string $docID, ?RequestOptions $requestOptions = null - ): mixed { - $params = []; - - return $this->permanentlyDeleteRaw($docID, $params, $requestOptions); - } - - /** - * @api - * - * @throws APIException - */ - public function permanentlyDeleteRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null ): mixed { // @phpstan-ignore-next-line; return $this->client->request( diff --git a/src/Services/GroupService.php b/src/Services/GroupService.php index 47977b1..d3fca7f 100644 --- a/src/Services/GroupService.php +++ b/src/Services/GroupService.php @@ -6,7 +6,6 @@ use LegalesignSDK\Client; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\Group\GroupCreateParams; use LegalesignSDK\Group\GroupGetResponse; use LegalesignSDK\Group\GroupListParams; @@ -14,8 +13,6 @@ use LegalesignSDK\RequestOptions; use LegalesignSDK\ServiceContracts\GroupContract; -use const LegalesignSDK\Core\OMIT as omit; - final class GroupService implements GroupContract { /** @@ -28,35 +25,17 @@ public function __construct(private Client $client) {} * * Create group * - * @param string $name - * @param bool $xframeAllow set to true if you want to embed your signing page + * @param array{name: string, xframe_allow?: bool}|GroupCreateParams $params * * @throws APIException */ public function create( - $name, - $xframeAllow = omit, - ?RequestOptions $requestOptions = null - ): mixed { - $params = ['name' => $name, 'xframeAllow' => $xframeAllow]; - - return $this->createRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function createRaw( - array $params, + array|GroupCreateParams $params, ?RequestOptions $requestOptions = null ): mixed { [$parsed, $options] = GroupCreateParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -74,30 +53,11 @@ public function createRaw( * * Get group * - * @return GroupGetResponse - * * @throws APIException */ public function retrieve( string $groupID, ?RequestOptions $requestOptions = null - ): GroupGetResponse { - $params = []; - - return $this->retrieveRaw($groupID, $params, $requestOptions); - } - - /** - * @api - * - * @return GroupGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $groupID, - mixed $params, - ?RequestOptions $requestOptions = null ): GroupGetResponse { // @phpstan-ignore-next-line; return $this->client->request( @@ -113,39 +73,17 @@ public function retrieveRaw( * * List groups the api user belongs to * - * @param int $limit Length of dataset to return. Use with offset query to iterate through results. - * @param int $offset Offset from start of dataset. Use with the limit query to iterate through dataset. - * - * @return GroupListResponse + * @param array{limit?: int, offset?: int}|GroupListParams $params * * @throws APIException */ public function list( - $limit = omit, - $offset = omit, - ?RequestOptions $requestOptions = null - ): GroupListResponse { - $params = ['limit' => $limit, 'offset' => $offset]; - - return $this->listRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return GroupListResponse - * - * @throws APIException - */ - public function listRaw( - array $params, + array|GroupListParams $params, ?RequestOptions $requestOptions = null ): GroupListResponse { [$parsed, $options] = GroupListParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; diff --git a/src/Services/PdfService.php b/src/Services/PdfService.php index 81da54d..8823646 100644 --- a/src/Services/PdfService.php +++ b/src/Services/PdfService.php @@ -26,21 +26,6 @@ public function __construct(private Client $client) {} public function retrieve( string $docID, ?RequestOptions $requestOptions = null - ): string { - $params = []; - - return $this->retrieveRaw($docID, $params, $requestOptions); - } - - /** - * @api - * - * @throws APIException - */ - public function retrieveRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null ): string { // @phpstan-ignore-next-line; return $this->client->request( diff --git a/src/Services/SignerService.php b/src/Services/SignerService.php index 87af241..749a775 100644 --- a/src/Services/SignerService.php +++ b/src/Services/SignerService.php @@ -7,15 +7,12 @@ use LegalesignSDK\Client; use LegalesignSDK\Core\Conversion\ListOf; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\ServiceContracts\SignerContract; use LegalesignSDK\Signer\SignerGetFieldsResponseItem; use LegalesignSDK\Signer\SignerGetResponse; use LegalesignSDK\Signer\SignerSendReminderParams; -use const LegalesignSDK\Core\OMIT as omit; - final class SignerService implements SignerContract { /** @@ -28,30 +25,11 @@ public function __construct(private Client $client) {} * * Get status and details of an individual signer * - * @return SignerGetResponse - * * @throws APIException */ public function retrieve( string $signerID, ?RequestOptions $requestOptions = null - ): SignerGetResponse { - $params = []; - - return $this->retrieveRaw($signerID, $params, $requestOptions); - } - - /** - * @api - * - * @return SignerGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $signerID, - mixed $params, - ?RequestOptions $requestOptions = null ): SignerGetResponse { // @phpstan-ignore-next-line; return $this->client->request( @@ -72,21 +50,6 @@ public function retrieveRaw( public function getAccessLink( string $signerID, ?RequestOptions $requestOptions = null - ): mixed { - $params = []; - - return $this->getAccessLinkRaw($signerID, $params, $requestOptions); - } - - /** - * @api - * - * @throws APIException - */ - public function getAccessLinkRaw( - string $signerID, - mixed $params, - ?RequestOptions $requestOptions = null ): mixed { // @phpstan-ignore-next-line; return $this->client->request( @@ -109,23 +72,6 @@ public function getAccessLinkRaw( public function retrieveFields( string $signerID, ?RequestOptions $requestOptions = null - ): array { - $params = []; - - return $this->retrieveFieldsRaw($signerID, $params, $requestOptions); - } - - /** - * @api - * - * @return list - * - * @throws APIException - */ - public function retrieveFieldsRaw( - string $signerID, - mixed $params, - ?RequestOptions $requestOptions = null ): array { // @phpstan-ignore-next-line; return $this->client->request( @@ -141,35 +87,18 @@ public function retrieveFieldsRaw( * * Send signer reminder email * - * @param string $text custom message text, html will be stripped + * @param array{text?: string}|SignerSendReminderParams $params * * @throws APIException */ public function sendReminder( string $signerID, - $text = omit, - ?RequestOptions $requestOptions = null - ): mixed { - $params = ['text' => $text]; - - return $this->sendReminderRaw($signerID, $params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function sendReminderRaw( - string $signerID, - array $params, - ?RequestOptions $requestOptions = null + array|SignerSendReminderParams $params, + ?RequestOptions $requestOptions = null, ): mixed { [$parsed, $options] = SignerSendReminderParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; diff --git a/src/Services/StatusService.php b/src/Services/StatusService.php index 3bd5875..04fb425 100644 --- a/src/Services/StatusService.php +++ b/src/Services/StatusService.php @@ -6,7 +6,6 @@ use LegalesignSDK\Client; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\ServiceContracts\StatusContract; use LegalesignSDK\Status\StatusGetResponse; @@ -23,30 +22,11 @@ public function __construct(private Client $client) {} * * Faster short query for a document status * - * @return StatusGetResponse - * * @throws APIException */ public function retrieve( string $docID, ?RequestOptions $requestOptions = null - ): StatusGetResponse { - $params = []; - - return $this->retrieveRaw($docID, $params, $requestOptions); - } - - /** - * @api - * - * @return StatusGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $docID, - mixed $params, - ?RequestOptions $requestOptions = null ): StatusGetResponse { // @phpstan-ignore-next-line; return $this->client->request( diff --git a/src/Services/TemplateService.php b/src/Services/TemplateService.php index 2dcb32d..0b8fba7 100644 --- a/src/Services/TemplateService.php +++ b/src/Services/TemplateService.php @@ -6,7 +6,6 @@ use LegalesignSDK\Client; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\ServiceContracts\TemplateContract; use LegalesignSDK\Template\TemplateCreateParams; @@ -15,8 +14,6 @@ use LegalesignSDK\Template\TemplateListResponse; use LegalesignSDK\Template\TemplateUpdateParams; -use const LegalesignSDK\Core\OMIT as omit; - final class TemplateService implements TemplateContract { /** @@ -29,44 +26,19 @@ public function __construct(private Client $client) {} * * Create a new html/text template. This probably isn't the method you are looking for. You can use the 'text' attribute in /document/ to create and send your HTML as a signing document in one call. * - * @param string $group - * @param string $latestText text/html for template - * @param string $title - * @param string $user assign to a user if not api user + * @param array{ + * group: string, latest_text: string, title: string, user?: string + * }|TemplateCreateParams $params * * @throws APIException */ public function create( - $group, - $latestText, - $title, - $user = omit, - ?RequestOptions $requestOptions = null, - ): mixed { - $params = [ - 'group' => $group, - 'latestText' => $latestText, - 'title' => $title, - 'user' => $user, - ]; - - return $this->createRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function createRaw( - array $params, + array|TemplateCreateParams $params, ?RequestOptions $requestOptions = null ): mixed { [$parsed, $options] = TemplateCreateParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -84,30 +56,11 @@ public function createRaw( * * Get text template * - * @return TemplateGetResponse - * * @throws APIException */ public function retrieve( string $templateID, ?RequestOptions $requestOptions = null - ): TemplateGetResponse { - $params = []; - - return $this->retrieveRaw($templateID, $params, $requestOptions); - } - - /** - * @api - * - * @return TemplateGetResponse - * - * @throws APIException - */ - public function retrieveRaw( - string $templateID, - mixed $params, - ?RequestOptions $requestOptions = null ): TemplateGetResponse { // @phpstan-ignore-next-line; return $this->client->request( @@ -123,35 +76,16 @@ public function retrieveRaw( * * Update text template * - * @param string $body json with any fields to update - * * @throws APIException */ public function update( string $templateID, - $body, - ?RequestOptions $requestOptions = null - ): mixed { - $params = ['body' => $body]; - - return $this->updateRaw($templateID, $params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function updateRaw( - string $templateID, - array $params, + string $params, ?RequestOptions $requestOptions = null ): mixed { [$parsed, $options] = TemplateUpdateParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -169,48 +103,19 @@ public function updateRaw( * * Get text templates * - * @param string $archive - * @param string $group can be full resource_uri or only id - * @param int $limit Length of dataset to return. Use with offset query to iterate through results. - * @param int $offset Offset from start of dataset. Use with the limit query to iterate through dataset. - * - * @return TemplateListResponse + * @param array{ + * archive?: string, group?: string, limit?: int, offset?: int + * }|TemplateListParams $params * * @throws APIException */ public function list( - $archive = omit, - $group = omit, - $limit = omit, - $offset = omit, - ?RequestOptions $requestOptions = null, - ): TemplateListResponse { - $params = [ - 'archive' => $archive, - 'group' => $group, - 'limit' => $limit, - 'offset' => $offset, - ]; - - return $this->listRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return TemplateListResponse - * - * @throws APIException - */ - public function listRaw( - array $params, + array|TemplateListParams $params, ?RequestOptions $requestOptions = null ): TemplateListResponse { [$parsed, $options] = TemplateListParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; diff --git a/src/Services/Templatepdf/FieldsService.php b/src/Services/Templatepdf/FieldsService.php index 1f142ba..a11ef14 100644 --- a/src/Services/Templatepdf/FieldsService.php +++ b/src/Services/Templatepdf/FieldsService.php @@ -6,7 +6,6 @@ use LegalesignSDK\Client; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\ServiceContracts\Templatepdf\FieldsContract; use LegalesignSDK\Templatepdf\Fields\FieldCreateParams; @@ -25,35 +24,18 @@ public function __construct(private Client $client) {} * * Replace existing pdf fields with new ones * - * @param list $body + * @param list $params * * @throws APIException */ public function create( - string $pdfID, - $body, - ?RequestOptions $requestOptions = null - ): mixed { - $params = ['body' => $body]; - - return $this->createRaw($pdfID, $params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function createRaw( string $pdfID, array $params, ?RequestOptions $requestOptions = null ): mixed { [$parsed, $options] = FieldCreateParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -71,30 +53,11 @@ public function createRaw( * * Get PDF template fields * - * @return FieldListResponse - * * @throws APIException */ public function list( string $pdfID, ?RequestOptions $requestOptions = null - ): FieldListResponse { - $params = []; - - return $this->listRaw($pdfID, $params, $requestOptions); - } - - /** - * @api - * - * @return FieldListResponse - * - * @throws APIException - */ - public function listRaw( - string $pdfID, - mixed $params, - ?RequestOptions $requestOptions = null ): FieldListResponse { // @phpstan-ignore-next-line; return $this->client->request( diff --git a/src/Services/TemplatepdfService.php b/src/Services/TemplatepdfService.php index a1512cb..118ad03 100644 --- a/src/Services/TemplatepdfService.php +++ b/src/Services/TemplatepdfService.php @@ -6,7 +6,6 @@ use LegalesignSDK\Client; use LegalesignSDK\Core\Exceptions\APIException; -use LegalesignSDK\Core\Implementation\HasRawResponse; use LegalesignSDK\RequestOptions; use LegalesignSDK\ServiceContracts\TemplatepdfContract; use LegalesignSDK\Services\Templatepdf\FieldsService; @@ -15,12 +14,10 @@ use LegalesignSDK\Templatepdf\TemplatepdfListParams; use LegalesignSDK\Templatepdf\TemplatepdfListResponse; -use const LegalesignSDK\Core\OMIT as omit; - final class TemplatepdfService implements TemplatepdfContract { /** - * @@api + * @api */ public FieldsService $fields; @@ -37,50 +34,24 @@ public function __construct(private Client $client) * * Upload a PDF document you want to send to be signed * - * @param string $group - * @param string $pdfFile base64 encoded PDF file data - * @param bool $archiveUponSend archive PDF when sent - * @param bool $processTags - * @param string $title - * @param string $user assign to group member if not api user + * @param array{ + * group: string, + * pdf_file: string, + * archive_upon_send?: bool, + * process_tags?: bool, + * title?: string, + * user?: string, + * }|TemplatepdfCreateParams $params * * @throws APIException */ public function create( - $group, - $pdfFile, - $archiveUponSend = omit, - $processTags = omit, - $title = omit, - $user = omit, + array|TemplatepdfCreateParams $params, ?RequestOptions $requestOptions = null, - ): mixed { - $params = [ - 'group' => $group, - 'pdfFile' => $pdfFile, - 'archiveUponSend' => $archiveUponSend, - 'processTags' => $processTags, - 'title' => $title, - 'user' => $user, - ]; - - return $this->createRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @throws APIException - */ - public function createRaw( - array $params, - ?RequestOptions $requestOptions = null ): mixed { [$parsed, $options] = TemplatepdfCreateParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -98,30 +69,11 @@ public function createRaw( * * Get PDF template * - * @return TemplatePdf - * * @throws APIException */ public function retrieve( string $pdfID, ?RequestOptions $requestOptions = null - ): TemplatePdf { - $params = []; - - return $this->retrieveRaw($pdfID, $params, $requestOptions); - } - - /** - * @api - * - * @return TemplatePdf - * - * @throws APIException - */ - public function retrieveRaw( - string $pdfID, - mixed $params, - ?RequestOptions $requestOptions = null ): TemplatePdf { // @phpstan-ignore-next-line; return $this->client->request( @@ -137,48 +89,19 @@ public function retrieveRaw( * * Get PDF templates * - * @param string $archive - * @param string $group can be full resource_uri or only id - * @param int $limit Length of dataset to return. Use with offset query to iterate through results. - * @param int $offset Offset from start of dataset. Use with the limit query to iterate through dataset. - * - * @return TemplatepdfListResponse + * @param array{ + * archive?: string, group?: string, limit?: int, offset?: int + * }|TemplatepdfListParams $params * * @throws APIException */ public function list( - $archive = omit, - $group = omit, - $limit = omit, - $offset = omit, - ?RequestOptions $requestOptions = null, - ): TemplatepdfListResponse { - $params = [ - 'archive' => $archive, - 'group' => $group, - 'limit' => $limit, - 'offset' => $offset, - ]; - - return $this->listRaw($params, $requestOptions); - } - - /** - * @api - * - * @param array $params - * - * @return TemplatepdfListResponse - * - * @throws APIException - */ - public function listRaw( - array $params, + array|TemplatepdfListParams $params, ?RequestOptions $requestOptions = null ): TemplatepdfListResponse { [$parsed, $options] = TemplatepdfListParams::parseRequest( $params, - $requestOptions + $requestOptions, ); // @phpstan-ignore-next-line; @@ -201,21 +124,6 @@ public function listRaw( public function getEditLink( string $pdfID, ?RequestOptions $requestOptions = null - ): string { - $params = []; - - return $this->getEditLinkRaw($pdfID, $params, $requestOptions); - } - - /** - * @api - * - * @throws APIException - */ - public function getEditLinkRaw( - string $pdfID, - mixed $params, - ?RequestOptions $requestOptions = null ): string { // @phpstan-ignore-next-line; return $this->client->request( diff --git a/src/Signer/SignerGetFieldsResponseItem.php b/src/Signer/SignerGetFieldsResponseItem.php index 13177db..5679072 100644 --- a/src/Signer/SignerGetFieldsResponseItem.php +++ b/src/Signer/SignerGetFieldsResponseItem.php @@ -9,17 +9,17 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * @phpstan-type signer_get_fields_response_item = array{ + * @phpstan-type SignerGetFieldsResponseItemShape = array{ * fieldorder?: int|null, - * label?: string, - * labelExtra?: string, - * state?: bool, + * label?: string|null, + * label_extra?: string|null, + * state?: bool|null, * value?: string|null, * } */ final class SignerGetFieldsResponseItem implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(nullable: true, optional: true)] @@ -28,8 +28,8 @@ final class SignerGetFieldsResponseItem implements BaseModel #[Api(optional: true)] public ?string $label; - #[Api('label_extra', optional: true)] - public ?string $labelExtra; + #[Api(optional: true)] + public ?string $label_extra; #[Api(optional: true)] public ?bool $state; @@ -53,7 +53,7 @@ public function __construct() public static function with( ?int $fieldorder = null, ?string $label = null, - ?string $labelExtra = null, + ?string $label_extra = null, ?bool $state = null, ?string $value = null, ): self { @@ -61,7 +61,7 @@ public static function with( null !== $fieldorder && $obj->fieldorder = $fieldorder; null !== $label && $obj->label = $label; - null !== $labelExtra && $obj->labelExtra = $labelExtra; + null !== $label_extra && $obj->label_extra = $label_extra; null !== $state && $obj->state = $state; null !== $value && $obj->value = $value; @@ -87,7 +87,7 @@ public function withLabel(string $label): self public function withLabelExtra(string $labelExtra): self { $obj = clone $this; - $obj->labelExtra = $labelExtra; + $obj->label_extra = $labelExtra; return $obj; } diff --git a/src/Signer/SignerGetResponse.php b/src/Signer/SignerGetResponse.php index 023c0ca..c97b0d2 100644 --- a/src/Signer/SignerGetResponse.php +++ b/src/Signer/SignerGetResponse.php @@ -6,49 +6,49 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; /** - * @phpstan-type signer_get_response = array{ - * document?: string, - * email?: string, - * firstName?: string, - * hasFields?: bool, - * lastName?: string, - * order?: int, - * resourceUri?: string, - * status?: value-of, + * @phpstan-type SignerGetResponseShape = array{ + * document?: string|null, + * email?: string|null, + * first_name?: string|null, + * has_fields?: bool|null, + * last_name?: string|null, + * order?: int|null, + * resource_uri?: string|null, + * status?: null|4|5|10|15|20|30|35|39|40|50|60, * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class SignerGetResponse implements BaseModel +final class SignerGetResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?string $document; #[Api(optional: true)] public ?string $email; - #[Api('first_name', optional: true)] - public ?string $firstName; + #[Api(optional: true)] + public ?string $first_name; - #[Api('has_fields', optional: true)] - public ?bool $hasFields; + #[Api(optional: true)] + public ?bool $has_fields; - #[Api('last_name', optional: true)] - public ?string $lastName; + #[Api(optional: true)] + public ?string $last_name; #[Api(optional: true)] public ?int $order; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; /** * Signer status options: @@ -64,7 +64,7 @@ final class SignerGetResponse implements BaseModel * * 50 - downloaded * * 60 - rejected * - * @var value-of|null $status + * @var 4|5|10|15|20|30|35|39|40|50|60|null $status */ #[Api(enum: SignerStatusEnum::class, optional: true)] public ?int $status; @@ -79,28 +79,28 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param SignerStatusEnum|value-of $status + * @param 4|5|10|15|20|30|35|39|40|50|60 $status */ public static function with( ?string $document = null, ?string $email = null, - ?string $firstName = null, - ?bool $hasFields = null, - ?string $lastName = null, + ?string $first_name = null, + ?bool $has_fields = null, + ?string $last_name = null, ?int $order = null, - ?string $resourceUri = null, - SignerStatusEnum|int|null $status = null, + ?string $resource_uri = null, + ?int $status = null, ): self { $obj = new self; null !== $document && $obj->document = $document; null !== $email && $obj->email = $email; - null !== $firstName && $obj->firstName = $firstName; - null !== $hasFields && $obj->hasFields = $hasFields; - null !== $lastName && $obj->lastName = $lastName; + null !== $first_name && $obj->first_name = $first_name; + null !== $has_fields && $obj->has_fields = $has_fields; + null !== $last_name && $obj->last_name = $last_name; null !== $order && $obj->order = $order; - null !== $resourceUri && $obj->resourceUri = $resourceUri; - null !== $status && $obj->status = $status instanceof SignerStatusEnum ? $status->value : $status; + null !== $resource_uri && $obj->resource_uri = $resource_uri; + null !== $status && $obj->status = $status; return $obj; } @@ -124,7 +124,7 @@ public function withEmail(string $email): self public function withFirstName(string $firstName): self { $obj = clone $this; - $obj->firstName = $firstName; + $obj->first_name = $firstName; return $obj; } @@ -132,7 +132,7 @@ public function withFirstName(string $firstName): self public function withHasFields(bool $hasFields): self { $obj = clone $this; - $obj->hasFields = $hasFields; + $obj->has_fields = $hasFields; return $obj; } @@ -140,7 +140,7 @@ public function withHasFields(bool $hasFields): self public function withLastName(string $lastName): self { $obj = clone $this; - $obj->lastName = $lastName; + $obj->last_name = $lastName; return $obj; } @@ -156,7 +156,7 @@ public function withOrder(int $order): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -175,12 +175,12 @@ public function withResourceUri(string $resourceUri): self * * 50 - downloaded * * 60 - rejected * - * @param SignerStatusEnum|value-of $status + * @param 4|5|10|15|20|30|35|39|40|50|60 $status */ - public function withStatus(SignerStatusEnum|int $status): self + public function withStatus(int $status): self { $obj = clone $this; - $obj->status = $status instanceof SignerStatusEnum ? $status->value : $status; + $obj->status = $status; return $obj; } diff --git a/src/Signer/SignerSendReminderParams.php b/src/Signer/SignerSendReminderParams.php index 4696400..101e809 100644 --- a/src/Signer/SignerSendReminderParams.php +++ b/src/Signer/SignerSendReminderParams.php @@ -10,26 +10,15 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new SignerSendReminderParams); // set properties as needed - * $client->signer->sendReminder(...$params->toArray()); - * ``` * Send signer reminder email. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\SignerService::sendReminder() * - * `$client->signer->sendReminder(...$params->toArray());` - * - * @see LegalesignSDK\Signer->sendReminder - * - * @phpstan-type signer_send_reminder_params = array{text?: string} + * @phpstan-type SignerSendReminderParamsShape = array{text?: string} */ final class SignerSendReminderParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/Signer/SignerStatusEnum.php b/src/Signer/SignerStatusEnum.php index 979481f..1d9bc5b 100644 --- a/src/Signer/SignerStatusEnum.php +++ b/src/Signer/SignerStatusEnum.php @@ -20,25 +20,25 @@ */ enum SignerStatusEnum: int { - case SIGNER_STATUS_ENUM_4 = 4; + case _4 = 4; - case SIGNER_STATUS_ENUM_5 = 5; + case _5 = 5; - case SIGNER_STATUS_ENUM_10 = 10; + case _10 = 10; - case SIGNER_STATUS_ENUM_15 = 15; + case _15 = 15; - case SIGNER_STATUS_ENUM_20 = 20; + case _20 = 20; - case SIGNER_STATUS_ENUM_30 = 30; + case _30 = 30; - case SIGNER_STATUS_ENUM_35 = 35; + case _35 = 35; - case SIGNER_STATUS_ENUM_39 = 39; + case _39 = 39; - case SIGNER_STATUS_ENUM_40 = 40; + case _40 = 40; - case SIGNER_STATUS_ENUM_50 = 50; + case _50 = 50; - case SIGNER_STATUS_ENUM_60 = 60; + case _60 = 60; } diff --git a/src/Status/StatusGetResponse.php b/src/Status/StatusGetResponse.php index 25489ea..000be30 100644 --- a/src/Status/StatusGetResponse.php +++ b/src/Status/StatusGetResponse.php @@ -6,37 +6,37 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; use LegalesignSDK\Signer\SignerStatusEnum; /** - * @phpstan-type status_get_response = array{ - * archived?: bool, - * downloadFinal?: bool, - * resourceUri?: string, - * status?: value-of, - * tag?: string, - * tag1?: string, - * tag2?: string, + * @phpstan-type StatusGetResponseShape = array{ + * archived?: bool|null, + * download_final?: bool|null, + * resource_uri?: string|null, + * status?: null|4|5|10|15|20|30|35|39|40|50|60, + * tag?: string|null, + * tag1?: string|null, + * tag2?: string|null, * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class StatusGetResponse implements BaseModel +final class StatusGetResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?bool $archived; - #[Api('download_final', optional: true)] - public ?bool $downloadFinal; + #[Api(optional: true)] + public ?bool $download_final; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; /** * Signer status options: @@ -52,7 +52,7 @@ final class StatusGetResponse implements BaseModel * * 50 - downloaded * * 60 - rejected * - * @var value-of|null $status + * @var 4|5|10|15|20|30|35|39|40|50|60|null $status */ #[Api(enum: SignerStatusEnum::class, optional: true)] public ?int $status; @@ -76,13 +76,13 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param SignerStatusEnum|value-of $status + * @param 4|5|10|15|20|30|35|39|40|50|60 $status */ public static function with( ?bool $archived = null, - ?bool $downloadFinal = null, - ?string $resourceUri = null, - SignerStatusEnum|int|null $status = null, + ?bool $download_final = null, + ?string $resource_uri = null, + ?int $status = null, ?string $tag = null, ?string $tag1 = null, ?string $tag2 = null, @@ -90,9 +90,9 @@ public static function with( $obj = new self; null !== $archived && $obj->archived = $archived; - null !== $downloadFinal && $obj->downloadFinal = $downloadFinal; - null !== $resourceUri && $obj->resourceUri = $resourceUri; - null !== $status && $obj->status = $status instanceof SignerStatusEnum ? $status->value : $status; + null !== $download_final && $obj->download_final = $download_final; + null !== $resource_uri && $obj->resource_uri = $resource_uri; + null !== $status && $obj->status = $status; null !== $tag && $obj->tag = $tag; null !== $tag1 && $obj->tag1 = $tag1; null !== $tag2 && $obj->tag2 = $tag2; @@ -111,7 +111,7 @@ public function withArchived(bool $archived): self public function withDownloadFinal(bool $downloadFinal): self { $obj = clone $this; - $obj->downloadFinal = $downloadFinal; + $obj->download_final = $downloadFinal; return $obj; } @@ -119,7 +119,7 @@ public function withDownloadFinal(bool $downloadFinal): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -138,12 +138,12 @@ public function withResourceUri(string $resourceUri): self * * 50 - downloaded * * 60 - rejected * - * @param SignerStatusEnum|value-of $status + * @param 4|5|10|15|20|30|35|39|40|50|60 $status */ - public function withStatus(SignerStatusEnum|int $status): self + public function withStatus(int $status): self { $obj = clone $this; - $obj->status = $status instanceof SignerStatusEnum ? $status->value : $status; + $obj->status = $status; return $obj; } diff --git a/src/Template/TemplateCreateParams.php b/src/Template/TemplateCreateParams.php index 2aaac1c..71e0505 100644 --- a/src/Template/TemplateCreateParams.php +++ b/src/Template/TemplateCreateParams.php @@ -10,28 +10,17 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new TemplateCreateParams); // set properties as needed - * $client->template->create(...$params->toArray()); - * ``` * Create a new html/text template. This probably isn't the method you are looking for. You can use the 'text' attribute in /document/ to create and send your HTML as a signing document in one call. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\TemplateService::create() * - * `$client->template->create(...$params->toArray());` - * - * @see LegalesignSDK\Template->create - * - * @phpstan-type template_create_params = array{ - * group: string, latestText: string, title: string, user?: string + * @phpstan-type TemplateCreateParamsShape = array{ + * group: string, latest_text: string, title: string, user?: string * } */ final class TemplateCreateParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -41,8 +30,8 @@ final class TemplateCreateParams implements BaseModel /** * text/html for template. */ - #[Api('latest_text')] - public string $latestText; + #[Api] + public string $latest_text; #[Api] public string $title; @@ -58,7 +47,7 @@ final class TemplateCreateParams implements BaseModel * * To enforce required parameters use * ``` - * TemplateCreateParams::with(group: ..., latestText: ..., title: ...) + * TemplateCreateParams::with(group: ..., latest_text: ..., title: ...) * ``` * * Otherwise ensure the following setters are called @@ -79,14 +68,14 @@ public function __construct() */ public static function with( string $group, - string $latestText, + string $latest_text, string $title, ?string $user = null ): self { $obj = new self; $obj->group = $group; - $obj->latestText = $latestText; + $obj->latest_text = $latest_text; $obj->title = $title; null !== $user && $obj->user = $user; @@ -108,7 +97,7 @@ public function withGroup(string $group): self public function withLatestText(string $latestText): self { $obj = clone $this; - $obj->latestText = $latestText; + $obj->latest_text = $latestText; return $obj; } diff --git a/src/Template/TemplateGetResponse.php b/src/Template/TemplateGetResponse.php index 295560f..5823c29 100644 --- a/src/Template/TemplateGetResponse.php +++ b/src/Template/TemplateGetResponse.php @@ -6,32 +6,32 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; /** - * @phpstan-type template_get_response = array{ - * archive?: bool, - * created?: \DateTimeInterface, - * group?: string, - * hasFields?: bool, - * latestText?: string, - * modified?: \DateTimeInterface, - * resourceUri?: string, - * signeeCount?: int, - * title?: string, - * user?: string, - * uuid?: string, + * @phpstan-type TemplateGetResponseShape = array{ + * archive?: bool|null, + * created?: \DateTimeInterface|null, + * group?: string|null, + * has_fields?: bool|null, + * latest_text?: string|null, + * modified?: \DateTimeInterface|null, + * resource_uri?: string|null, + * signee_count?: int|null, + * title?: string|null, + * user?: string|null, + * uuid?: string|null, * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class TemplateGetResponse implements BaseModel +final class TemplateGetResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?bool $archive; @@ -41,20 +41,20 @@ final class TemplateGetResponse implements BaseModel #[Api(optional: true)] public ?string $group; - #[Api('has_fields', optional: true)] - public ?bool $hasFields; + #[Api(optional: true)] + public ?bool $has_fields; - #[Api('latest_text', optional: true)] - public ?string $latestText; + #[Api(optional: true)] + public ?string $latest_text; #[Api(optional: true)] public ?\DateTimeInterface $modified; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; - #[Api('signee_count', optional: true)] - public ?int $signeeCount; + #[Api(optional: true)] + public ?int $signee_count; #[Api(optional: true)] public ?string $title; @@ -79,11 +79,11 @@ public static function with( ?bool $archive = null, ?\DateTimeInterface $created = null, ?string $group = null, - ?bool $hasFields = null, - ?string $latestText = null, + ?bool $has_fields = null, + ?string $latest_text = null, ?\DateTimeInterface $modified = null, - ?string $resourceUri = null, - ?int $signeeCount = null, + ?string $resource_uri = null, + ?int $signee_count = null, ?string $title = null, ?string $user = null, ?string $uuid = null, @@ -93,11 +93,11 @@ public static function with( null !== $archive && $obj->archive = $archive; null !== $created && $obj->created = $created; null !== $group && $obj->group = $group; - null !== $hasFields && $obj->hasFields = $hasFields; - null !== $latestText && $obj->latestText = $latestText; + null !== $has_fields && $obj->has_fields = $has_fields; + null !== $latest_text && $obj->latest_text = $latest_text; null !== $modified && $obj->modified = $modified; - null !== $resourceUri && $obj->resourceUri = $resourceUri; - null !== $signeeCount && $obj->signeeCount = $signeeCount; + null !== $resource_uri && $obj->resource_uri = $resource_uri; + null !== $signee_count && $obj->signee_count = $signee_count; null !== $title && $obj->title = $title; null !== $user && $obj->user = $user; null !== $uuid && $obj->uuid = $uuid; @@ -132,7 +132,7 @@ public function withGroup(string $group): self public function withHasFields(bool $hasFields): self { $obj = clone $this; - $obj->hasFields = $hasFields; + $obj->has_fields = $hasFields; return $obj; } @@ -140,7 +140,7 @@ public function withHasFields(bool $hasFields): self public function withLatestText(string $latestText): self { $obj = clone $this; - $obj->latestText = $latestText; + $obj->latest_text = $latestText; return $obj; } @@ -156,7 +156,7 @@ public function withModified(\DateTimeInterface $modified): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -164,7 +164,7 @@ public function withResourceUri(string $resourceUri): self public function withSigneeCount(int $signeeCount): self { $obj = clone $this; - $obj->signeeCount = $signeeCount; + $obj->signee_count = $signeeCount; return $obj; } diff --git a/src/Template/TemplateListParams.php b/src/Template/TemplateListParams.php index 813f4ef..541056f 100644 --- a/src/Template/TemplateListParams.php +++ b/src/Template/TemplateListParams.php @@ -10,28 +10,17 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new TemplateListParams); // set properties as needed - * $client->template->list(...$params->toArray()); - * ``` * Get text templates. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\TemplateService::list() * - * `$client->template->list(...$params->toArray());` - * - * @see LegalesignSDK\Template->list - * - * @phpstan-type template_list_params = array{ + * @phpstan-type TemplateListParamsShape = array{ * archive?: string, group?: string, limit?: int, offset?: int * } */ final class TemplateListParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/Template/TemplateListResponse.php b/src/Template/TemplateListResponse.php index 2313251..d8a7dde 100644 --- a/src/Template/TemplateListResponse.php +++ b/src/Template/TemplateListResponse.php @@ -6,24 +6,24 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; use LegalesignSDK\Document\ListMeta; use LegalesignSDK\Template\TemplateListResponse\Object1; /** - * @phpstan-type template_list_response = array{ - * meta?: ListMeta, objects?: list + * @phpstan-type TemplateListResponseShape = array{ + * meta?: ListMeta|null, objects?: list|null * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class TemplateListResponse implements BaseModel +final class TemplateListResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?ListMeta $meta; diff --git a/src/Template/TemplateListResponse/Object1.php b/src/Template/TemplateListResponse/Object1.php index 21de3c4..72399bf 100644 --- a/src/Template/TemplateListResponse/Object1.php +++ b/src/Template/TemplateListResponse/Object1.php @@ -9,22 +9,22 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * @phpstan-type object1_alias = array{ - * archive?: bool, - * created?: \DateTimeInterface, - * group?: string, - * hasFields?: bool, - * modified?: \DateTimeInterface, - * resourceUri?: string, - * signeeCount?: int, - * title?: string, - * user?: string, - * uuid?: string, + * @phpstan-type Object1Shape = array{ + * archive?: bool|null, + * created?: \DateTimeInterface|null, + * group?: string|null, + * has_fields?: bool|null, + * modified?: \DateTimeInterface|null, + * resource_uri?: string|null, + * signee_count?: int|null, + * title?: string|null, + * user?: string|null, + * uuid?: string|null, * } */ final class Object1 implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; #[Api(optional: true)] @@ -36,17 +36,17 @@ final class Object1 implements BaseModel #[Api(optional: true)] public ?string $group; - #[Api('has_fields', optional: true)] - public ?bool $hasFields; + #[Api(optional: true)] + public ?bool $has_fields; #[Api(optional: true)] public ?\DateTimeInterface $modified; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; - #[Api('signee_count', optional: true)] - public ?int $signeeCount; + #[Api(optional: true)] + public ?int $signee_count; #[Api(optional: true)] public ?string $title; @@ -71,10 +71,10 @@ public static function with( ?bool $archive = null, ?\DateTimeInterface $created = null, ?string $group = null, - ?bool $hasFields = null, + ?bool $has_fields = null, ?\DateTimeInterface $modified = null, - ?string $resourceUri = null, - ?int $signeeCount = null, + ?string $resource_uri = null, + ?int $signee_count = null, ?string $title = null, ?string $user = null, ?string $uuid = null, @@ -84,10 +84,10 @@ public static function with( null !== $archive && $obj->archive = $archive; null !== $created && $obj->created = $created; null !== $group && $obj->group = $group; - null !== $hasFields && $obj->hasFields = $hasFields; + null !== $has_fields && $obj->has_fields = $has_fields; null !== $modified && $obj->modified = $modified; - null !== $resourceUri && $obj->resourceUri = $resourceUri; - null !== $signeeCount && $obj->signeeCount = $signeeCount; + null !== $resource_uri && $obj->resource_uri = $resource_uri; + null !== $signee_count && $obj->signee_count = $signee_count; null !== $title && $obj->title = $title; null !== $user && $obj->user = $user; null !== $uuid && $obj->uuid = $uuid; @@ -122,7 +122,7 @@ public function withGroup(string $group): self public function withHasFields(bool $hasFields): self { $obj = clone $this; - $obj->hasFields = $hasFields; + $obj->has_fields = $hasFields; return $obj; } @@ -138,7 +138,7 @@ public function withModified(\DateTimeInterface $modified): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -146,7 +146,7 @@ public function withResourceUri(string $resourceUri): self public function withSigneeCount(int $signeeCount): self { $obj = clone $this; - $obj->signeeCount = $signeeCount; + $obj->signee_count = $signeeCount; return $obj; } diff --git a/src/Template/TemplateUpdateParams.php b/src/Template/TemplateUpdateParams.php index b83b325..c9e1a30 100644 --- a/src/Template/TemplateUpdateParams.php +++ b/src/Template/TemplateUpdateParams.php @@ -10,26 +10,15 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new TemplateUpdateParams); // set properties as needed - * $client->template->update(...$params->toArray()); - * ``` * Update text template. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\TemplateService::update() * - * `$client->template->update(...$params->toArray());` - * - * @see LegalesignSDK\Template->update - * - * @phpstan-type template_update_params = array{body: string} + * @phpstan-type TemplateUpdateParamsShape = array{body: string} */ final class TemplateUpdateParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/Templatepdf/Fields/FieldCreateParams.php b/src/Templatepdf/Fields/FieldCreateParams.php index a48e025..19ef548 100644 --- a/src/Templatepdf/Fields/FieldCreateParams.php +++ b/src/Templatepdf/Fields/FieldCreateParams.php @@ -11,26 +11,15 @@ use LegalesignSDK\Templatepdf\Fields\FieldCreateParams\Body; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new FieldCreateParams); // set properties as needed - * $client->templatepdf.fields->create(...$params->toArray()); - * ``` * Replace existing pdf fields with new ones. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\Templatepdf\FieldsService::create() * - * `$client->templatepdf.fields->create(...$params->toArray());` - * - * @see LegalesignSDK\Templatepdf\Fields->create - * - * @phpstan-type field_create_params = array{body: list} + * @phpstan-type FieldCreateParamsShape = array{body: list} */ final class FieldCreateParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/Templatepdf/Fields/FieldCreateParams/Body.php b/src/Templatepdf/Fields/FieldCreateParams/Body.php index 1e1a4b2..1adc09d 100644 --- a/src/Templatepdf/Fields/FieldCreateParams/Body.php +++ b/src/Templatepdf/Fields/FieldCreateParams/Body.php @@ -8,40 +8,38 @@ use LegalesignSDK\Core\Concerns\SdkModel; use LegalesignSDK\Core\Contracts\BaseModel; use LegalesignSDK\Document\PdfFieldValidationEnum; -use LegalesignSDK\Templatepdf\Fields\FieldCreateParams\Body\Align; use LegalesignSDK\Templatepdf\Fields\FieldCreateParams\Body\ElementType; use LegalesignSDK\Templatepdf\Fields\FieldCreateParams\Body\FontName; -use LegalesignSDK\Templatepdf\Fields\FieldCreateParams\Body\LogicAction; /** - * @phpstan-type body_alias = array{ + * @phpstan-type BodyShape = array{ * ax: float, * ay: float, * bx: float, * by: float, - * elementType: value-of, + * element_type: value-of, * page: int, * signer: int, - * align?: value-of|null, + * align?: null|1|2|3, * fieldorder?: int|null, - * fontName?: value-of, - * fontSize?: int, - * hideBorder?: bool, - * label?: string, - * labelExtra?: string, - * logicAction?: value-of, - * logicGroup?: string, - * mapTo?: string, - * optional?: bool, - * options?: string, - * substantive?: bool, - * validation?: value-of|null, - * value?: string, + * font_name?: value-of|null, + * font_size?: int|null, + * hide_border?: bool|null, + * label?: string|null, + * label_extra?: string|null, + * logic_action?: null|1|2|3, + * logic_group?: string|null, + * map_to?: string|null, + * optional?: bool|null, + * options?: string|null, + * substantive?: bool|null, + * validation?: null|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92, + * value?: string|null, * } */ final class Body implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @@ -71,10 +69,10 @@ final class Body implements BaseModel /** * Must be one of the following: * signature - signature field * initials - initials field * text - signer field (field for signer to complete) * admin - sender field (field to complete by admin user when sending, use pdftext). * - * @var value-of $elementType + * @var value-of $element_type */ - #[Api('element_type', enum: ElementType::class)] - public string $elementType; + #[Api(enum: ElementType::class)] + public string $element_type; /** * which page to place field on. @@ -94,9 +92,9 @@ final class Body implements BaseModel * * 2 - middle * * 3 - right * - * @var value-of|null $align + * @var 1|2|3|null $align */ - #[Api(enum: Align::class, nullable: true, optional: true)] + #[Api(nullable: true, optional: true)] public ?int $align; /** @@ -105,15 +103,15 @@ final class Body implements BaseModel #[Api(nullable: true, optional: true)] public ?int $fieldorder; - /** @var value-of|null $fontName */ - #[Api('font_name', enum: FontName::class, optional: true)] - public ?string $fontName; + /** @var value-of|null $font_name */ + #[Api(enum: FontName::class, optional: true)] + public ?string $font_name; - #[Api('font_size', optional: true)] - public ?int $fontSize; + #[Api(optional: true)] + public ?int $font_size; - #[Api('hide_border', optional: true)] - public ?bool $hideBorder; + #[Api(optional: true)] + public ?bool $hide_border; /** * Help a signer/sender understand what to do with the form field. @@ -126,8 +124,8 @@ final class Body implements BaseModel * * unused. more label if required */ - #[Api('label_extra', optional: true)] - public ?string $labelExtra; + #[Api(optional: true)] + public ?string $label_extra; /** * offers options for more advanced forms @@ -135,22 +133,22 @@ final class Body implements BaseModel * 2 = Sum a set of fields * 3 = Conditional upon another field. * - * @var value-of|null $logicAction + * @var 1|2|3|null $logic_action */ - #[Api('logic_action', enum: LogicAction::class, optional: true)] - public ?int $logicAction; + #[Api(optional: true)] + public ?int $logic_action; /** * values to enable a given logic_action in the form. */ - #[Api('logic_group', optional: true)] - public ?string $logicGroup; + #[Api(optional: true)] + public ?string $logic_group; /** * custom data for form integrations. */ - #[Api('map_to', optional: true)] - public ?string $mapTo; + #[Api(optional: true)] + public ?string $map_to; /** * Set true to allow field to be ignored. @@ -254,7 +252,7 @@ final class Body implements BaseModel * * 91 - countries list * * 92 - honorifics list * - * @var value-of|null $validation + * @var 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ #[Api(enum: PdfFieldValidationEnum::class, nullable: true, optional: true)] public ?int $validation; @@ -268,7 +266,7 @@ final class Body implements BaseModel * To enforce required parameters use * ``` * Body::with( - * ax: ..., ay: ..., bx: ..., by: ..., elementType: ..., page: ..., signer: ... + * ax: ..., ay: ..., bx: ..., by: ..., element_type: ..., page: ..., signer: ... * ) * ``` * @@ -295,34 +293,34 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ElementType|value-of $elementType - * @param Align|value-of|null $align - * @param FontName|value-of $fontName - * @param LogicAction|value-of $logicAction - * @param PdfFieldValidationEnum|value-of|null $validation + * @param ElementType|value-of $element_type + * @param 1|2|3|null $align + * @param FontName|value-of $font_name + * @param 1|2|3 $logic_action + * @param 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ public static function with( float $ax, float $ay, float $bx, float $by, - ElementType|string $elementType, + ElementType|string $element_type, int $page, int $signer, - Align|int|null $align = null, + ?int $align = null, ?int $fieldorder = null, - FontName|string|null $fontName = null, - ?int $fontSize = null, - ?bool $hideBorder = null, + FontName|string|null $font_name = null, + ?int $font_size = null, + ?bool $hide_border = null, ?string $label = null, - ?string $labelExtra = null, - LogicAction|int|null $logicAction = null, - ?string $logicGroup = null, - ?string $mapTo = null, + ?string $label_extra = null, + ?int $logic_action = null, + ?string $logic_group = null, + ?string $map_to = null, ?bool $optional = null, ?string $options = null, ?bool $substantive = null, - PdfFieldValidationEnum|int|null $validation = null, + ?int $validation = null, ?string $value = null, ): self { $obj = new self; @@ -331,24 +329,24 @@ public static function with( $obj->ay = $ay; $obj->bx = $bx; $obj->by = $by; - $obj->elementType = $elementType instanceof ElementType ? $elementType->value : $elementType; + $obj['element_type'] = $element_type; $obj->page = $page; $obj->signer = $signer; - null !== $align && $obj->align = $align instanceof Align ? $align->value : $align; + null !== $align && $obj->align = $align; null !== $fieldorder && $obj->fieldorder = $fieldorder; - null !== $fontName && $obj->fontName = $fontName instanceof FontName ? $fontName->value : $fontName; - null !== $fontSize && $obj->fontSize = $fontSize; - null !== $hideBorder && $obj->hideBorder = $hideBorder; + null !== $font_name && $obj['font_name'] = $font_name; + null !== $font_size && $obj->font_size = $font_size; + null !== $hide_border && $obj->hide_border = $hide_border; null !== $label && $obj->label = $label; - null !== $labelExtra && $obj->labelExtra = $labelExtra; - null !== $logicAction && $obj->logicAction = $logicAction instanceof LogicAction ? $logicAction->value : $logicAction; - null !== $logicGroup && $obj->logicGroup = $logicGroup; - null !== $mapTo && $obj->mapTo = $mapTo; + null !== $label_extra && $obj->label_extra = $label_extra; + null !== $logic_action && $obj->logic_action = $logic_action; + null !== $logic_group && $obj->logic_group = $logic_group; + null !== $map_to && $obj->map_to = $map_to; null !== $optional && $obj->optional = $optional; null !== $options && $obj->options = $options; null !== $substantive && $obj->substantive = $substantive; - null !== $validation && $obj->validation = $validation instanceof PdfFieldValidationEnum ? $validation->value : $validation; + null !== $validation && $obj->validation = $validation; null !== $value && $obj->value = $value; return $obj; @@ -406,7 +404,7 @@ public function withBy(float $by): self public function withElementType(ElementType|string $elementType): self { $obj = clone $this; - $obj->elementType = $elementType instanceof ElementType ? $elementType->value : $elementType; + $obj['element_type'] = $elementType; return $obj; } @@ -439,12 +437,12 @@ public function withSigner(int $signer): self * * 2 - middle * * 3 - right * - * @param Align|value-of|null $align + * @param 1|2|3|null $align */ - public function withAlign(Align|int|null $align): self + public function withAlign(?int $align): self { $obj = clone $this; - $obj->align = $align instanceof Align ? $align->value : $align; + $obj->align = $align; return $obj; } @@ -466,7 +464,7 @@ public function withFieldorder(?int $fieldorder): self public function withFontName(FontName|string $fontName): self { $obj = clone $this; - $obj->fontName = $fontName instanceof FontName ? $fontName->value : $fontName; + $obj['font_name'] = $fontName; return $obj; } @@ -474,7 +472,7 @@ public function withFontName(FontName|string $fontName): self public function withFontSize(int $fontSize): self { $obj = clone $this; - $obj->fontSize = $fontSize; + $obj->font_size = $fontSize; return $obj; } @@ -482,7 +480,7 @@ public function withFontSize(int $fontSize): self public function withHideBorder(bool $hideBorder): self { $obj = clone $this; - $obj->hideBorder = $hideBorder; + $obj->hide_border = $hideBorder; return $obj; } @@ -504,7 +502,7 @@ public function withLabel(string $label): self public function withLabelExtra(string $labelExtra): self { $obj = clone $this; - $obj->labelExtra = $labelExtra; + $obj->label_extra = $labelExtra; return $obj; } @@ -515,12 +513,12 @@ public function withLabelExtra(string $labelExtra): self * 2 = Sum a set of fields * 3 = Conditional upon another field. * - * @param LogicAction|value-of $logicAction + * @param 1|2|3 $logicAction */ - public function withLogicAction(LogicAction|int $logicAction): self + public function withLogicAction(int $logicAction): self { $obj = clone $this; - $obj->logicAction = $logicAction instanceof LogicAction ? $logicAction->value : $logicAction; + $obj->logic_action = $logicAction; return $obj; } @@ -531,7 +529,7 @@ public function withLogicAction(LogicAction|int $logicAction): self public function withLogicGroup(string $logicGroup): self { $obj = clone $this; - $obj->logicGroup = $logicGroup; + $obj->logic_group = $logicGroup; return $obj; } @@ -542,7 +540,7 @@ public function withLogicGroup(string $logicGroup): self public function withMapTo(string $mapTo): self { $obj = clone $this; - $obj->mapTo = $mapTo; + $obj->map_to = $mapTo; return $obj; } @@ -664,13 +662,12 @@ public function withSubstantive(bool $substantive): self * * 91 - countries list * * 92 - honorifics list * - * @param PdfFieldValidationEnum|value-of|null $validation + * @param 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ - public function withValidation( - PdfFieldValidationEnum|int|null $validation - ): self { + public function withValidation(?int $validation): self + { $obj = clone $this; - $obj->validation = $validation instanceof PdfFieldValidationEnum ? $validation->value : $validation; + $obj->validation = $validation; return $obj; } diff --git a/src/Templatepdf/Fields/FieldCreateParams/Body/Align.php b/src/Templatepdf/Fields/FieldCreateParams/Body/Align.php deleted file mode 100644 index 0b6dd83..0000000 --- a/src/Templatepdf/Fields/FieldCreateParams/Body/Align.php +++ /dev/null @@ -1,20 +0,0 @@ - + * @phpstan-type FieldListResponseShape = array{ + * meta?: ListMeta|null, objects?: list|null * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class FieldListResponse implements BaseModel +final class FieldListResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?ListMeta $meta; diff --git a/src/Templatepdf/Fields/FieldListResponse/Object1.php b/src/Templatepdf/Fields/FieldListResponse/Object1.php index 163f17a..261594f 100644 --- a/src/Templatepdf/Fields/FieldListResponse/Object1.php +++ b/src/Templatepdf/Fields/FieldListResponse/Object1.php @@ -8,40 +8,38 @@ use LegalesignSDK\Core\Concerns\SdkModel; use LegalesignSDK\Core\Contracts\BaseModel; use LegalesignSDK\Document\PdfFieldValidationEnum; -use LegalesignSDK\Templatepdf\Fields\FieldListResponse\Object1\Align; use LegalesignSDK\Templatepdf\Fields\FieldListResponse\Object1\ElementType; use LegalesignSDK\Templatepdf\Fields\FieldListResponse\Object1\FontName; -use LegalesignSDK\Templatepdf\Fields\FieldListResponse\Object1\LogicAction; /** - * @phpstan-type object1_alias = array{ + * @phpstan-type Object1Shape = array{ * ax: float, * ay: float, * bx: float, * by: float, - * elementType: value-of, + * element_type: value-of, * page: int, * signer: int|null, - * align?: value-of|null, - * fieldorder?: int, - * fontName?: value-of, - * fontSize?: int, - * hideBorder?: bool, - * label?: string, - * labelExtra?: string, - * logicAction?: value-of, - * logicGroup?: string, - * mapTo?: string, - * optional?: bool, - * options?: string, - * substantive?: bool, - * validation?: value-of|null, - * value?: string, + * align?: null|1|2|3, + * fieldorder?: int|null, + * font_name?: value-of|null, + * font_size?: int|null, + * hide_border?: bool|null, + * label?: string|null, + * label_extra?: string|null, + * logic_action?: null|1|2|3, + * logic_group?: string|null, + * map_to?: string|null, + * optional?: bool|null, + * options?: string|null, + * substantive?: bool|null, + * validation?: null|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92, + * value?: string|null, * } */ final class Object1 implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; /** @@ -71,10 +69,10 @@ final class Object1 implements BaseModel /** * Must be one of the following: * signature - signature field * initials - initials field * text - signer field (field for signer to complete) * admin - sender field (field to complete by admin user when sending). * - * @var value-of $elementType + * @var value-of $element_type */ - #[Api('element_type', enum: ElementType::class)] - public string $elementType; + #[Api(enum: ElementType::class)] + public string $element_type; /** * which page to place field on. @@ -94,9 +92,9 @@ final class Object1 implements BaseModel * * 2 - middle * * 3 - right * - * @var value-of|null $align + * @var 1|2|3|null $align */ - #[Api(enum: Align::class, nullable: true, optional: true)] + #[Api(nullable: true, optional: true)] public ?int $align; /** @@ -105,15 +103,15 @@ final class Object1 implements BaseModel #[Api(optional: true)] public ?int $fieldorder; - /** @var value-of|null $fontName */ - #[Api('font_name', enum: FontName::class, optional: true)] - public ?string $fontName; + /** @var value-of|null $font_name */ + #[Api(enum: FontName::class, optional: true)] + public ?string $font_name; - #[Api('font_size', optional: true)] - public ?int $fontSize; + #[Api(optional: true)] + public ?int $font_size; - #[Api('hide_border', optional: true)] - public ?bool $hideBorder; + #[Api(optional: true)] + public ?bool $hide_border; /** * help signer/sender understand what to do. @@ -126,28 +124,28 @@ final class Object1 implements BaseModel * * not in use */ - #[Api('label_extra', optional: true)] - public ?string $labelExtra; + #[Api(optional: true)] + public ?string $label_extra; /** * offers options for more advanced forms 1 = One of a set of field (radio group), 2 = Sum a set of fields, 3 = Conditional upon another field. * - * @var value-of|null $logicAction + * @var 1|2|3|null $logic_action */ - #[Api('logic_action', enum: LogicAction::class, optional: true)] - public ?int $logicAction; + #[Api(optional: true)] + public ?int $logic_action; /** * values to enable a given logic_action in the form. */ - #[Api('logic_group', optional: true)] - public ?string $logicGroup; + #[Api(optional: true)] + public ?string $logic_group; /** * custom data for form integrations. */ - #[Api('map_to', optional: true)] - public ?string $mapTo; + #[Api(optional: true)] + public ?string $map_to; #[Api(optional: true)] public ?bool $optional; @@ -250,7 +248,7 @@ final class Object1 implements BaseModel * * 91 - countries list * * 92 - honorifics list * - * @var value-of|null $validation + * @var 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ #[Api(enum: PdfFieldValidationEnum::class, nullable: true, optional: true)] public ?int $validation; @@ -264,7 +262,7 @@ final class Object1 implements BaseModel * To enforce required parameters use * ``` * Object1::with( - * ax: ..., ay: ..., bx: ..., by: ..., elementType: ..., page: ..., signer: ... + * ax: ..., ay: ..., bx: ..., by: ..., element_type: ..., page: ..., signer: ... * ) * ``` * @@ -291,34 +289,34 @@ public function __construct() * * You must use named parameters to construct any parameters with a default value. * - * @param ElementType|value-of $elementType - * @param Align|value-of|null $align - * @param FontName|value-of $fontName - * @param LogicAction|value-of $logicAction - * @param PdfFieldValidationEnum|value-of|null $validation + * @param ElementType|value-of $element_type + * @param 1|2|3|null $align + * @param FontName|value-of $font_name + * @param 1|2|3 $logic_action + * @param 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ public static function with( float $ax, float $ay, float $bx, float $by, - ElementType|string $elementType, + ElementType|string $element_type, int $page, ?int $signer, - Align|int|null $align = null, + ?int $align = null, ?int $fieldorder = null, - FontName|string|null $fontName = null, - ?int $fontSize = null, - ?bool $hideBorder = null, + FontName|string|null $font_name = null, + ?int $font_size = null, + ?bool $hide_border = null, ?string $label = null, - ?string $labelExtra = null, - LogicAction|int|null $logicAction = null, - ?string $logicGroup = null, - ?string $mapTo = null, + ?string $label_extra = null, + ?int $logic_action = null, + ?string $logic_group = null, + ?string $map_to = null, ?bool $optional = null, ?string $options = null, ?bool $substantive = null, - PdfFieldValidationEnum|int|null $validation = null, + ?int $validation = null, ?string $value = null, ): self { $obj = new self; @@ -327,24 +325,24 @@ public static function with( $obj->ay = $ay; $obj->bx = $bx; $obj->by = $by; - $obj->elementType = $elementType instanceof ElementType ? $elementType->value : $elementType; + $obj['element_type'] = $element_type; $obj->page = $page; $obj->signer = $signer; - null !== $align && $obj->align = $align instanceof Align ? $align->value : $align; + null !== $align && $obj->align = $align; null !== $fieldorder && $obj->fieldorder = $fieldorder; - null !== $fontName && $obj->fontName = $fontName instanceof FontName ? $fontName->value : $fontName; - null !== $fontSize && $obj->fontSize = $fontSize; - null !== $hideBorder && $obj->hideBorder = $hideBorder; + null !== $font_name && $obj['font_name'] = $font_name; + null !== $font_size && $obj->font_size = $font_size; + null !== $hide_border && $obj->hide_border = $hide_border; null !== $label && $obj->label = $label; - null !== $labelExtra && $obj->labelExtra = $labelExtra; - null !== $logicAction && $obj->logicAction = $logicAction instanceof LogicAction ? $logicAction->value : $logicAction; - null !== $logicGroup && $obj->logicGroup = $logicGroup; - null !== $mapTo && $obj->mapTo = $mapTo; + null !== $label_extra && $obj->label_extra = $label_extra; + null !== $logic_action && $obj->logic_action = $logic_action; + null !== $logic_group && $obj->logic_group = $logic_group; + null !== $map_to && $obj->map_to = $map_to; null !== $optional && $obj->optional = $optional; null !== $options && $obj->options = $options; null !== $substantive && $obj->substantive = $substantive; - null !== $validation && $obj->validation = $validation instanceof PdfFieldValidationEnum ? $validation->value : $validation; + null !== $validation && $obj->validation = $validation; null !== $value && $obj->value = $value; return $obj; @@ -402,7 +400,7 @@ public function withBy(float $by): self public function withElementType(ElementType|string $elementType): self { $obj = clone $this; - $obj->elementType = $elementType instanceof ElementType ? $elementType->value : $elementType; + $obj['element_type'] = $elementType; return $obj; } @@ -435,12 +433,12 @@ public function withSigner(?int $signer): self * * 2 - middle * * 3 - right * - * @param Align|value-of|null $align + * @param 1|2|3|null $align */ - public function withAlign(Align|int|null $align): self + public function withAlign(?int $align): self { $obj = clone $this; - $obj->align = $align instanceof Align ? $align->value : $align; + $obj->align = $align; return $obj; } @@ -462,7 +460,7 @@ public function withFieldorder(int $fieldorder): self public function withFontName(FontName|string $fontName): self { $obj = clone $this; - $obj->fontName = $fontName instanceof FontName ? $fontName->value : $fontName; + $obj['font_name'] = $fontName; return $obj; } @@ -470,7 +468,7 @@ public function withFontName(FontName|string $fontName): self public function withFontSize(int $fontSize): self { $obj = clone $this; - $obj->fontSize = $fontSize; + $obj->font_size = $fontSize; return $obj; } @@ -478,7 +476,7 @@ public function withFontSize(int $fontSize): self public function withHideBorder(bool $hideBorder): self { $obj = clone $this; - $obj->hideBorder = $hideBorder; + $obj->hide_border = $hideBorder; return $obj; } @@ -500,7 +498,7 @@ public function withLabel(string $label): self public function withLabelExtra(string $labelExtra): self { $obj = clone $this; - $obj->labelExtra = $labelExtra; + $obj->label_extra = $labelExtra; return $obj; } @@ -508,12 +506,12 @@ public function withLabelExtra(string $labelExtra): self /** * offers options for more advanced forms 1 = One of a set of field (radio group), 2 = Sum a set of fields, 3 = Conditional upon another field. * - * @param LogicAction|value-of $logicAction + * @param 1|2|3 $logicAction */ - public function withLogicAction(LogicAction|int $logicAction): self + public function withLogicAction(int $logicAction): self { $obj = clone $this; - $obj->logicAction = $logicAction instanceof LogicAction ? $logicAction->value : $logicAction; + $obj->logic_action = $logicAction; return $obj; } @@ -524,7 +522,7 @@ public function withLogicAction(LogicAction|int $logicAction): self public function withLogicGroup(string $logicGroup): self { $obj = clone $this; - $obj->logicGroup = $logicGroup; + $obj->logic_group = $logicGroup; return $obj; } @@ -535,7 +533,7 @@ public function withLogicGroup(string $logicGroup): self public function withMapTo(string $mapTo): self { $obj = clone $this; - $obj->mapTo = $mapTo; + $obj->map_to = $mapTo; return $obj; } @@ -654,13 +652,12 @@ public function withSubstantive(bool $substantive): self * * 91 - countries list * * 92 - honorifics list * - * @param PdfFieldValidationEnum|value-of|null $validation + * @param 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|24|25|26|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|90|91|92|null $validation */ - public function withValidation( - PdfFieldValidationEnum|int|null $validation - ): self { + public function withValidation(?int $validation): self + { $obj = clone $this; - $obj->validation = $validation instanceof PdfFieldValidationEnum ? $validation->value : $validation; + $obj->validation = $validation; return $obj; } diff --git a/src/Templatepdf/Fields/FieldListResponse/Object1/Align.php b/src/Templatepdf/Fields/FieldListResponse/Object1/Align.php deleted file mode 100644 index 37b7809..0000000 --- a/src/Templatepdf/Fields/FieldListResponse/Object1/Align.php +++ /dev/null @@ -1,20 +0,0 @@ - */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?\DateTimeInterface $created; @@ -41,8 +41,8 @@ final class TemplatePdf implements BaseModel #[Api(optional: true)] public ?\DateTimeInterface $modified; - #[Api('page_count', optional: true)] - public ?int $pageCount; + #[Api(optional: true)] + public ?int $page_count; /** * JSON stringified array of document parties. @@ -50,11 +50,11 @@ final class TemplatePdf implements BaseModel #[Api(optional: true)] public ?string $parties; - #[Api('resource_uri', optional: true)] - public ?string $resourceUri; + #[Api(optional: true)] + public ?string $resource_uri; - #[Api('signer_count', optional: true)] - public ?int $signerCount; + #[Api(optional: true)] + public ?int $signer_count; #[Api(optional: true)] public ?string $title; @@ -91,10 +91,10 @@ public static function with( ?\DateTimeInterface $created = null, ?string $group = null, ?\DateTimeInterface $modified = null, - ?int $pageCount = null, + ?int $page_count = null, ?string $parties = null, - ?string $resourceUri = null, - ?int $signerCount = null, + ?string $resource_uri = null, + ?int $signer_count = null, ?string $title = null, ?string $user = null, ?string $uuid = null, @@ -105,10 +105,10 @@ public static function with( null !== $created && $obj->created = $created; null !== $group && $obj->group = $group; null !== $modified && $obj->modified = $modified; - null !== $pageCount && $obj->pageCount = $pageCount; + null !== $page_count && $obj->page_count = $page_count; null !== $parties && $obj->parties = $parties; - null !== $resourceUri && $obj->resourceUri = $resourceUri; - null !== $signerCount && $obj->signerCount = $signerCount; + null !== $resource_uri && $obj->resource_uri = $resource_uri; + null !== $signer_count && $obj->signer_count = $signer_count; null !== $title && $obj->title = $title; null !== $user && $obj->user = $user; null !== $uuid && $obj->uuid = $uuid; @@ -144,7 +144,7 @@ public function withModified(\DateTimeInterface $modified): self public function withPageCount(int $pageCount): self { $obj = clone $this; - $obj->pageCount = $pageCount; + $obj->page_count = $pageCount; return $obj; } @@ -163,7 +163,7 @@ public function withParties(string $parties): self public function withResourceUri(string $resourceUri): self { $obj = clone $this; - $obj->resourceUri = $resourceUri; + $obj->resource_uri = $resourceUri; return $obj; } @@ -171,7 +171,7 @@ public function withResourceUri(string $resourceUri): self public function withSignerCount(int $signerCount): self { $obj = clone $this; - $obj->signerCount = $signerCount; + $obj->signer_count = $signerCount; return $obj; } diff --git a/src/Templatepdf/TemplatepdfCreateParams.php b/src/Templatepdf/TemplatepdfCreateParams.php index 536c2ce..f3b5544 100644 --- a/src/Templatepdf/TemplatepdfCreateParams.php +++ b/src/Templatepdf/TemplatepdfCreateParams.php @@ -10,33 +10,22 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new TemplatepdfCreateParams); // set properties as needed - * $client->templatepdf->create(...$params->toArray()); - * ``` * Upload a PDF document you want to send to be signed. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\TemplatepdfService::create() * - * `$client->templatepdf->create(...$params->toArray());` - * - * @see LegalesignSDK\Templatepdf->create - * - * @phpstan-type templatepdf_create_params = array{ + * @phpstan-type TemplatepdfCreateParamsShape = array{ * group: string, - * pdfFile: string, - * archiveUponSend?: bool, - * processTags?: bool, + * pdf_file: string, + * archive_upon_send?: bool, + * process_tags?: bool, * title?: string, * user?: string, * } */ final class TemplatepdfCreateParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; @@ -46,17 +35,17 @@ final class TemplatepdfCreateParams implements BaseModel /** * base64 encoded PDF file data. */ - #[Api('pdf_file')] - public string $pdfFile; + #[Api] + public string $pdf_file; /** * archive PDF when sent. */ - #[Api('archive_upon_send', optional: true)] - public ?bool $archiveUponSend; + #[Api(optional: true)] + public ?bool $archive_upon_send; - #[Api('process_tags', optional: true)] - public ?bool $processTags; + #[Api(optional: true)] + public ?bool $process_tags; #[Api(optional: true)] public ?string $title; @@ -72,7 +61,7 @@ final class TemplatepdfCreateParams implements BaseModel * * To enforce required parameters use * ``` - * TemplatepdfCreateParams::with(group: ..., pdfFile: ...) + * TemplatepdfCreateParams::with(group: ..., pdf_file: ...) * ``` * * Otherwise ensure the following setters are called @@ -93,19 +82,19 @@ public function __construct() */ public static function with( string $group, - string $pdfFile, - ?bool $archiveUponSend = null, - ?bool $processTags = null, + string $pdf_file, + ?bool $archive_upon_send = null, + ?bool $process_tags = null, ?string $title = null, ?string $user = null, ): self { $obj = new self; $obj->group = $group; - $obj->pdfFile = $pdfFile; + $obj->pdf_file = $pdf_file; - null !== $archiveUponSend && $obj->archiveUponSend = $archiveUponSend; - null !== $processTags && $obj->processTags = $processTags; + null !== $archive_upon_send && $obj->archive_upon_send = $archive_upon_send; + null !== $process_tags && $obj->process_tags = $process_tags; null !== $title && $obj->title = $title; null !== $user && $obj->user = $user; @@ -126,7 +115,7 @@ public function withGroup(string $group): self public function withPdfFile(string $pdfFile): self { $obj = clone $this; - $obj->pdfFile = $pdfFile; + $obj->pdf_file = $pdfFile; return $obj; } @@ -137,7 +126,7 @@ public function withPdfFile(string $pdfFile): self public function withArchiveUponSend(bool $archiveUponSend): self { $obj = clone $this; - $obj->archiveUponSend = $archiveUponSend; + $obj->archive_upon_send = $archiveUponSend; return $obj; } @@ -145,7 +134,7 @@ public function withArchiveUponSend(bool $archiveUponSend): self public function withProcessTags(bool $processTags): self { $obj = clone $this; - $obj->processTags = $processTags; + $obj->process_tags = $processTags; return $obj; } diff --git a/src/Templatepdf/TemplatepdfListParams.php b/src/Templatepdf/TemplatepdfListParams.php index 4ef1034..58659c6 100644 --- a/src/Templatepdf/TemplatepdfListParams.php +++ b/src/Templatepdf/TemplatepdfListParams.php @@ -10,28 +10,17 @@ use LegalesignSDK\Core\Contracts\BaseModel; /** - * An object containing the method's parameters. - * Example usage: - * ``` - * $params = (new TemplatepdfListParams); // set properties as needed - * $client->templatepdf->list(...$params->toArray()); - * ``` * Get PDF templates. * - * @method toArray() - * Returns the parameters as an associative array suitable for passing to the client method. + * @see LegalesignSDK\Services\TemplatepdfService::list() * - * `$client->templatepdf->list(...$params->toArray());` - * - * @see LegalesignSDK\Templatepdf->list - * - * @phpstan-type templatepdf_list_params = array{ + * @phpstan-type TemplatepdfListParamsShape = array{ * archive?: string, group?: string, limit?: int, offset?: int * } */ final class TemplatepdfListParams implements BaseModel { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; use SdkParams; diff --git a/src/Templatepdf/TemplatepdfListResponse.php b/src/Templatepdf/TemplatepdfListResponse.php index f96f0ae..7c62d65 100644 --- a/src/Templatepdf/TemplatepdfListResponse.php +++ b/src/Templatepdf/TemplatepdfListResponse.php @@ -6,23 +6,23 @@ use LegalesignSDK\Core\Attributes\Api; use LegalesignSDK\Core\Concerns\SdkModel; +use LegalesignSDK\Core\Concerns\SdkResponse; use LegalesignSDK\Core\Contracts\BaseModel; +use LegalesignSDK\Core\Conversion\Contracts\ResponseConverter; use LegalesignSDK\Document\ListMeta; /** - * @phpstan-type templatepdf_list_response = array{ - * meta?: ListMeta, objects?: list + * @phpstan-type TemplatepdfListResponseShape = array{ + * meta?: ListMeta|null, objects?: list|null * } - * When used in a response, this type parameter can define a $rawResponse property. - * @template TRawResponse of object = object{} - * - * @mixin TRawResponse */ -final class TemplatepdfListResponse implements BaseModel +final class TemplatepdfListResponse implements BaseModel, ResponseConverter { - /** @use SdkModel */ + /** @use SdkModel */ use SdkModel; + use SdkResponse; + #[Api(optional: true)] public ?ListMeta $meta; diff --git a/tests/Services/DocumentTest.php b/tests/Services/DocumentTest.php index a4d390f..4789815 100644 --- a/tests/Services/DocumentTest.php +++ b/tests/Services/DocumentTest.php @@ -3,8 +3,6 @@ namespace Tests\Services; use LegalesignSDK\Client; -use LegalesignSDK\Document\DocumentCreateParams\Signer; -use LegalesignSDK\Document\DocumentCreateParams\Signer\Reviewer; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -35,17 +33,17 @@ public function testCreate(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->document->create( - group: 'https://example.com', - name: 'x', - signers: [ - Signer::with( - email: 'dev@stainless.com', - firstname: 'firstname', - lastname: 'lastname', - ), + $result = $this->client->document->create([ + 'group' => 'https://example.com', + 'name' => 'x', + 'signers' => [ + [ + 'email' => 'dev@stainless.com', + 'firstname' => 'firstname', + 'lastname' => 'lastname', + ], ], - ); + ]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -57,35 +55,35 @@ public function testCreateWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->document->create( - group: 'https://example.com', - name: 'x', - signers: [ - Signer::with( - email: 'dev@stainless.com', - firstname: 'firstname', - lastname: 'lastname', - ) - ->withAttachments(['/api/v1/attachment/IK-GV--w1tvt/']) - ->withBehalfof('behalfof') - ->withDecideLater(true) - ->withExpires(new \DateTimeImmutable('2019-12-27T18:11:19.117Z')) - ->withMessage('message') - ->withOrder(0) - ->withReviewers( + $result = $this->client->document->create([ + 'group' => 'https://example.com', + 'name' => 'x', + 'signers' => [ + [ + 'email' => 'dev@stainless.com', + 'firstname' => 'firstname', + 'lastname' => 'lastname', + 'attachments' => ['/api/v1/attachment/IK-GV--w1tvt/'], + 'behalfof' => 'behalfof', + 'decide_later' => true, + 'expires' => '2019-12-27T18:11:19.117Z', + 'message' => 'message', + 'order' => 0, + 'reviewers' => [ [ - Reviewer::with(email: 'dev@stainless.com') - ->withFirstname('firstname') - ->withIncludeLink(true) - ->withLastname('lastname'), + 'email' => 'dev@stainless.com', + 'firstname' => 'firstname', + 'include_link' => true, + 'lastname' => 'lastname', ], - ) - ->withRole('witness') - ->withSMS('sms') - ->withSubject('subject') - ->withTimezone('timezone'), + ], + 'role' => 'witness', + 'sms' => 'sms', + 'subject' => 'subject', + 'timezone' => 'timezone', + ], ], - ); + ]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -111,7 +109,7 @@ public function testList(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->document->list(group: 'group'); + $result = $this->client->document->list(['group' => 'group']); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -123,7 +121,7 @@ public function testListWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->document->list(group: 'group'); + $result = $this->client->document->list(['group' => 'group']); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } diff --git a/tests/Services/GroupTest.php b/tests/Services/GroupTest.php index 0ea92d2..de58533 100644 --- a/tests/Services/GroupTest.php +++ b/tests/Services/GroupTest.php @@ -33,7 +33,7 @@ public function testCreate(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->group->create(name: 'xxxx'); + $result = $this->client->group->create(['name' => 'xxxx']); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -45,7 +45,7 @@ public function testCreateWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->group->create(name: 'xxxx'); + $result = $this->client->group->create(['name' => 'xxxx']); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -69,7 +69,7 @@ public function testList(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->group->list(); + $result = $this->client->group->list([]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } diff --git a/tests/Services/SignerTest.php b/tests/Services/SignerTest.php index dd279af..3d0001c 100644 --- a/tests/Services/SignerTest.php +++ b/tests/Services/SignerTest.php @@ -69,7 +69,7 @@ public function testSendReminder(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->signer->sendReminder('signerId'); + $result = $this->client->signer->sendReminder('signerId', []); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } diff --git a/tests/Services/TemplateTest.php b/tests/Services/TemplateTest.php index 8a94c25..d991614 100644 --- a/tests/Services/TemplateTest.php +++ b/tests/Services/TemplateTest.php @@ -33,11 +33,11 @@ public function testCreate(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->template->create( - group: '/api/v1/group/IK-GV--w1tvt/', - latestText: 'latest_text', - title: 'title', - ); + $result = $this->client->template->create([ + 'group' => '/api/v1/group/IK-GV--w1tvt/', + 'latest_text' => 'latest_text', + 'title' => 'title', + ]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -49,11 +49,11 @@ public function testCreateWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->template->create( - group: '/api/v1/group/IK-GV--w1tvt/', - latestText: 'latest_text', - title: 'title', - ); + $result = $this->client->template->create([ + 'group' => '/api/v1/group/IK-GV--w1tvt/', + 'latest_text' => 'latest_text', + 'title' => 'title', + ]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -81,7 +81,7 @@ public function testUpdate(): void $result = $this->client->template->update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - 'body' + ['body' => 'body'] ); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType @@ -96,7 +96,7 @@ public function testUpdateWithOptionalParams(): void $result = $this->client->template->update( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - 'body' + ['body' => 'body'] ); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType @@ -109,7 +109,7 @@ public function testList(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->template->list(); + $result = $this->client->template->list([]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } diff --git a/tests/Services/Templatepdf/FieldsTest.php b/tests/Services/Templatepdf/FieldsTest.php index f46147e..2091eef 100644 --- a/tests/Services/Templatepdf/FieldsTest.php +++ b/tests/Services/Templatepdf/FieldsTest.php @@ -3,8 +3,6 @@ namespace Tests\Services\Templatepdf; use LegalesignSDK\Client; -use LegalesignSDK\Document\PdfFieldValidationEnum; -use LegalesignSDK\Templatepdf\Fields\FieldCreateParams\Body; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -38,15 +36,17 @@ public function testCreate(): void $result = $this->client->templatepdf->fields->create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', [ - Body::with( - ax: 0, - ay: 0, - bx: 0, - by: 0, - elementType: 'signature', - page: 0, - signer: 1, - ), + 'body' => [ + [ + 'ax' => 0, + 'ay' => 0, + 'bx' => 0, + 'by' => 0, + 'element_type' => 'signature', + 'page' => 0, + 'signer' => 1, + ], + ], ], ); @@ -63,30 +63,32 @@ public function testCreateWithOptionalParams(): void $result = $this->client->templatepdf->fields->create( '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', [ - Body::with( - ax: 0, - ay: 0, - bx: 0, - by: 0, - elementType: 'signature', - page: 0, - signer: 1, - ) - ->withAlign(1) - ->withFieldorder(0) - ->withFontName('') - ->withFontSize(6) - ->withHideBorder(true) - ->withLabel('label') - ->withLabelExtra('label_extra') - ->withLogicAction(1) - ->withLogicGroup('logic_group') - ->withMapTo('map_to') - ->withOptional(true) - ->withOptions('options') - ->withSubstantive(true) - ->withValidation(PdfFieldValidationEnum::$PDF_FIELD_VALIDATION_ENUM_1) - ->withValue('value'), + 'body' => [ + [ + 'ax' => 0, + 'ay' => 0, + 'bx' => 0, + 'by' => 0, + 'element_type' => 'signature', + 'page' => 0, + 'signer' => 1, + 'align' => 1, + 'fieldorder' => 0, + 'font_name' => '', + 'font_size' => 6, + 'hide_border' => true, + 'label' => 'label', + 'label_extra' => 'label_extra', + 'logic_action' => 1, + 'logic_group' => 'logic_group', + 'map_to' => 'map_to', + 'optional' => true, + 'options' => 'options', + 'substantive' => true, + 'validation' => 1, + 'value' => 'value', + ], + ], ], ); diff --git a/tests/Services/TemplatepdfTest.php b/tests/Services/TemplatepdfTest.php index 9d9f1dd..0248aea 100644 --- a/tests/Services/TemplatepdfTest.php +++ b/tests/Services/TemplatepdfTest.php @@ -33,10 +33,10 @@ public function testCreate(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->templatepdf->create( - group: '/api/v1/group/IK-GV--w1tvt/', - pdfFile: 'U3RhaW5sZXNzIHJvY2tz' - ); + $result = $this->client->templatepdf->create([ + 'group' => '/api/v1/group/IK-GV--w1tvt/', + 'pdf_file' => 'U3RhaW5sZXNzIHJvY2tz', + ]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -48,10 +48,10 @@ public function testCreateWithOptionalParams(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->templatepdf->create( - group: '/api/v1/group/IK-GV--w1tvt/', - pdfFile: 'U3RhaW5sZXNzIHJvY2tz' - ); + $result = $this->client->templatepdf->create([ + 'group' => '/api/v1/group/IK-GV--w1tvt/', + 'pdf_file' => 'U3RhaW5sZXNzIHJvY2tz', + ]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType } @@ -77,7 +77,7 @@ public function testList(): void $this->markTestSkipped('Prism tests are disabled'); } - $result = $this->client->templatepdf->list(); + $result = $this->client->templatepdf->list([]); $this->assertTrue(true); // @phpstan-ignore method.alreadyNarrowedType }