From cb032b2a35fd17cb3f9a646d26afe0d9f5610c5d Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Sun, 13 Oct 2024 00:21:59 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.418.1 --- .speakeasy/gen.lock | 13 ++++--- .speakeasy/gen.yaml | 3 +- .speakeasy/workflow.lock | 12 +++--- RELEASES.md | 12 +++++- composer.json | 3 +- src/Analytics.php | 7 ++-- src/Domains.php | 26 +++++-------- src/Events.php | 7 ++-- src/Links.php | 66 +++++++++++++-------------------- src/Metatags.php | 5 +-- src/QRCodes.php | 5 +-- src/SDKConfiguration.php | 6 +-- src/Tags.php | 22 +++++------ src/Track.php | 21 +++++------ src/Utils/BigDecimalHandler.php | 65 ++++++++++++++++++++++++++++++++ src/Utils/BigIntHandler.php | 65 ++++++++++++++++++++++++++++++++ src/Utils/FormMetadata.php | 4 ++ src/Utils/Headers.php | 12 +++--- src/Utils/JSON.php | 2 + src/Utils/MultipartMetadata.php | 4 ++ src/Utils/ParamsMetadata.php | 4 ++ src/Utils/PathParameters.php | 12 +++--- src/Utils/QueryParameters.php | 22 +++++------ src/Utils/RequestBodies.php | 27 ++++++++------ src/Utils/UnionHandler.php | 2 + src/Utils/Utils.php | 25 +++++++++++-- src/Workspaces.php | 11 ++---- 27 files changed, 305 insertions(+), 158 deletions(-) create mode 100644 src/Utils/BigDecimalHandler.php create mode 100644 src/Utils/BigIntHandler.php diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 03e8c8a..06161c9 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 43187d3e-7c3c-4c11-b5d4-4b2334fb6d96 management: - docChecksum: 8620b0f24a0133906ad7b91d73cc1651 + docChecksum: a31838ebdf42ec2dd03d62aa6a2b788e docVersion: 0.0.1 - speakeasyVersion: 1.410.0 - generationVersion: 2.434.1 - releaseVersion: 0.7.0 - configChecksum: 007f5a8816c52013295fe822a0183d6d + speakeasyVersion: 1.418.1 + generationVersion: 2.438.3 + releaseVersion: 0.8.0 + configChecksum: 1a1e970ef8164057282fa6582c0855fc repoURL: https://github.com/dubinc/dub-php.git installationURL: https://github.com/dubinc/dub-php published: true @@ -22,6 +22,7 @@ features: globalSecurityFlattening: 0.1.1 globalServerURLs: 2.82.1 includes: 2.81.1 + methodArguments: 0.1.0 nameOverrides: 2.81.2 nullables: 1.0.0 responseFormat: 0.1.0 @@ -442,6 +443,8 @@ generatedFiles: - src/SDKConfiguration.php - src/Tags.php - src/Track.php + - src/Utils/BigDecimalHandler.php + - src/Utils/BigIntHandler.php - src/Utils/DateHandler.php - src/Utils/DateTimeHandler.php - src/Utils/DefaultRequest.php diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 6d81d97..ad72e03 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true php: - version: 0.7.0 + version: 0.8.0 clientServerStatusCodesAsErrors: true flattenGlobalSecurity: true imports: @@ -28,6 +28,7 @@ php: enabled: false svcName: openapi maxMethodParams: 4 + methodArguments: infer-optional-args namespace: Dub outputModelSuffix: output packageName: dub/dub-php diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 739c058..022d55a 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.410.0 +speakeasyVersion: 1.418.1 sources: dub: sourceNamespace: dub - sourceRevisionDigest: sha256:1d21d889d6d503cdb0b4c5ec4743e423f9244c7e26d083a87e9e43d427a2a84b - sourceBlobDigest: sha256:bb86fada285bc8f668248f0458c4c2b992a67b17c3e59d839c9d4e5f15850b8a + sourceRevisionDigest: sha256:978cca65ec3e69f5d78ffc261300d951cc69ecf4a916b5c28586ec7d51c1bba8 + sourceBlobDigest: sha256:669f003487611af850e92287f4eaaf8d7ec1c94e336922f2c00a6522f36893e6 tags: - latest - main @@ -11,10 +11,10 @@ targets: my-first-target: source: dub sourceNamespace: dub - sourceRevisionDigest: sha256:1d21d889d6d503cdb0b4c5ec4743e423f9244c7e26d083a87e9e43d427a2a84b - sourceBlobDigest: sha256:bb86fada285bc8f668248f0458c4c2b992a67b17c3e59d839c9d4e5f15850b8a + sourceRevisionDigest: sha256:978cca65ec3e69f5d78ffc261300d951cc69ecf4a916b5c28586ec7d51c1bba8 + sourceBlobDigest: sha256:669f003487611af850e92287f4eaaf8d7ec1c94e336922f2c00a6522f36893e6 codeSamplesNamespace: code-samples-php-my-first-target - codeSamplesRevisionDigest: sha256:52966a6ed9ed3e173e97022eb3f04e60e551372ddd58fe2cbaf96225dffcc4dc + codeSamplesRevisionDigest: sha256:18086347a54be7821c45400d515b694586ef99408fa8847f30cc8cca62806980 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/RELEASES.md b/RELEASES.md index 021e5e4..158d3b7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -300,4 +300,14 @@ Based on: ### Generated - [php v0.7.0] . ### Releases -- [Composer v0.7.0] https://packagist.org/packages/dub/dub-php#v0.7.0 - . \ No newline at end of file +- [Composer v0.7.0] https://packagist.org/packages/dub/dub-php#v0.7.0 - . + +## 2024-10-13 00:20:42 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.418.1 (2.438.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [php v0.8.0] . +### Releases +- [Composer v0.8.0] https://packagist.org/packages/dub/dub-php#v0.8.0 - . \ No newline at end of file diff --git a/composer.json b/composer.json index 430fc20..1949aa7 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "guzzlehttp/guzzle": "^7.0", "speakeasy/serializer": "^3.40.0", "brick/date-time": "^0.7.0", - "phpdocumentor/type-resolver": "^1.8" + "phpdocumentor/type-resolver": "^1.8", + "brick/math": "^0.12.1" }, "require-dev": { "laravel/pint": "^1.18.1", diff --git a/src/Analytics.php b/src/Analytics.php index 8efbf0d..ccf57ac 100644 --- a/src/Analytics.php +++ b/src/Analytics.php @@ -27,13 +27,12 @@ public function __construct(SDKConfiguration $sdkConfig) * * Retrieve analytics for a link, a domain, or the authenticated workspace. The response type depends on the `event` and `type` query parameters. * - * @param Operations\RetrieveAnalyticsRequest $request + * @param ?Operations\RetrieveAnalyticsRequest $request * @return Operations\RetrieveAnalyticsResponse * @throws \Dub\Models\Errors\SDKException */ - public function retrieve( - ?Operations\RetrieveAnalyticsRequest $request, - ): Operations\RetrieveAnalyticsResponse { + public function retrieve(?Operations\RetrieveAnalyticsRequest $request = null): Operations\RetrieveAnalyticsResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/analytics'); $options = ['http_errors' => false]; diff --git a/src/Domains.php b/src/Domains.php index ba18e11..3acb19b 100644 --- a/src/Domains.php +++ b/src/Domains.php @@ -27,13 +27,12 @@ public function __construct(SDKConfiguration $sdkConfig) * * Create a domain for the authenticated workspace. * - * @param Operations\CreateDomainRequestBody $request + * @param ?Operations\CreateDomainRequestBody $request * @return Operations\CreateDomainResponse * @throws \Dub\Models\Errors\SDKException */ - public function create( - ?Operations\CreateDomainRequestBody $request, - ): Operations\CreateDomainResponse { + public function create(?Operations\CreateDomainRequestBody $request = null): Operations\CreateDomainResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/domains'); $options = ['http_errors' => false]; @@ -155,12 +154,8 @@ public function create( * @return Operations\ListDomainsResponse * @throws \Dub\Models\Errors\SDKException */ - public function list( - ?bool $archived = null, - ?string $search = null, - ?float $page = null, - ?float $pageSize = null, - ): Operations\ListDomainsResponse { + public function list(?bool $archived = null, ?string $search = null, ?float $page = null, ?float $pageSize = null): Operations\ListDomainsResponse + { $request = new Operations\ListDomainsRequest( archived: $archived, search: $search, @@ -283,10 +278,8 @@ public function list( * @return Operations\UpdateDomainResponse * @throws \Dub\Models\Errors\SDKException */ - public function update( - string $slug, - ?Operations\UpdateDomainRequestBody $requestBody = null, - ): Operations\UpdateDomainResponse { + public function update(string $slug, ?Operations\UpdateDomainRequestBody $requestBody = null): Operations\UpdateDomainResponse + { $request = new Operations\UpdateDomainRequest( slug: $slug, requestBody: $requestBody, @@ -409,9 +402,8 @@ public function update( * @return Operations\DeleteDomainResponse * @throws \Dub\Models\Errors\SDKException */ - public function delete( - string $slug, - ): Operations\DeleteDomainResponse { + public function delete(string $slug): Operations\DeleteDomainResponse + { $request = new Operations\DeleteDomainRequest( slug: $slug, ); diff --git a/src/Events.php b/src/Events.php index 95e2617..b5a54b2 100644 --- a/src/Events.php +++ b/src/Events.php @@ -27,13 +27,12 @@ public function __construct(SDKConfiguration $sdkConfig) * * Retrieve a paginated list of events for the authenticated workspace. * - * @param Operations\ListEventsRequest $request + * @param ?Operations\ListEventsRequest $request * @return Operations\ListEventsResponse * @throws \Dub\Models\Errors\SDKException */ - public function list( - ?Operations\ListEventsRequest $request, - ): Operations\ListEventsResponse { + public function list(?Operations\ListEventsRequest $request = null): Operations\ListEventsResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/events'); $options = ['http_errors' => false]; diff --git a/src/Links.php b/src/Links.php index 9c84617..c292481 100644 --- a/src/Links.php +++ b/src/Links.php @@ -27,13 +27,12 @@ public function __construct(SDKConfiguration $sdkConfig) * * Create a new link for the authenticated workspace. * - * @param Operations\CreateLinkRequestBody $request + * @param ?Operations\CreateLinkRequestBody $request * @return Operations\CreateLinkResponse * @throws \Dub\Models\Errors\SDKException */ - public function create( - ?Operations\CreateLinkRequestBody $request, - ): Operations\CreateLinkResponse { + public function create(?Operations\CreateLinkRequestBody $request = null): Operations\CreateLinkResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/links'); $options = ['http_errors' => false]; @@ -148,13 +147,12 @@ public function create( * * Retrieve a paginated list of links for the authenticated workspace. * - * @param Operations\GetLinksRequest $request + * @param ?Operations\GetLinksRequest $request * @return Operations\GetLinksResponse * @throws \Dub\Models\Errors\SDKException */ - public function list( - ?Operations\GetLinksRequest $request, - ): Operations\GetLinksResponse { + public function list(?Operations\GetLinksRequest $request = null): Operations\GetLinksResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/links'); $options = ['http_errors' => false]; @@ -266,13 +264,12 @@ public function list( * * Retrieve the number of links for the authenticated workspace. * - * @param Operations\GetLinksCountRequest $request + * @param ?Operations\GetLinksCountRequest $request * @return Operations\GetLinksCountResponse * @throws \Dub\Models\Errors\SDKException */ - public function count( - ?Operations\GetLinksCountRequest $request, - ): Operations\GetLinksCountResponse { + public function count(?Operations\GetLinksCountRequest $request = null): Operations\GetLinksCountResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/links/count'); $options = ['http_errors' => false]; @@ -391,12 +388,8 @@ public function count( * @return Operations\GetLinkInfoResponse * @throws \Dub\Models\Errors\SDKException */ - public function get( - ?string $domain = null, - ?string $key = null, - ?string $linkId = null, - ?string $externalId = null, - ): Operations\GetLinkInfoResponse { + public function get(?string $domain = null, ?string $key = null, ?string $linkId = null, ?string $externalId = null): Operations\GetLinkInfoResponse + { $request = new Operations\GetLinkInfoRequest( domain: $domain, key: $key, @@ -519,10 +512,8 @@ public function get( * @return Operations\UpdateLinkResponse * @throws \Dub\Models\Errors\SDKException */ - public function update( - string $linkId, - ?Operations\UpdateLinkRequestBody $requestBody = null, - ): Operations\UpdateLinkResponse { + public function update(string $linkId, ?Operations\UpdateLinkRequestBody $requestBody = null): Operations\UpdateLinkResponse + { $request = new Operations\UpdateLinkRequest( linkId: $linkId, requestBody: $requestBody, @@ -645,9 +636,8 @@ public function update( * @return Operations\DeleteLinkResponse * @throws \Dub\Models\Errors\SDKException */ - public function delete( - string $linkId, - ): Operations\DeleteLinkResponse { + public function delete(string $linkId): Operations\DeleteLinkResponse + { $request = new Operations\DeleteLinkRequest( linkId: $linkId, ); @@ -761,13 +751,12 @@ public function delete( * * Bulk create up to 100 links for the authenticated workspace. * - * @param array $request + * @param ?array $request * @return Operations\BulkCreateLinksResponse * @throws \Dub\Models\Errors\SDKException */ - public function createMany( - ?array $request, - ): Operations\BulkCreateLinksResponse { + public function createMany(?array $request = null): Operations\BulkCreateLinksResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/links/bulk'); $options = ['http_errors' => false]; @@ -882,13 +871,12 @@ public function createMany( * * Bulk update up to 100 links with the same data for the authenticated workspace. * - * @param Operations\BulkUpdateLinksRequestBody $request + * @param ?Operations\BulkUpdateLinksRequestBody $request * @return Operations\BulkUpdateLinksResponse * @throws \Dub\Models\Errors\SDKException */ - public function updateMany( - ?Operations\BulkUpdateLinksRequestBody $request, - ): Operations\BulkUpdateLinksResponse { + public function updateMany(?Operations\BulkUpdateLinksRequestBody $request = null): Operations\BulkUpdateLinksResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/links/bulk'); $options = ['http_errors' => false]; @@ -1007,9 +995,8 @@ public function updateMany( * @return Operations\BulkDeleteLinksResponse * @throws \Dub\Models\Errors\SDKException */ - public function deleteMany( - array $linkIds, - ): Operations\BulkDeleteLinksResponse { + public function deleteMany(array $linkIds): Operations\BulkDeleteLinksResponse + { $request = new Operations\BulkDeleteLinksRequest( linkIds: $linkIds, ); @@ -1124,13 +1111,12 @@ public function deleteMany( * * Upsert a link for the authenticated workspace by its URL. If a link with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new link will be created. * - * @param Operations\UpsertLinkRequestBody $request + * @param ?Operations\UpsertLinkRequestBody $request * @return Operations\UpsertLinkResponse * @throws \Dub\Models\Errors\SDKException */ - public function upsert( - ?Operations\UpsertLinkRequestBody $request, - ): Operations\UpsertLinkResponse { + public function upsert(?Operations\UpsertLinkRequestBody $request = null): Operations\UpsertLinkResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/links/upsert'); $options = ['http_errors' => false]; diff --git a/src/Metatags.php b/src/Metatags.php index ad33e97..3464a7f 100644 --- a/src/Metatags.php +++ b/src/Metatags.php @@ -31,9 +31,8 @@ public function __construct(SDKConfiguration $sdkConfig) * @return Operations\GetMetatagsResponse * @throws \Dub\Models\Errors\SDKException */ - public function get( - string $url, - ): Operations\GetMetatagsResponse { + public function get(string $url): Operations\GetMetatagsResponse + { $request = new Operations\GetMetatagsRequest( url: $url, ); diff --git a/src/QRCodes.php b/src/QRCodes.php index 6429ded..54e5ca6 100644 --- a/src/QRCodes.php +++ b/src/QRCodes.php @@ -31,9 +31,8 @@ public function __construct(SDKConfiguration $sdkConfig) * @return Operations\GetQRCodeResponse * @throws \Dub\Models\Errors\SDKException */ - public function get( - ?Operations\GetQRCodeRequest $request, - ): Operations\GetQRCodeResponse { + public function get(Operations\GetQRCodeRequest $request): Operations\GetQRCodeResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/qr'); $options = ['http_errors' => false]; diff --git a/src/SDKConfiguration.php b/src/SDKConfiguration.php index efe1e83..997f67c 100644 --- a/src/SDKConfiguration.php +++ b/src/SDKConfiguration.php @@ -27,11 +27,11 @@ class SDKConfiguration public string $openapiDocVersion = '0.0.1'; - public string $sdkVersion = '0.7.0'; + public string $sdkVersion = '0.8.0'; - public string $genVersion = '2.434.1'; + public string $genVersion = '2.438.3'; - public string $userAgent = 'speakeasy-sdk/php 0.7.0 2.434.1 0.0.1 dub/dub-php'; + public string $userAgent = 'speakeasy-sdk/php 0.8.0 2.438.3 0.0.1 dub/dub-php'; public function getServerUrl(): string { diff --git a/src/Tags.php b/src/Tags.php index 4df0ebe..dc47f3e 100644 --- a/src/Tags.php +++ b/src/Tags.php @@ -27,13 +27,12 @@ public function __construct(SDKConfiguration $sdkConfig) * * Create a new tag for the authenticated workspace. * - * @param Operations\CreateTagRequestBody $request + * @param ?Operations\CreateTagRequestBody $request * @return Operations\CreateTagResponse * @throws \Dub\Models\Errors\SDKException */ - public function create( - ?Operations\CreateTagRequestBody $request, - ): Operations\CreateTagResponse { + public function create(?Operations\CreateTagRequestBody $request = null): Operations\CreateTagResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/tags'); $options = ['http_errors' => false]; @@ -151,8 +150,8 @@ public function create( * @return Operations\GetTagsResponse * @throws \Dub\Models\Errors\SDKException */ - public function list( - ): Operations\GetTagsResponse { + public function list(): Operations\GetTagsResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/tags'); $options = ['http_errors' => false]; @@ -268,10 +267,8 @@ public function list( * @return Operations\UpdateTagResponse * @throws \Dub\Models\Errors\SDKException */ - public function update( - string $id, - ?Operations\UpdateTagRequestBody $requestBody = null, - ): Operations\UpdateTagResponse { + public function update(string $id, ?Operations\UpdateTagRequestBody $requestBody = null): Operations\UpdateTagResponse + { $request = new Operations\UpdateTagRequest( id: $id, requestBody: $requestBody, @@ -394,9 +391,8 @@ public function update( * @return Operations\DeleteTagResponse * @throws \Dub\Models\Errors\SDKException */ - public function delete( - string $id, - ): Operations\DeleteTagResponse { + public function delete(string $id): Operations\DeleteTagResponse + { $request = new Operations\DeleteTagRequest( id: $id, ); diff --git a/src/Track.php b/src/Track.php index 0ccb8a4..3131882 100644 --- a/src/Track.php +++ b/src/Track.php @@ -27,13 +27,12 @@ public function __construct(SDKConfiguration $sdkConfig) * * Track a lead for a short link. * - * @param Operations\TrackLeadRequestBody $request + * @param ?Operations\TrackLeadRequestBody $request * @return Operations\TrackLeadResponse * @throws \Dub\Models\Errors\SDKException */ - public function lead( - ?Operations\TrackLeadRequestBody $request, - ): Operations\TrackLeadResponse { + public function lead(?Operations\TrackLeadRequestBody $request = null): Operations\TrackLeadResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/track/lead'); $options = ['http_errors' => false]; @@ -148,13 +147,12 @@ public function lead( * * Track a sale for a short link. * - * @param Operations\TrackSaleRequestBody $request + * @param ?Operations\TrackSaleRequestBody $request * @return Operations\TrackSaleResponse * @throws \Dub\Models\Errors\SDKException */ - public function sale( - ?Operations\TrackSaleRequestBody $request, - ): Operations\TrackSaleResponse { + public function sale(?Operations\TrackSaleRequestBody $request = null): Operations\TrackSaleResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/track/sale'); $options = ['http_errors' => false]; @@ -269,13 +267,12 @@ public function sale( * * Track a customer for an authenticated workspace. * - * @param Operations\TrackCustomerRequestBody $request + * @param ?Operations\TrackCustomerRequestBody $request * @return Operations\TrackCustomerResponse * @throws \Dub\Models\Errors\SDKException */ - public function customer( - ?Operations\TrackCustomerRequestBody $request, - ): Operations\TrackCustomerResponse { + public function customer(?Operations\TrackCustomerRequestBody $request = null): Operations\TrackCustomerResponse + { $baseUrl = $this->sdkConfiguration->getServerUrl(); $url = Utils\Utils::generateUrl($baseUrl, '/track/customer'); $options = ['http_errors' => false]; diff --git a/src/Utils/BigDecimalHandler.php b/src/Utils/BigDecimalHandler.php new file mode 100644 index 0000000..5c9c86d --- /dev/null +++ b/src/Utils/BigDecimalHandler.php @@ -0,0 +1,65 @@ + GraphNavigator::DIRECTION_SERIALIZATION, + 'format' => 'json', + 'type' => '\\Brick\\Math\\BigDecimal', + 'method' => 'serialize', + ], + [ + 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, + 'format' => 'json', + 'type' => '\\Brick\\Math\\BigDecimal', + 'method' => 'deserialize', + ], + [ + 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, + 'format' => 'json', + 'type' => 'Brick\\Math\\BigDecimal', + 'method' => 'serialize', + ], + [ + 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, + 'format' => 'json', + 'type' => 'Brick\\Math\\BigDecimal', + 'method' => 'deserialize', + ], + ]; + } + + /** @phpstan-ignore-next-line */ + public function serialize(JsonSerializationVisitor $visitor, \Brick\Math\BigDecimal|string $any, array $type, Context $context): string|float + { + if (gettype($any) == 'string') { + return $any; + } + + return (float) $any->__toString(); + } + + /** @phpstan-ignore-next-line */ + public function deserialize(JsonDeserializationVisitor $visitor, string|float $data, array $type, Context $context): mixed + { + return \Brick\Math\BigDecimal::of($data); + } +} diff --git a/src/Utils/BigIntHandler.php b/src/Utils/BigIntHandler.php new file mode 100644 index 0000000..9d540a1 --- /dev/null +++ b/src/Utils/BigIntHandler.php @@ -0,0 +1,65 @@ + GraphNavigator::DIRECTION_SERIALIZATION, + 'format' => 'json', + 'type' => '\\Brick\\Math\\BigInteger', + 'method' => 'serialize', + ], + [ + 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, + 'format' => 'json', + 'type' => '\\Brick\\Math\\BigInteger', + 'method' => 'deserialize', + ], + [ + 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, + 'format' => 'json', + 'type' => 'Brick\\Math\\BigInteger', + 'method' => 'serialize', + ], + [ + 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, + 'format' => 'json', + 'type' => 'Brick\\Math\\BigInteger', + 'method' => 'deserialize', + ], + ]; + } + + /** @phpstan-ignore-next-line */ + public function serialize(JsonSerializationVisitor $visitor, \Brick\Math\BigInteger|string $any, array $type, Context $context): string|int + { + if (gettype($any) == 'string') { + return $any; + } + + return (int) $any->toBase(10); + } + + /** @phpstan-ignore-next-line */ + public function deserialize(JsonDeserializationVisitor $visitor, string|int $data, array $type, Context $context): mixed + { + return \Brick\Math\BigInteger::of($data); + } +} diff --git a/src/Utils/FormMetadata.php b/src/Utils/FormMetadata.php index e82e2cf..b745ba2 100644 --- a/src/Utils/FormMetadata.php +++ b/src/Utils/FormMetadata.php @@ -16,6 +16,7 @@ private function __construct( public string $style, public bool $explode, public string $dateTimeFormat, + public bool $serializeToString ) { } @@ -32,6 +33,7 @@ public static function parse(string $metadata): ?FormMetadata $style = 'form'; $explode = true; $dateTimeFormat = ''; + $serializeToString = false; $options = explode(',', $metadata); @@ -47,6 +49,7 @@ public static function parse(string $metadata): ?FormMetadata 'style' => $style = $parts[1], 'explode' => $explode = $parts[1] === 'true', 'dateTimeFormat' => $dateTimeFormat = $parts[1], + 'serializeToString' => $serializeToString = $parts[1] === 'true', default => throw new \RuntimeException('Invalid part'), }; } @@ -57,6 +60,7 @@ public static function parse(string $metadata): ?FormMetadata style: $style, explode: $explode, dateTimeFormat: $dateTimeFormat, + serializeToString: $serializeToString ); } } diff --git a/src/Utils/Headers.php b/src/Utils/Headers.php index 34fc767..a4ef998 100644 --- a/src/Utils/Headers.php +++ b/src/Utils/Headers.php @@ -68,17 +68,17 @@ private function serializeHeader(ParamsMetadata $metadata, mixed $value): string } if ($metadata->explode) { - $items[] = $fieldMetadata->name.'='.valToString($fieldValue, $fieldMetadata->dateTimeFormat); + $items[] = $fieldMetadata->name.'='.valToString($fieldValue, ['dateTimeFormat' => $fieldMetadata->dateTimeFormat]); } else { $items[] = $fieldMetadata->name; - $items[] = valToString($fieldValue, $fieldMetadata->dateTimeFormat); + $items[] = valToString($fieldValue, ['dateTimeFormat' => $fieldMetadata->dateTimeFormat]); } } return implode(',', $items); case 'array': if (array_is_list($value)) { - return implode(',', array_map(fn ($v) => valToString($v), $value)); + return implode(',', array_map(fn ($v) => valToString($v, []), $value)); } else { $items = []; @@ -88,17 +88,17 @@ private function serializeHeader(ParamsMetadata $metadata, mixed $value): string } if ($metadata->explode) { - $items[] = $field.'='.valToString($fieldValue); + $items[] = $field.'='.valToString($fieldValue, []); } else { $items[] = $field; - $items[] = valToString($fieldValue); + $items[] = valToString($fieldValue, []); } } return implode(',', $items); } default: - return valToString($value); + return valToString($value, []); } } diff --git a/src/Utils/JSON.php b/src/Utils/JSON.php index 179015d..36da556 100644 --- a/src/Utils/JSON.php +++ b/src/Utils/JSON.php @@ -31,6 +31,8 @@ static function (HandlerRegistry $registry): void { $registry->registerSubscribingHandler(new DateTimeHandler()); $registry->registerSubscribingHandler(new DateHandler()); $registry->registerSubscribingHandler(new UnionHandler()); + $registry->registerSubscribingHandler(new BigIntHandler()); + $registry->registerSubscribingHandler(new BigDecimalHandler()); }, )->setTypeParser(new PhpDocTypeParser() )->setSerializationContextFactory(function () { diff --git a/src/Utils/MultipartMetadata.php b/src/Utils/MultipartMetadata.php index d4d3b2c..818df50 100644 --- a/src/Utils/MultipartMetadata.php +++ b/src/Utils/MultipartMetadata.php @@ -16,6 +16,7 @@ private function __construct( public bool $content, public bool $json, public string $dateTimeFormat, + public bool $serializeToString ) { } @@ -32,6 +33,7 @@ public static function parse(string $metadata): ?MultipartMetadata $content = false; $json = false; $dateTimeFormat = ''; + $serializeToString = false; $options = explode(',', $metadata); @@ -47,6 +49,7 @@ public static function parse(string $metadata): ?MultipartMetadata 'content' => $content = $parts[1] === 'true', 'json' => $json = $parts[1] === 'true', 'dateTimeFormat' => $dateTimeFormat = $parts[1], + 'serializeToString' => $serializeToString = $parts[1] === 'true', default => throw new \RuntimeException('Failed to parse options.'), }; } @@ -57,6 +60,7 @@ public static function parse(string $metadata): ?MultipartMetadata content: $content, json: $json, dateTimeFormat: $dateTimeFormat, + serializeToString: $serializeToString ); } } diff --git a/src/Utils/ParamsMetadata.php b/src/Utils/ParamsMetadata.php index 47de064..d9de687 100644 --- a/src/Utils/ParamsMetadata.php +++ b/src/Utils/ParamsMetadata.php @@ -17,6 +17,7 @@ private function __construct( public string $name, public string $serialization, public string $dateTimeFormat, + public bool $serializeToString ) { } @@ -36,6 +37,7 @@ public static function parse(string $metadata): ?ParamsMetadata $name = ''; $serialization = ''; $dateTimeFormat = ''; + $serializeToString = false; switch ($type) { case 'queryParam': @@ -66,6 +68,7 @@ public static function parse(string $metadata): ?ParamsMetadata 'explode' => $explode = $parts[1] === 'true', 'serialization' => $serialization = $parts[1], 'dateTimeFormat' => $dateTimeFormat = $parts[1], + 'serializeToString' => $serializeToString = $parts[1] === 'true', default => throw new \RuntimeException('Failed to parse options'), }; } @@ -77,6 +80,7 @@ public static function parse(string $metadata): ?ParamsMetadata name: $name, serialization: $serialization, dateTimeFormat: $dateTimeFormat, + serializeToString: $serializeToString ); } } diff --git a/src/Utils/PathParameters.php b/src/Utils/PathParameters.php index 0262773..914df0d 100644 --- a/src/Utils/PathParameters.php +++ b/src/Utils/PathParameters.php @@ -82,9 +82,9 @@ private function parseSimplePathParams(ParamsMetadata $metadata, mixed $value): } if ($metadata->explode) { - $vals[] = sprintf('%s=%s', $fieldMetadata->name, valToString($fieldValue, $fieldMetadata->dateTimeFormat)); + $vals[] = sprintf('%s=%s', $fieldMetadata->name, valToString($fieldValue, ['dateTimeFormat' => $fieldMetadata->dateTimeFormat])); } else { - $vals[] = sprintf('%s,%s', $fieldMetadata->name, valToString($fieldValue, $fieldMetadata->dateTimeFormat)); + $vals[] = sprintf('%s,%s', $fieldMetadata->name, valToString($fieldValue, ['dateTimeFormat' => $fieldMetadata->dateTimeFormat])); } } @@ -95,14 +95,14 @@ private function parseSimplePathParams(ParamsMetadata $metadata, mixed $value): if (array_is_list($value)) { foreach ($value as $val) { - $vals[] = valToString($val); + $vals[] = valToString($val, []); } } else { foreach ($value as $key => $val) { if ($metadata->explode) { - $vals[] = sprintf('%s=%s', $key, valToString($val)); + $vals[] = sprintf('%s=%s', $key, valToString($val, [])); } else { - $vals[] = sprintf('%s,%s', $key, valToString($val)); + $vals[] = sprintf('%s,%s', $key, valToString($val, [])); } } } @@ -110,7 +110,7 @@ private function parseSimplePathParams(ParamsMetadata $metadata, mixed $value): $pathParams[$metadata->name] = implode(',', $vals); break; default: - $pathParams[$metadata->name] = valToString($value); + $pathParams[$metadata->name] = valToString($value, []); break; } diff --git a/src/Utils/QueryParameters.php b/src/Utils/QueryParameters.php index aa8361a..3e577d9 100644 --- a/src/Utils/QueryParameters.php +++ b/src/Utils/QueryParameters.php @@ -110,10 +110,10 @@ private function parseDeepObjectParams(ParamsMetadata $metadata, mixed $value): if (is_array($val) && array_is_list($val)) { foreach ($val as $item) { - $items[] = valToString($item, $dateTimeFormat); + $items[] = valToString($item, ['dateTimeFormat' => $dateTimeFormat]); } } else { - $queryParams[$metadata->name.'['.$fieldMetaData->name.']'] = valToString($val, $dateTimeFormat); + $queryParams[$metadata->name.'['.$fieldMetaData->name.']'] = valToString($val, ['dateTimeFormat' => $dateTimeFormat]); } if (count($items) > 0) { @@ -132,10 +132,10 @@ private function parseDeepObjectParams(ParamsMetadata $metadata, mixed $value): if (is_array($val) && array_is_list($val)) { foreach ($val as $item) { - $items[] = valToString($item, $dateTimeFormat); + $items[] = valToString($item, ['dateTimeFormat' => $dateTimeFormat]); } } else { - $queryParams[$metadata->name.'['.$key.']'] = valToString($val, $dateTimeFormat); + $queryParams[$metadata->name.'['.$key.']'] = valToString($val, ['dateTimeFormat' => $dateTimeFormat]); } if (count($items) > 0) { @@ -178,9 +178,9 @@ private function parseDelimitedParams(ParamsMetadata $metadata, mixed $value, st $dateTimeFormat = $fieldMetaData->dateTimeFormat; if ($metadata->explode) { - $queryParams[$fieldMetaData->name] = valToString($val, $dateTimeFormat); + $queryParams[$fieldMetaData->name] = valToString($val, ['dateTimeFormat' => $dateTimeFormat]); } else { - $items[] = $fieldMetaData->name.$delimiter.valToString($val, $dateTimeFormat); + $items[] = $fieldMetaData->name.$delimiter.valToString($val, ['dateTimeFormat' => $dateTimeFormat]); } } @@ -195,9 +195,9 @@ private function parseDelimitedParams(ParamsMetadata $metadata, mixed $value, st foreach ($value as $item) { if ($metadata->explode) { - $values[] = valToString($item, $dateTimeFormat); + $values[] = valToString($item, ['dateTimeFormat' => $dateTimeFormat]); } else { - $items[] = valToString($item, $dateTimeFormat); + $items[] = valToString($item, ['dateTimeFormat' => $dateTimeFormat]); } } @@ -215,9 +215,9 @@ private function parseDelimitedParams(ParamsMetadata $metadata, mixed $value, st } if ($metadata->explode) { - $queryParams[$key] = valToString($val, $dateTimeFormat); + $queryParams[$key] = valToString($val, ['dateTimeFormat' => $dateTimeFormat]); } else { - $items[] = $key.$delimiter.valToString($val, $dateTimeFormat); + $items[] = $key.$delimiter.valToString($val, ['dateTimeFormat' => $dateTimeFormat]); } } @@ -227,7 +227,7 @@ private function parseDelimitedParams(ParamsMetadata $metadata, mixed $value, st } break; default: - $queryParams[$metadata->name] = valToString($value, $dateTimeFormat); + $queryParams[$metadata->name] = valToString($value, ['dateTimeFormat' => $dateTimeFormat]); } return $this->buildQueryString($queryParams); diff --git a/src/Utils/RequestBodies.php b/src/Utils/RequestBodies.php index 6e1209f..62e8ca4 100644 --- a/src/Utils/RequestBodies.php +++ b/src/Utils/RequestBodies.php @@ -122,13 +122,13 @@ private function serializeMultipart(mixed $value): array foreach ($value as $item) { $options['multipart'][] = [ 'name' => $metadata->name.'[]', - 'contents' => valToString($item, $dateTimeFormat), + 'contents' => valToString($item, ['dateTimeFormat' => $dateTimeFormat]), ]; } } else { $options['multipart'][] = [ 'name' => $metadata->name, - 'contents' => valToString($val, $dateTimeFormat), + 'contents' => valToString($val, ['dateTimeFormat' => $dateTimeFormat]), ]; } } @@ -225,7 +225,7 @@ private function serializeFormData(string $fieldName, mixed $value): array throw new \Exception("Invalid request body type for field $fieldName"); } else { foreach ($value as $k => $v) { - $options['form_params'][$k] = valToString($v); + $options['form_params'][$k] = valToString($v, []); } } break; @@ -246,17 +246,22 @@ private function serializeForm(FormMetadata $metadata, mixed $value): array $values = []; $dateTimeFormat = $metadata->dateTimeFormat; + $serializeToString = $metadata->serializeToString; switch (gettype($value)) { case 'object': switch ($value::class) { case 'Brick\DateTime\LocalDate': case 'DateTime': - $values[$metadata->name] = valToString($value, $dateTimeFormat); + $values[$metadata->name] = valToString($value, ['dateTimeFormat' => $dateTimeFormat]); + break; + case 'Brick\Math\BigInteger': + case 'Brick\Math\BigDecimal': + $values[$metadata->name] = valToString($value, ['serializeToString' => $serializeToString]); break; default: if (is_a($value, \BackedEnum::class, true)) { - $values[$metadata->name] = valToString($value); + $values[$metadata->name] = valToString($value, []); } else { $items = []; @@ -271,9 +276,9 @@ private function serializeForm(FormMetadata $metadata, mixed $value): array } if ($metadata->explode) { - $values[$fieldMetadata->name] = valToString($val, $fieldMetadata->dateTimeFormat); + $values[$fieldMetadata->name] = valToString($val, ['dateTimeFormat' => $fieldMetadata->dateTimeFormat]); } else { - $items[] = sprintf('%s,%s', $fieldMetadata->name, valToString($val)); + $items[] = sprintf('%s,%s', $fieldMetadata->name, valToString($val, [])); } } @@ -287,16 +292,16 @@ private function serializeForm(FormMetadata $metadata, mixed $value): array case 'array': if (array_is_list($value)) { foreach ($value as $v) { - $values[$metadata->name] = valToString($v, $dateTimeFormat); + $values[$metadata->name] = valToString($v, ['dateTimeFormat' => $dateTimeFormat]); } } else { $items = []; foreach ($value as $k => $v) { if ($metadata->explode) { - $values[$k] = valToString($v, $dateTimeFormat); + $values[$k] = valToString($v, ['dateTimeFormat' => $dateTimeFormat]); } else { - $items[] = sprintf('%s,%s', $k, valToString($v, $dateTimeFormat)); + $items[] = sprintf('%s,%s', $k, valToString($v, ['dateTimeFormat' => $dateTimeFormat])); } } @@ -306,7 +311,7 @@ private function serializeForm(FormMetadata $metadata, mixed $value): array } break; default: - $values[$metadata->name] = valToString($value, $dateTimeFormat); + $values[$metadata->name] = valToString($value, ['dateTimeFormat' => $dateTimeFormat]); break; } diff --git a/src/Utils/UnionHandler.php b/src/Utils/UnionHandler.php index c2fa5cb..89cea89 100644 --- a/src/Utils/UnionHandler.php +++ b/src/Utils/UnionHandler.php @@ -188,6 +188,8 @@ public function deserializeUnion(DeserializationVisitorInterface $visitor, mixed continue; } catch (NonFloatCastableTypeException $e) { continue; + } catch (\Brick\Math\Exception\NumberFormatException $e) { + continue; } catch (RuntimeException $e) { continue; } diff --git a/src/Utils/Utils.php b/src/Utils/Utils.php index 0646ce4..be519f7 100644 --- a/src/Utils/Utils.php +++ b/src/Utils/Utils.php @@ -194,8 +194,12 @@ function removeSuffix(string $text, string $suffix): string return $text; } - -function valToString(mixed $val, string $dateTimeFormat = ''): string +/** + * @param mixed $val + * @param array $extras + * @return string + */ +function valToString(mixed $val, array $extras): string { switch (gettype($val)) { case 'string': @@ -203,13 +207,26 @@ function valToString(mixed $val, string $dateTimeFormat = ''): string case 'object': switch (get_class($val)) { case 'DateTime': - if (empty($dateTimeFormat)) { - $dateTimeFormat = 'Y-m-d\TH:i:s.up'; + $dateTimeFormat = $dateTimeFormat = 'Y-m-d\TH:i:s.up'; + if (array_key_exists('dateTimeFormat', $extras)) { + $dateTimeFormat = $extras['dateTimeFormat']; } return $val->format($dateTimeFormat); case 'Brick\DateTime\LocalDate': return $val->jsonSerialize(); + case 'Brick\Math\BigInteger': + if (array_key_exists('serializeToString', $extras) && $extras['serializeToString']) { + return '"'.$val->toBase(10).'"'; + } + + return $val->toBase(10); + case 'Brick\Math\BigDecimal': + if (array_key_exists('serializeToString', $extras) && $extras['serializeToString']) { + return '"'.$val->__toString().'"'; + } + + return $val->__toString(); default: if (is_a($val, \BackedEnum::class, true)) { $enumVal = $val->value; diff --git a/src/Workspaces.php b/src/Workspaces.php index e6b59e5..dc664ad 100644 --- a/src/Workspaces.php +++ b/src/Workspaces.php @@ -31,9 +31,8 @@ public function __construct(SDKConfiguration $sdkConfig) * @return Operations\GetWorkspaceResponse * @throws \Dub\Models\Errors\SDKException */ - public function get( - string $idOrSlug, - ): Operations\GetWorkspaceResponse { + public function get(string $idOrSlug): Operations\GetWorkspaceResponse + { $request = new Operations\GetWorkspaceRequest( idOrSlug: $idOrSlug, ); @@ -152,10 +151,8 @@ public function get( * @return Operations\UpdateWorkspaceResponse * @throws \Dub\Models\Errors\SDKException */ - public function update( - string $idOrSlug, - ?Operations\UpdateWorkspaceRequestBody $requestBody = null, - ): Operations\UpdateWorkspaceResponse { + public function update(string $idOrSlug, ?Operations\UpdateWorkspaceRequestBody $requestBody = null): Operations\UpdateWorkspaceResponse + { $request = new Operations\UpdateWorkspaceRequest( idOrSlug: $idOrSlug, requestBody: $requestBody,