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/Service/AbstractService.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/Service/AbstractService.php | 184 |
1 files changed, 105 insertions, 79 deletions
diff --git a/vendor/stripe/stripe-php/lib/Service/AbstractService.php b/vendor/stripe/stripe-php/lib/Service/AbstractService.php index ed092c8..79cd9d9 100644 --- a/vendor/stripe/stripe-php/lib/Service/AbstractService.php +++ b/vendor/stripe/stripe-php/lib/Service/AbstractService.php @@ -1,79 +1,105 @@ -<?php - -namespace Stripe\Service; - -/** - * Abstract base class for all services. - */ -abstract class AbstractService -{ - /** - * @var \Stripe\StripeClientInterface - */ - protected $client; - - /** - * Initializes a new instance of the {@link AbstractService} class. - * - * @param \Stripe\StripeClientInterface $client - */ - public function __construct($client) - { - $this->client = $client; - } - - /** - * Gets the client used by this service to send requests. - * - * @return \Stripe\StripeClientInterface - */ - public function getClient() - { - return $this->client; - } - - /** - * Translate null values to empty strings. For service methods, - * we interpret null as a request to unset the field, which - * corresponds to sending an empty string for the field to the - * API. - * - * @param null|array $params - */ - private static function formatParams($params) - { - if (null === $params) { - return null; - } - \array_walk_recursive($params, function (&$value, $key) { - if (null === $value) { - $value = ''; - } - }); - - return $params; - } - - protected function request($method, $path, $params, $opts) - { - return $this->getClient()->request($method, $path, static::formatParams($params), $opts); - } - - protected function requestCollection($method, $path, $params, $opts) - { - return $this->getClient()->requestCollection($method, $path, static::formatParams($params), $opts); - } - - protected function buildPath($basePath, ...$ids) - { - foreach ($ids as $id) { - if (null === $id || '' === \trim($id)) { - $msg = 'The resource ID cannot be null or whitespace.'; - - throw new \Stripe\Exception\InvalidArgumentException($msg); - } - } - - return \sprintf($basePath, ...\array_map('\urlencode', $ids)); - } -} +<?php
+
+namespace Stripe\Service;
+
+/**
+ * Abstract base class for all services.
+ */
+abstract class AbstractService
+{
+ /**
+ * @var \Stripe\StripeClientInterface
+ */
+ protected $client;
+
+ /**
+ * @var \Stripe\StripeStreamingClientInterface
+ */
+ protected $streamingClient;
+
+ /**
+ * Initializes a new instance of the {@link AbstractService} class.
+ *
+ * @param \Stripe\StripeClientInterface $client
+ */
+ public function __construct($client)
+ {
+ $this->client = $client;
+ $this->streamingClient = $client;
+ }
+
+ /**
+ * Gets the client used by this service to send requests.
+ *
+ * @return \Stripe\StripeClientInterface
+ */
+ public function getClient()
+ {
+ return $this->client;
+ }
+
+ /**
+ * Gets the client used by this service to send requests.
+ *
+ * @return \Stripe\StripeStreamingClientInterface
+ */
+ public function getStreamingClient()
+ {
+ return $this->streamingClient;
+ }
+
+ /**
+ * Translate null values to empty strings. For service methods,
+ * we interpret null as a request to unset the field, which
+ * corresponds to sending an empty string for the field to the
+ * API.
+ *
+ * @param null|array $params
+ */
+ private static function formatParams($params)
+ {
+ if (null === $params) {
+ return null;
+ }
+ \array_walk_recursive($params, function (&$value, $key) {
+ if (null === $value) {
+ $value = '';
+ }
+ });
+
+ return $params;
+ }
+
+ protected function request($method, $path, $params, $opts)
+ {
+ return $this->getClient()->request($method, $path, static::formatParams($params), $opts);
+ }
+
+ protected function requestStream($method, $path, $readBodyChunkCallable, $params, $opts)
+ {
+ return $this->getStreamingClient()->requestStream($method, $path, $readBodyChunkCallable, static::formatParams($params), $opts);
+ }
+
+ protected function requestCollection($method, $path, $params, $opts)
+ {
+ return $this->getClient()->requestCollection($method, $path, static::formatParams($params), $opts);
+ }
+
+ protected function requestSearchResult($method, $path, $params, $opts)
+ {
+ return $this->getClient()->requestSearchResult($method, $path, static::formatParams($params), $opts);
+ }
+
+ protected function buildPath($basePath, ...$ids)
+ {
+ foreach ($ids as $id) {
+ if (null === $id || '' === \trim($id)) {
+ $msg = 'The resource ID cannot be null or whitespace.';
+
+ throw new \Stripe\Exception\InvalidArgumentException($msg);
+ }
+ }
+
+ return \sprintf($basePath, ...\array_map('\urlencode', $ids));
+ }
+}
|