From 75160b12821f7f4299cce7f0b69c83c1502ae071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Mon, 27 May 2024 13:08:29 +0200 Subject: 2024-02-19 upstream --- vendor/stripe/stripe-php/lib/ApiResource.php | 242 ++++++++++++++------------- 1 file changed, 122 insertions(+), 120 deletions(-) (limited to 'vendor/stripe/stripe-php/lib/ApiResource.php') diff --git a/vendor/stripe/stripe-php/lib/ApiResource.php b/vendor/stripe/stripe-php/lib/ApiResource.php index 521010b..2b4dc65 100644 --- a/vendor/stripe/stripe-php/lib/ApiResource.php +++ b/vendor/stripe/stripe-php/lib/ApiResource.php @@ -1,120 +1,122 @@ -{$k}; - if ((static::getSavedNestedResources()->includes($k)) - && ($v instanceof ApiResource)) { - $v->saveWithParent = true; - } - } - - /** - * @throws Exception\ApiErrorException - * - * @return ApiResource the refreshed resource - */ - public function refresh() - { - $requestor = new ApiRequestor($this->_opts->apiKey, static::baseUrl()); - $url = $this->instanceUrl(); - - list($response, $this->_opts->apiKey) = $requestor->request( - 'get', - $url, - $this->_retrieveOptions, - $this->_opts->headers - ); - $this->setLastResponse($response); - $this->refreshFrom($response->json, $this->_opts); - - return $this; - } - - /** - * @return string the base URL for the given class - */ - public static function baseUrl() - { - return Stripe::$apiBase; - } - - /** - * @return string the endpoint URL for the given class - */ - public static function classUrl() - { - // Replace dots with slashes for namespaced resources, e.g. if the object's name is - // "foo.bar", then its URL will be "/v1/foo/bars". - $base = \str_replace('.', '/', static::OBJECT_NAME); - - return "/v1/{$base}s"; - } - - /** - * @param null|string $id the ID of the resource - * - * @throws Exception\UnexpectedValueException if $id is null - * - * @return string the instance endpoint URL for the given class - */ - public static function resourceUrl($id) - { - if (null === $id) { - $class = static::class; - $message = 'Could not determine which URL to request: ' - . "{$class} instance has invalid ID: {$id}"; - - throw new Exception\UnexpectedValueException($message); - } - $id = Util\Util::utf8($id); - $base = static::classUrl(); - $extn = \urlencode($id); - - return "{$base}/{$extn}"; - } - - /** - * @return string the full API URL for this API resource - */ - public function instanceUrl() - { - return static::resourceUrl($this['id']); - } -} +{$k}; + if ((static::getSavedNestedResources()->includes($k)) + && ($v instanceof ApiResource)) { + $v->saveWithParent = true; + } + } + + /** + * @throws Exception\ApiErrorException + * + * @return ApiResource the refreshed resource + */ + public function refresh() + { + $requestor = new ApiRequestor($this->_opts->apiKey, static::baseUrl()); + $url = $this->instanceUrl(); + + list($response, $this->_opts->apiKey) = $requestor->request( + 'get', + $url, + $this->_retrieveOptions, + $this->_opts->headers + ); + $this->setLastResponse($response); + $this->refreshFrom($response->json, $this->_opts); + + return $this; + } + + /** + * @return string the base URL for the given class + */ + public static function baseUrl() + { + return Stripe::$apiBase; + } + + /** + * @return string the endpoint URL for the given class + */ + public static function classUrl() + { + // Replace dots with slashes for namespaced resources, e.g. if the object's name is + // "foo.bar", then its URL will be "/v1/foo/bars". + + /** @phpstan-ignore-next-line */ + $base = \str_replace('.', '/', static::OBJECT_NAME); + + return "/v1/{$base}s"; + } + + /** + * @param null|string $id the ID of the resource + * + * @throws Exception\UnexpectedValueException if $id is null + * + * @return string the instance endpoint URL for the given class + */ + public static function resourceUrl($id) + { + if (null === $id) { + $class = static::class; + $message = 'Could not determine which URL to request: ' + . "{$class} instance has invalid ID: {$id}"; + + throw new Exception\UnexpectedValueException($message); + } + $id = Util\Util::utf8($id); + $base = static::classUrl(); + $extn = \urlencode($id); + + return "{$base}/{$extn}"; + } + + /** + * @return string the full API URL for this API resource + */ + public function instanceUrl() + { + return static::resourceUrl($this['id']); + } +} -- cgit v1.2.3