diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /vendor/stripe/stripe-php/lib/ApiOperations | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to '')
8 files changed, 452 insertions, 417 deletions
diff --git a/vendor/stripe/stripe-php/lib/ApiOperations/All.php b/vendor/stripe/stripe-php/lib/ApiOperations/All.php index ff2955d..e8884d2 100644 --- a/vendor/stripe/stripe-php/lib/ApiOperations/All.php +++ b/vendor/stripe/stripe-php/lib/ApiOperations/All.php @@ -1,37 +1,37 @@ -<?php - -namespace Stripe\ApiOperations; - -/** - * Trait for listable resources. Adds a `all()` static method to the class. - * - * This trait should only be applied to classes that derive from StripeObject. - */ -trait All -{ - /** - * @param null|array $params - * @param null|array|string $opts - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return \Stripe\Collection of ApiResources - */ - public static function all($params = null, $opts = null) - { - self::_validateParams($params); - $url = static::classUrl(); - - list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); - $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); - if (!($obj instanceof \Stripe\Collection)) { - throw new \Stripe\Exception\UnexpectedValueException( - 'Expected type ' . \Stripe\Collection::class . ', got "' . \get_class($obj) . '" instead.' - ); - } - $obj->setLastResponse($response); - $obj->setFilters($params); - - return $obj; - } -} +<?php
+
+namespace Stripe\ApiOperations;
+
+/**
+ * Trait for listable resources. Adds a `all()` static method to the class.
+ *
+ * This trait should only be applied to classes that derive from StripeObject.
+ */
+trait All
+{
+ /**
+ * @param null|array $params
+ * @param null|array|string $opts
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return \Stripe\Collection of ApiResources
+ */
+ public static function all($params = null, $opts = null)
+ {
+ self::_validateParams($params);
+ $url = static::classUrl();
+
+ list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
+ $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
+ if (!($obj instanceof \Stripe\Collection)) {
+ throw new \Stripe\Exception\UnexpectedValueException(
+ 'Expected type ' . \Stripe\Collection::class . ', got "' . \get_class($obj) . '" instead.'
+ );
+ }
+ $obj->setLastResponse($response);
+ $obj->setFilters($params);
+
+ return $obj;
+ }
+}
diff --git a/vendor/stripe/stripe-php/lib/ApiOperations/Create.php b/vendor/stripe/stripe-php/lib/ApiOperations/Create.php index c435132..d1dead9 100644 --- a/vendor/stripe/stripe-php/lib/ApiOperations/Create.php +++ b/vendor/stripe/stripe-php/lib/ApiOperations/Create.php @@ -1,31 +1,31 @@ -<?php - -namespace Stripe\ApiOperations; - -/** - * Trait for creatable resources. Adds a `create()` static method to the class. - * - * This trait should only be applied to classes that derive from StripeObject. - */ -trait Create -{ - /** - * @param null|array $params - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return static the created resource - */ - public static function create($params = null, $options = null) - { - self::_validateParams($params); - $url = static::classUrl(); - - list($response, $opts) = static::_staticRequest('post', $url, $params, $options); - $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); - $obj->setLastResponse($response); - - return $obj; - } -} +<?php
+
+namespace Stripe\ApiOperations;
+
+/**
+ * Trait for creatable resources. Adds a `create()` static method to the class.
+ *
+ * This trait should only be applied to classes that derive from StripeObject.
+ */
+trait Create
+{
+ /**
+ * @param null|array $params
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return static the created resource
+ */
+ public static function create($params = null, $options = null)
+ {
+ self::_validateParams($params);
+ $url = static::classUrl();
+
+ list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
+ $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
+ $obj->setLastResponse($response);
+
+ return $obj;
+ }
+}
diff --git a/vendor/stripe/stripe-php/lib/ApiOperations/Delete.php b/vendor/stripe/stripe-php/lib/ApiOperations/Delete.php index c6082ff..291546a 100644 --- a/vendor/stripe/stripe-php/lib/ApiOperations/Delete.php +++ b/vendor/stripe/stripe-php/lib/ApiOperations/Delete.php @@ -1,30 +1,30 @@ -<?php - -namespace Stripe\ApiOperations; - -/** - * Trait for deletable resources. Adds a `delete()` method to the class. - * - * This trait should only be applied to classes that derive from StripeObject. - */ -trait Delete -{ - /** - * @param null|array $params - * @param null|array|string $opts - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return static the deleted resource - */ - public function delete($params = null, $opts = null) - { - self::_validateParams($params); - - $url = $this->instanceUrl(); - list($response, $opts) = $this->_request('delete', $url, $params, $opts); - $this->refreshFrom($response, $opts); - - return $this; - } -} +<?php
+
+namespace Stripe\ApiOperations;
+
+/**
+ * Trait for deletable resources. Adds a `delete()` method to the class.
+ *
+ * This trait should only be applied to classes that derive from StripeObject.
+ */
+trait Delete
+{
+ /**
+ * @param null|array $params
+ * @param null|array|string $opts
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return static the deleted resource
+ */
+ public function delete($params = null, $opts = null)
+ {
+ self::_validateParams($params);
+
+ $url = $this->instanceUrl();
+ list($response, $opts) = $this->_request('delete', $url, $params, $opts);
+ $this->refreshFrom($response, $opts);
+
+ return $this;
+ }
+}
diff --git a/vendor/stripe/stripe-php/lib/ApiOperations/NestedResource.php b/vendor/stripe/stripe-php/lib/ApiOperations/NestedResource.php index 180cacd..ed9c830 100644 --- a/vendor/stripe/stripe-php/lib/ApiOperations/NestedResource.php +++ b/vendor/stripe/stripe-php/lib/ApiOperations/NestedResource.php @@ -1,135 +1,135 @@ -<?php - -namespace Stripe\ApiOperations; - -/** - * Trait for resources that have nested resources. - * - * This trait should only be applied to classes that derive from StripeObject. - */ -trait NestedResource -{ - /** - * @param string $method - * @param string $url - * @param null|array $params - * @param null|array|string $options - * - * @return \Stripe\StripeObject - */ - protected static function _nestedResourceOperation($method, $url, $params = null, $options = null) - { - self::_validateParams($params); - - list($response, $opts) = static::_staticRequest($method, $url, $params, $options); - $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); - $obj->setLastResponse($response); - - return $obj; - } - - /** - * @param string $id - * @param string $nestedPath - * @param null|string $nestedId - * - * @return string - */ - protected static function _nestedResourceUrl($id, $nestedPath, $nestedId = null) - { - $url = static::resourceUrl($id) . $nestedPath; - if (null !== $nestedId) { - $url .= "/{$nestedId}"; - } - - return $url; - } - - /** - * @param string $id - * @param string $nestedPath - * @param null|array $params - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return \Stripe\StripeObject - */ - protected static function _createNestedResource($id, $nestedPath, $params = null, $options = null) - { - $url = static::_nestedResourceUrl($id, $nestedPath); - - return self::_nestedResourceOperation('post', $url, $params, $options); - } - - /** - * @param string $id - * @param string $nestedPath - * @param null|string $nestedId - * @param null|array $params - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return \Stripe\StripeObject - */ - protected static function _retrieveNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null) - { - $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId); - - return self::_nestedResourceOperation('get', $url, $params, $options); - } - - /** - * @param string $id - * @param string $nestedPath - * @param null|string $nestedId - * @param null|array $params - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return \Stripe\StripeObject - */ - protected static function _updateNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null) - { - $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId); - - return self::_nestedResourceOperation('post', $url, $params, $options); - } - - /** - * @param string $id - * @param string $nestedPath - * @param null|string $nestedId - * @param null|array $params - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return \Stripe\StripeObject - */ - protected static function _deleteNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null) - { - $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId); - - return self::_nestedResourceOperation('delete', $url, $params, $options); - } - - /** - * @param string $id - * @param string $nestedPath - * @param null|array $params - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return \Stripe\StripeObject - */ - protected static function _allNestedResources($id, $nestedPath, $params = null, $options = null) - { - $url = static::_nestedResourceUrl($id, $nestedPath); - - return self::_nestedResourceOperation('get', $url, $params, $options); - } -} +<?php
+
+namespace Stripe\ApiOperations;
+
+/**
+ * Trait for resources that have nested resources.
+ *
+ * This trait should only be applied to classes that derive from StripeObject.
+ */
+trait NestedResource
+{
+ /**
+ * @param string $method
+ * @param string $url
+ * @param null|array $params
+ * @param null|array|string $options
+ *
+ * @return \Stripe\StripeObject
+ */
+ protected static function _nestedResourceOperation($method, $url, $params = null, $options = null)
+ {
+ self::_validateParams($params);
+
+ list($response, $opts) = static::_staticRequest($method, $url, $params, $options);
+ $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
+ $obj->setLastResponse($response);
+
+ return $obj;
+ }
+
+ /**
+ * @param string $id
+ * @param string $nestedPath
+ * @param null|string $nestedId
+ *
+ * @return string
+ */
+ protected static function _nestedResourceUrl($id, $nestedPath, $nestedId = null)
+ {
+ $url = static::resourceUrl($id) . $nestedPath;
+ if (null !== $nestedId) {
+ $url .= "/{$nestedId}";
+ }
+
+ return $url;
+ }
+
+ /**
+ * @param string $id
+ * @param string $nestedPath
+ * @param null|array $params
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return \Stripe\StripeObject
+ */
+ protected static function _createNestedResource($id, $nestedPath, $params = null, $options = null)
+ {
+ $url = static::_nestedResourceUrl($id, $nestedPath);
+
+ return self::_nestedResourceOperation('post', $url, $params, $options);
+ }
+
+ /**
+ * @param string $id
+ * @param string $nestedPath
+ * @param null|string $nestedId
+ * @param null|array $params
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return \Stripe\StripeObject
+ */
+ protected static function _retrieveNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
+ {
+ $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
+
+ return self::_nestedResourceOperation('get', $url, $params, $options);
+ }
+
+ /**
+ * @param string $id
+ * @param string $nestedPath
+ * @param null|string $nestedId
+ * @param null|array $params
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return \Stripe\StripeObject
+ */
+ protected static function _updateNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
+ {
+ $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
+
+ return self::_nestedResourceOperation('post', $url, $params, $options);
+ }
+
+ /**
+ * @param string $id
+ * @param string $nestedPath
+ * @param null|string $nestedId
+ * @param null|array $params
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return \Stripe\StripeObject
+ */
+ protected static function _deleteNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
+ {
+ $url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
+
+ return self::_nestedResourceOperation('delete', $url, $params, $options);
+ }
+
+ /**
+ * @param string $id
+ * @param string $nestedPath
+ * @param null|array $params
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return \Stripe\StripeObject
+ */
+ protected static function _allNestedResources($id, $nestedPath, $params = null, $options = null)
+ {
+ $url = static::_nestedResourceUrl($id, $nestedPath);
+
+ return self::_nestedResourceOperation('get', $url, $params, $options);
+ }
+}
diff --git a/vendor/stripe/stripe-php/lib/ApiOperations/Request.php b/vendor/stripe/stripe-php/lib/ApiOperations/Request.php index 24c3741..a5046ab 100644 --- a/vendor/stripe/stripe-php/lib/ApiOperations/Request.php +++ b/vendor/stripe/stripe-php/lib/ApiOperations/Request.php @@ -1,102 +1,100 @@ -<?php - -namespace Stripe\ApiOperations; - -/** - * Trait for resources that need to make API requests. - * - * This trait should only be applied to classes that derive from StripeObject. - */ -trait Request -{ - /** - * @param null|array|mixed $params The list of parameters to validate - * - * @throws \Stripe\Exception\InvalidArgumentException if $params exists and is not an array - */ - protected static function _validateParams($params = null) - { - if ($params && !\is_array($params)) { - $message = 'You must pass an array as the first argument to Stripe API ' - . 'method calls. (HINT: an example call to create a charge ' - . "would be: \"Stripe\\Charge::create(['amount' => 100, " - . "'currency' => 'usd', 'source' => 'tok_1234'])\")"; - - throw new \Stripe\Exception\InvalidArgumentException($message); - } - } - - /** - * @param string $method HTTP method ('get', 'post', etc.) - * @param string $url URL for the request - * @param array $params list of parameters for the request - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return array tuple containing (the JSON response, $options) - */ - protected function _request($method, $url, $params = [], $options = null) - { - $opts = $this->_opts->merge($options); - list($resp, $options) = static::_staticRequest($method, $url, $params, $opts); - $this->setLastResponse($resp); - - return [$resp->json, $options]; - } - - /** - * @param string $method HTTP method ('get', 'post', etc.) - * @param string $url URL for the request - * @param callable $readBodyChunk function that will receive chunks of data from a successful request body - * @param array $params list of parameters for the request - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return array tuple containing (the JSON response, $options) - */ - protected function _requestStream($method, $url, $readBodyChunk, $params = [], $options = null) - { - $opts = $this->_opts->merge($options); - static::_staticStreamingRequest($method, $url, $readBodyChunk, $params, $opts); - } - - /** - * @param string $method HTTP method ('get', 'post', etc.) - * @param string $url URL for the request - * @param array $params list of parameters for the request - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return array tuple containing (the JSON response, $options) - */ - protected static function _staticRequest($method, $url, $params, $options) - { - $opts = \Stripe\Util\RequestOptions::parse($options); - $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl(); - $requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl); - list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers); - $opts->discardNonPersistentHeaders(); - - return [$response, $opts]; - } - - /** - * @param string $method HTTP method ('get', 'post', etc.) - * @param string $url URL for the request - * @param callable $readBodyChunk function that will receive chunks of data from a successful request body - * @param array $params list of parameters for the request - * @param null|array|string $options - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - */ - protected static function _staticStreamingRequest($method, $url, $readBodyChunk, $params, $options) - { - $opts = \Stripe\Util\RequestOptions::parse($options); - $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl(); - $requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl); - $requestor->requestStream($method, $url, $readBodyChunk, $params, $opts->headers); - } -} +<?php
+
+namespace Stripe\ApiOperations;
+
+/**
+ * Trait for resources that need to make API requests.
+ *
+ * This trait should only be applied to classes that derive from StripeObject.
+ */
+trait Request
+{
+ /**
+ * @param null|array|mixed $params The list of parameters to validate
+ *
+ * @throws \Stripe\Exception\InvalidArgumentException if $params exists and is not an array
+ */
+ protected static function _validateParams($params = null)
+ {
+ if ($params && !\is_array($params)) {
+ $message = 'You must pass an array as the first argument to Stripe API '
+ . 'method calls. (HINT: an example call to create a charge '
+ . "would be: \"Stripe\\Charge::create(['amount' => 100, "
+ . "'currency' => 'usd', 'source' => 'tok_1234'])\")";
+
+ throw new \Stripe\Exception\InvalidArgumentException($message);
+ }
+ }
+
+ /**
+ * @param string $method HTTP method ('get', 'post', etc.)
+ * @param string $url URL for the request
+ * @param array $params list of parameters for the request
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return array tuple containing (the JSON response, $options)
+ */
+ protected function _request($method, $url, $params = [], $options = null)
+ {
+ $opts = $this->_opts->merge($options);
+ list($resp, $options) = static::_staticRequest($method, $url, $params, $opts);
+ $this->setLastResponse($resp);
+
+ return [$resp->json, $options];
+ }
+
+ /**
+ * @param string $method HTTP method ('get', 'post', etc.)
+ * @param string $url URL for the request
+ * @param callable $readBodyChunk function that will receive chunks of data from a successful request body
+ * @param array $params list of parameters for the request
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ */
+ protected function _requestStream($method, $url, $readBodyChunk, $params = [], $options = null)
+ {
+ $opts = $this->_opts->merge($options);
+ static::_staticStreamingRequest($method, $url, $readBodyChunk, $params, $opts);
+ }
+
+ /**
+ * @param string $method HTTP method ('get', 'post', etc.)
+ * @param string $url URL for the request
+ * @param array $params list of parameters for the request
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return array tuple containing (the JSON response, $options)
+ */
+ protected static function _staticRequest($method, $url, $params, $options)
+ {
+ $opts = \Stripe\Util\RequestOptions::parse($options);
+ $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
+ $requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl);
+ list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
+ $opts->discardNonPersistentHeaders();
+
+ return [$response, $opts];
+ }
+
+ /**
+ * @param string $method HTTP method ('get', 'post', etc.)
+ * @param string $url URL for the request
+ * @param callable $readBodyChunk function that will receive chunks of data from a successful request body
+ * @param array $params list of parameters for the request
+ * @param null|array|string $options
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ */
+ protected static function _staticStreamingRequest($method, $url, $readBodyChunk, $params, $options)
+ {
+ $opts = \Stripe\Util\RequestOptions::parse($options);
+ $baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
+ $requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl);
+ $requestor->requestStream($method, $url, $readBodyChunk, $params, $opts->headers);
+ }
+}
diff --git a/vendor/stripe/stripe-php/lib/ApiOperations/Retrieve.php b/vendor/stripe/stripe-php/lib/ApiOperations/Retrieve.php index 5170afb..ddd8e51 100644 --- a/vendor/stripe/stripe-php/lib/ApiOperations/Retrieve.php +++ b/vendor/stripe/stripe-php/lib/ApiOperations/Retrieve.php @@ -1,30 +1,30 @@ -<?php - -namespace Stripe\ApiOperations; - -/** - * Trait for retrievable resources. Adds a `retrieve()` static method to the - * class. - * - * This trait should only be applied to classes that derive from StripeObject. - */ -trait Retrieve -{ - /** - * @param array|string $id the ID of the API resource to retrieve, - * or an options array containing an `id` key - * @param null|array|string $opts - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return static - */ - public static function retrieve($id, $opts = null) - { - $opts = \Stripe\Util\RequestOptions::parse($opts); - $instance = new static($id, $opts); - $instance->refresh(); - - return $instance; - } -} +<?php
+
+namespace Stripe\ApiOperations;
+
+/**
+ * Trait for retrievable resources. Adds a `retrieve()` static method to the
+ * class.
+ *
+ * This trait should only be applied to classes that derive from StripeObject.
+ */
+trait Retrieve
+{
+ /**
+ * @param array|string $id the ID of the API resource to retrieve,
+ * or an options array containing an `id` key
+ * @param null|array|string $opts
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return static
+ */
+ public static function retrieve($id, $opts = null)
+ {
+ $opts = \Stripe\Util\RequestOptions::parse($opts);
+ $instance = new static($id, $opts);
+ $instance->refresh();
+
+ return $instance;
+ }
+}
diff --git a/vendor/stripe/stripe-php/lib/ApiOperations/Search.php b/vendor/stripe/stripe-php/lib/ApiOperations/Search.php new file mode 100644 index 0000000..e52f8b9 --- /dev/null +++ b/vendor/stripe/stripe-php/lib/ApiOperations/Search.php @@ -0,0 +1,37 @@ +<?php
+
+namespace Stripe\ApiOperations;
+
+/**
+ * Trait for searchable resources.
+ *
+ * This trait should only be applied to classes that derive from StripeObject.
+ */
+trait Search
+{
+ /**
+ * @param string $searchUrl
+ * @param null|array $params
+ * @param null|array|string $opts
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return \Stripe\SearchResult of ApiResources
+ */
+ protected static function _searchResource($searchUrl, $params = null, $opts = null)
+ {
+ self::_validateParams($params);
+
+ list($response, $opts) = static::_staticRequest('get', $searchUrl, $params, $opts);
+ $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
+ if (!($obj instanceof \Stripe\SearchResult)) {
+ throw new \Stripe\Exception\UnexpectedValueException(
+ 'Expected type ' . \Stripe\SearchResult::class . ', got "' . \get_class($obj) . '" instead.'
+ );
+ }
+ $obj->setLastResponse($response);
+ $obj->setFilters($params);
+
+ return $obj;
+ }
+}
diff --git a/vendor/stripe/stripe-php/lib/ApiOperations/Update.php b/vendor/stripe/stripe-php/lib/ApiOperations/Update.php index 688f080..841b039 100644 --- a/vendor/stripe/stripe-php/lib/ApiOperations/Update.php +++ b/vendor/stripe/stripe-php/lib/ApiOperations/Update.php @@ -1,52 +1,52 @@ -<?php - -namespace Stripe\ApiOperations; - -/** - * Trait for updatable resources. Adds an `update()` static method and a - * `save()` method to the class. - * - * This trait should only be applied to classes that derive from StripeObject. - */ -trait Update -{ - /** - * @param string $id the ID of the resource to update - * @param null|array $params - * @param null|array|string $opts - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return static the updated resource - */ - public static function update($id, $params = null, $opts = null) - { - self::_validateParams($params); - $url = static::resourceUrl($id); - - list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); - $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); - $obj->setLastResponse($response); - - return $obj; - } - - /** - * @param null|array|string $opts - * - * @throws \Stripe\Exception\ApiErrorException if the request fails - * - * @return static the saved resource - */ - public function save($opts = null) - { - $params = $this->serializeParameters(); - if (\count($params) > 0) { - $url = $this->instanceUrl(); - list($response, $opts) = $this->_request('post', $url, $params, $opts); - $this->refreshFrom($response, $opts); - } - - return $this; - } -} +<?php
+
+namespace Stripe\ApiOperations;
+
+/**
+ * Trait for updatable resources. Adds an `update()` static method and a
+ * `save()` method to the class.
+ *
+ * This trait should only be applied to classes that derive from StripeObject.
+ */
+trait Update
+{
+ /**
+ * @param string $id the ID of the resource to update
+ * @param null|array $params
+ * @param null|array|string $opts
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return static the updated resource
+ */
+ public static function update($id, $params = null, $opts = null)
+ {
+ self::_validateParams($params);
+ $url = static::resourceUrl($id);
+
+ list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
+ $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
+ $obj->setLastResponse($response);
+
+ return $obj;
+ }
+
+ /**
+ * @param null|array|string $opts
+ *
+ * @throws \Stripe\Exception\ApiErrorException if the request fails
+ *
+ * @return static the saved resource
+ */
+ public function save($opts = null)
+ {
+ $params = $this->serializeParameters();
+ if (\count($params) > 0) {
+ $url = $this->instanceUrl();
+ list($response, $opts) = $this->_request('post', $url, $params, $opts);
+ $this->refreshFrom($response, $opts);
+ }
+
+ return $this;
+ }
+}
|