Initial Commit
This commit is contained in:
33
dependencies/stripe/stripe-php/lib/ApiOperations/All.php
vendored
Normal file
33
dependencies/stripe/stripe-php/lib/ApiOperations/All.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\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 = \WP_Ultimo\Dependencies\Stripe\Util\Util::convertToStripeObject($response->json, $opts);
|
||||
if (!$obj instanceof \WP_Ultimo\Dependencies\Stripe\Collection) {
|
||||
throw new \WP_Ultimo\Dependencies\Stripe\Exception\UnexpectedValueException('Expected type ' . \WP_Ultimo\Dependencies\Stripe\Collection::class . ', got "' . \get_class($obj) . '" instead.');
|
||||
}
|
||||
$obj->setLastResponse($response);
|
||||
$obj->setFilters($params);
|
||||
return $obj;
|
||||
}
|
||||
}
|
29
dependencies/stripe/stripe-php/lib/ApiOperations/Create.php
vendored
Normal file
29
dependencies/stripe/stripe-php/lib/ApiOperations/Create.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\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 = \WP_Ultimo\Dependencies\Stripe\Util\Util::convertToStripeObject($response->json, $opts);
|
||||
$obj->setLastResponse($response);
|
||||
return $obj;
|
||||
}
|
||||
}
|
28
dependencies/stripe/stripe-php/lib/ApiOperations/Delete.php
vendored
Normal file
28
dependencies/stripe/stripe-php/lib/ApiOperations/Delete.php
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\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;
|
||||
}
|
||||
}
|
121
dependencies/stripe/stripe-php/lib/ApiOperations/NestedResource.php
vendored
Normal file
121
dependencies/stripe/stripe-php/lib/ApiOperations/NestedResource.php
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\Stripe\ApiOperations;
|
||||
|
||||
/**
|
||||
* Trait for resources that have nested resources.
|
||||
*
|
||||
* This trait should only be applied to classes that derive from StripeObject.
|
||||
*/
|
||||
trait NestedResource
|
||||
{
|
||||
/**
|
||||
* @param 'delete'|'get'|'post' $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 = \WP_Ultimo\Dependencies\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);
|
||||
}
|
||||
}
|
90
dependencies/stripe/stripe-php/lib/ApiOperations/Request.php
vendored
Normal file
90
dependencies/stripe/stripe-php/lib/ApiOperations/Request.php
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\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 \WP_Ultimo\Dependencies\Stripe\Exception\InvalidArgumentException($message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param 'delete'|'get'|'post' $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 'delete'|'get'|'post' $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 'delete'|'get'|'post' $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 = \WP_Ultimo\Dependencies\Stripe\Util\RequestOptions::parse($options);
|
||||
$baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
|
||||
$requestor = new \WP_Ultimo\Dependencies\Stripe\ApiRequestor($opts->apiKey, $baseUrl);
|
||||
list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers);
|
||||
$opts->discardNonPersistentHeaders();
|
||||
return [$response, $opts];
|
||||
}
|
||||
/**
|
||||
* @param 'delete'|'get'|'post' $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 = \WP_Ultimo\Dependencies\Stripe\Util\RequestOptions::parse($options);
|
||||
$baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
|
||||
$requestor = new \WP_Ultimo\Dependencies\Stripe\ApiRequestor($opts->apiKey, $baseUrl);
|
||||
$requestor->requestStream($method, $url, $readBodyChunk, $params, $opts->headers);
|
||||
}
|
||||
}
|
29
dependencies/stripe/stripe-php/lib/ApiOperations/Retrieve.php
vendored
Normal file
29
dependencies/stripe/stripe-php/lib/ApiOperations/Retrieve.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\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 = \WP_Ultimo\Dependencies\Stripe\Util\RequestOptions::parse($opts);
|
||||
$instance = new static($id, $opts);
|
||||
$instance->refresh();
|
||||
return $instance;
|
||||
}
|
||||
}
|
33
dependencies/stripe/stripe-php/lib/ApiOperations/Search.php
vendored
Normal file
33
dependencies/stripe/stripe-php/lib/ApiOperations/Search.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\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 = \WP_Ultimo\Dependencies\Stripe\Util\Util::convertToStripeObject($response->json, $opts);
|
||||
if (!$obj instanceof \WP_Ultimo\Dependencies\Stripe\SearchResult) {
|
||||
throw new \WP_Ultimo\Dependencies\Stripe\Exception\UnexpectedValueException('Expected type ' . \WP_Ultimo\Dependencies\Stripe\SearchResult::class . ', got "' . \get_class($obj) . '" instead.');
|
||||
}
|
||||
$obj->setLastResponse($response);
|
||||
$obj->setFilters($params);
|
||||
return $obj;
|
||||
}
|
||||
}
|
28
dependencies/stripe/stripe-php/lib/ApiOperations/SingletonRetrieve.php
vendored
Normal file
28
dependencies/stripe/stripe-php/lib/ApiOperations/SingletonRetrieve.php
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\Stripe\ApiOperations;
|
||||
|
||||
/**
|
||||
* Trait for retrievable singleton resources. Adds a `retrieve()` static method to the
|
||||
* class.
|
||||
*
|
||||
* This trait should only be applied to classes that derive from SingletonApiResource.
|
||||
*/
|
||||
trait SingletonRetrieve
|
||||
{
|
||||
/**
|
||||
* @param null|array|string $opts the ID of the API resource to retrieve,
|
||||
* or an options array containing an `id` key
|
||||
*
|
||||
* @throws \Stripe\Exception\ApiErrorException if the request fails
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function retrieve($opts = null)
|
||||
{
|
||||
$opts = \WP_Ultimo\Dependencies\Stripe\Util\RequestOptions::parse($opts);
|
||||
$instance = new static(null, $opts);
|
||||
$instance->refresh();
|
||||
return $instance;
|
||||
}
|
||||
}
|
52
dependencies/stripe/stripe-php/lib/ApiOperations/Update.php
vendored
Normal file
52
dependencies/stripe/stripe-php/lib/ApiOperations/Update.php
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Ultimo\Dependencies\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 = \WP_Ultimo\Dependencies\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
|
||||
*
|
||||
* @deprecated The `save` method is deprecated and will be removed in a
|
||||
* future major version of the library. Use the static method `update`
|
||||
* on the resource instead.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user