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/Request.php | |
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 '')
-rw-r--r-- | vendor/stripe/stripe-php/lib/ApiOperations/Request.php | 202 |
1 files changed, 100 insertions, 102 deletions
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);
+ }
+}
|