diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 8dde7a9..16265a9 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: 2.0.0 id: 0e1578f5-5df8-4086-96d6-369ac62fc49d management: - docChecksum: 5a3c61710af05ae5c21380b118217322 + docChecksum: 6385e11ae594d46afc1910ffab8d003a docVersion: 10.8.3 - speakeasyVersion: 1.453.0 - generationVersion: 2.472.1 - releaseVersion: 0.0.3 - configChecksum: dac14721849799a0fe7ba3949bcc1164 + speakeasyVersion: 1.454.0 + generationVersion: 2.477.0 + releaseVersion: 0.0.4 + configChecksum: c3a2f196fe8dd693b6d6914e96dab69a repoURL: https://github.com/apideck-libraries/sdk-php.git installationURL: https://github.com/apideck-libraries/sdk-php published: true features: php: constsAndDefaults: 0.2.0 - core: 3.7.3 + core: 3.7.4 deprecations: 2.81.1 errors: 0.3.0 flattening: 2.81.1 @@ -1438,6 +1438,7 @@ generatedFiles: - src/Hooks/AfterSuccessHook.php - src/Hooks/BeforeRequestContext.php - src/Hooks/BeforeRequestHook.php + - src/Hooks/Credentials.php - src/Hooks/ErrorResponseContext.php - src/Hooks/FailEarlyException.php - src/Hooks/HookContext.php @@ -1445,6 +1446,8 @@ generatedFiles: - src/Hooks/SDKHooks.php - src/Hooks/SDKInitHook.php - src/Hooks/SDKRequestContext.php + - src/Hooks/Session.php + - src/Hooks/TokenResponse.php - src/Hris.php - src/InvoiceItems.php - src/Invoices.php @@ -9088,7 +9091,7 @@ examples: "422": application/json: {"status_code": 422, "error": "Unprocessable Entity", "type_name": "InvalidStateError", "message": "Invalid State", "detail": "Unprocessable request, please verify your request headers and body.", "ref": "https://developers.apideck.com/errors#invalidstateerror"} default: - application/json: {"status_code": 400, "error": "Bad Request", "type_name": "RequestHeadersValidationError", "message": "Invalid Params", "detail": {"missing": [{"x-apideck-consumer-id": "required"}]}, "ref": "https://developers.apideck.com/errors#unauthorizederror"} + application/json: {"status_code": 400, "error": "Bad Request", "type_name": "RequestHeadersValidationError", "message": "Invalid Params", "detail": "Missing Header: x-apideck-consumer-id", "ref": "https://developers.apideck.com/errors#unauthorizederror"} vault.validateConnectionState: "": parameters: @@ -9110,7 +9113,7 @@ examples: "404": application/json: {"status_code": 404, "error": "Not Found", "type_name": "EntityNotFoundError", "message": "Unknown Widget", "detail": "Could not find widget with id: '123'", "ref": "https://developers.apideck.com/errors#entitynotfounderror"} "422": - application/json: {"status_code": 422, "error": "Unprocessable Entity", "type_name": "InvalidStateError", "message": "Invalid State", "detail": {"error": "Unprocessable", "message": "Unprocessable request, please verify your request headers and body."}, "ref": "https://developers.apideck.com/errors#invalidstateerror"} + application/json: {"status_code": 422, "error": "Unprocessable Entity", "type_name": "InvalidStateError", "message": "Invalid State", "detail": "Unprocessable request, please verify your request headers and body.", "ref": "https://developers.apideck.com/errors#invalidstateerror"} default: application/json: {"status_code": 400, "error": "Bad Request", "type_name": "RequestHeadersValidationError", "message": "Invalid Params", "detail": {"missing": [{"x-apideck-consumer-id": "required"}]}, "ref": "https://developers.apideck.com/errors#unauthorizederror"} vault.createCallbackState: @@ -9136,7 +9139,7 @@ examples: "404": application/json: {"status_code": 404, "error": "Not Found", "type_name": "EntityNotFoundError", "message": "Unknown Widget", "detail": "Could not find widget with id: '123'", "ref": "https://developers.apideck.com/errors#entitynotfounderror"} "422": - application/json: {"status_code": 422, "error": "Unprocessable Entity", "type_name": "InvalidStateError", "message": "Invalid State", "detail": {"error": "Unprocessable", "message": "Unprocessable request, please verify your request headers and body."}, "ref": "https://developers.apideck.com/errors#invalidstateerror"} + application/json: {"status_code": 422, "error": "Unprocessable Entity", "type_name": "InvalidStateError", "message": "Invalid State", "detail": "Unprocessable request, please verify your request headers and body.", "ref": "https://developers.apideck.com/errors#invalidstateerror"} default: application/json: {"status_code": 400, "error": "Bad Request", "type_name": "RequestHeadersValidationError", "message": "Invalid Params", "detail": {"missing": [{"x-apideck-consumer-id": "required"}]}, "ref": "https://developers.apideck.com/errors#unauthorizederror"} vault.connectionSettingsAll: diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 35b0aec..7b60edc 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -13,7 +13,12 @@ generation: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: true php: - version: 0.0.3 + version: 0.0.4 + additionalDependencies: + autoload: {} + autoload-dev: {} + require: {} + require-dev: {} clientServerStatusCodesAsErrors: true defaultErrorName: APIException flattenGlobalSecurity: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 73afe29..f304b04 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.453.0 +speakeasyVersion: 1.454.0 sources: Apideck: sourceNamespace: apideck - sourceRevisionDigest: sha256:0b5c1d9084456845b39928c8770817584e9e6b460f251fa25ba6a52f2cd5b584 - sourceBlobDigest: sha256:c78223a6f6e3fb5b1d9f0d663d8bd72bf35ecc3ed8435dd81561c45569a9f642 + sourceRevisionDigest: sha256:1c2ab08139231ee4ce3aa2e75d21f8660b997b38a72c8508f2e010f1e4f01212 + sourceBlobDigest: sha256:86718b5c608b0821aa024e8ed3a416e4347cbac957b0e241d46daf111903fdc0 tags: - latest - - speakeasy-sdk-regen-1733502108 + - speakeasy-sdk-regen-1733922060 - 10.8.3 targets: apideck: source: Apideck sourceNamespace: apideck - sourceRevisionDigest: sha256:0b5c1d9084456845b39928c8770817584e9e6b460f251fa25ba6a52f2cd5b584 - sourceBlobDigest: sha256:c78223a6f6e3fb5b1d9f0d663d8bd72bf35ecc3ed8435dd81561c45569a9f642 + sourceRevisionDigest: sha256:1c2ab08139231ee4ce3aa2e75d21f8660b997b38a72c8508f2e010f1e4f01212 + sourceBlobDigest: sha256:86718b5c608b0821aa024e8ed3a416e4347cbac957b0e241d46daf111903fdc0 codeSamplesNamespace: apideck-php-code-samples - codeSamplesRevisionDigest: sha256:7d5b42a9f7fc00e6906f6d824349da197434acf00cda00270de112a3c14be53e + codeSamplesRevisionDigest: sha256:54aa4c61991565aef222572e6c223e47e2e0c78fc8299e4db4f8c2700e435596 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/RELEASES.md b/RELEASES.md index 7e8a4e1..c656f6b 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -8,4 +8,14 @@ Based on: ### Generated - [php v0.0.3] . ### Releases -- [Composer v0.0.3] https://packagist.org/packages/apideck-libraries/sdk-php#v0.0.3 - . \ No newline at end of file +- [Composer v0.0.3] https://packagist.org/packages/apideck-libraries/sdk-php#v0.0.3 - . + +## 2024-12-11 14:16:31 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.454.0 (2.477.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [php v0.0.4] . +### Releases +- [Composer v0.0.4] https://packagist.org/packages/apideck-libraries/sdk-php#v0.0.4 - . \ No newline at end of file diff --git a/src/Hooks/AfterErrorContext.php b/src/Hooks/AfterErrorContext.php index aba2695..65868dc 100644 --- a/src/Hooks/AfterErrorContext.php +++ b/src/Hooks/AfterErrorContext.php @@ -15,4 +15,18 @@ public function __construct(HookContext $hookCtx) { parent::__construct($hookCtx->operationID, $hookCtx->oauth2Scopes, $hookCtx->securitySource); } + + /** + * @param string $name + * @param array $args + * @return mixed + */ + public function __call($name, $args): mixed + { + if ($name === 'securitySource') { + return call_user_func_array($this->securitySource, $args); + } + + return null; + } } diff --git a/src/Hooks/BeforeRequestContext.php b/src/Hooks/BeforeRequestContext.php index c6a784d..1005bc8 100644 --- a/src/Hooks/BeforeRequestContext.php +++ b/src/Hooks/BeforeRequestContext.php @@ -15,4 +15,18 @@ public function __construct(HookContext $hookCtx) { parent::__construct($hookCtx->operationID, $hookCtx->oauth2Scopes, $hookCtx->securitySource); } + + /** + * @param string $name + * @param array $args + * @return mixed + */ + public function __call($name, $args): mixed + { + if ($name === 'securitySource') { + return call_user_func_array($this->securitySource, $args); + } + + return null; + } } diff --git a/src/Hooks/Credentials.php b/src/Hooks/Credentials.php new file mode 100644 index 0000000..cde26a4 --- /dev/null +++ b/src/Hooks/Credentials.php @@ -0,0 +1,24 @@ +clientID = $clientID; + $this->clientSecret = $clientSecret; + $this->tokenURL = $tokenURL; + } +} diff --git a/src/Hooks/HookContext.php b/src/Hooks/HookContext.php index 46962e6..d0bcf4c 100644 --- a/src/Hooks/HookContext.php +++ b/src/Hooks/HookContext.php @@ -35,4 +35,17 @@ public function __construct(string $operationID, ?array $oauth2Scopes, ?\Closure $this->oauth2Scopes = $oauth2Scopes; $this->securitySource = $securitySource; } + /** + * @param string $name + * @param array $args + * @return mixed + */ + public function __call($name, $args): mixed + { + if ($name === 'securitySource') { + return call_user_func_array($this->securitySource, $args); + } + + return null; + } } diff --git a/src/Hooks/Session.php b/src/Hooks/Session.php new file mode 100644 index 0000000..e479a63 --- /dev/null +++ b/src/Hooks/Session.php @@ -0,0 +1,37 @@ + scopes + */ + public array $scopes; + public ?LocalTime $expiresAt; + + /** + * @param Credentials $credentials + * @param string $token + * @param array $scopes + * @param ?LocalTime $expiresAt + */ + public function __construct(Credentials $credentials, string $token, array $scopes, ?LocalTime $expiresAt = null) + { + $this->credentials = $credentials; + $this->token = $token; + $this->scopes = $scopes; + $this->expiresAt = $expiresAt; + } +} diff --git a/src/Hooks/TokenResponse.php b/src/Hooks/TokenResponse.php new file mode 100644 index 0000000..19b008c --- /dev/null +++ b/src/Hooks/TokenResponse.php @@ -0,0 +1,17 @@ +>> */ public ?array $globals = [ 'parameters' => [], diff --git a/src/Utils/Utils.php b/src/Utils/Utils.php index 442d044..6377f03 100644 --- a/src/Utils/Utils.php +++ b/src/Utils/Utils.php @@ -251,6 +251,111 @@ public static function removeHeaders(RequestInterface $request): RequestInterfac return $request; } + /** + * urljoin joins a base URL and a relative URL. + * this is a PHP port of the Python urllib.urljoin function + * + * @param string $base + * @param string $rel + * @return string + */ + public static function urljoin(string $base, string $rel): string + { + $pbase = parse_url($base); + if ($pbase === false) { + throw new \InvalidArgumentException('Invalid base URL: '.$base); + } else { + $pbase = (array) $pbase; + } + $prel = parse_url($rel); + if ($prel === false) { + throw new \InvalidArgumentException('Invalid relative URL: '.$rel); + } else { + $prel = (array) $prel; + } + + $merged = array_merge($pbase, $prel); + if (array_key_exists('path', $pbase) && array_key_exists('path', $prel) && $prel['path'][0] != '/') { + // Relative path + $dir = preg_replace('@/[^/]*$@', '', $pbase['path']); + $merged['path'] = $dir.'/'.$prel['path']; + } elseif (array_key_exists('path', $pbase)) { + $merged['path'] = $pbase['path']; + } elseif (array_key_exists('path', $prel)) { + $merged['path'] = $prel['path']; + } else { + $merged['path'] = ''; + } + + // Get the path components, and remove the initial empty one + $pathParts = explode('/', $merged['path']); + array_shift($pathParts); + + $path = []; + $prevPart = ''; + foreach ($pathParts as $part) { + if ($part == '..' && count($path) > 0) { + // Cancel out the parent directory (if there's a parent to cancel) + $parent = array_pop($path); + // But if it was also a parent directory, leave it in + if ($parent == '..') { + array_push($path, $parent); + array_push($path, $part); + } + } elseif ($prevPart != '' || ($part != '.' && $part != '')) { + // Don't include empty or current-directory components + if ($part == '.') { + $part = ''; + } + array_push($path, $part); + } + $prevPart = $part; + } + $merged['path'] = '/'.implode('/', $path); + + $ret = ''; + if (isset($merged['scheme'])) { + $ret .= $merged['scheme'].':'; + } + + if (isset($merged['scheme']) || isset($merged['host'])) { + $ret .= '//'; + } + + if (isset($prel['host'])) { + $hostSource = $prel; + } else { + $hostSource = $pbase; + } + + // username, password, and port are associated with the hostname, not merged + if (isset($hostSource['host'])) { + if (isset($hostSource['user'])) { + $ret .= $hostSource['user']; + if (isset($hostSource['pass'])) { + $ret .= ':'.$hostSource['pass']; + } + $ret .= '@'; + } + $ret .= $hostSource['host']; + if (isset($hostSource['port'])) { + $ret .= ':'.$hostSource['port']; + } + } + + $ret .= $merged['path']; + + if (isset($prel['query'])) { + $ret .= '?'.$prel['query']; + } + + if (isset($prel['fragment'])) { + $ret .= '#'.$prel['fragment']; + } + + return $ret; + } + } function removePrefix(string $text, string $prefix): string