diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 55ac6f1fa..4161e81ad 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v1044 +v1058 \ No newline at end of file diff --git a/lib/Account.php b/lib/Account.php index 9d1a0f295..303bddbb1 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -46,9 +46,6 @@ class Account extends ApiResource { const OBJECT_NAME = 'account'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; use ApiOperations\Update; @@ -62,6 +59,129 @@ class Account extends ApiResource const TYPE_NONE = 'none'; const TYPE_STANDARD = 'standard'; + /** + * With Connect, you can create Stripe accounts for + * your users. To do this, you’ll first need to register your + * platform. + * + * If you’ve already collected information for your connected accounts, you can prefill that information + * when creating the account. Connect Onboarding won’t ask for the prefilled + * information during account onboarding. You can prefill any information on the + * account. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Account 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; + } + + /** + * With Connect, you can delete accounts you manage. + * + * Test-mode accounts can be deleted at any time. + * + * Live-mode accounts where Stripe is responsible for negative account balances + * cannot be deleted, which includes Standard accounts. Live-mode accounts where + * your platform is liable for negative account balances, which includes Custom and + * Express accounts, can be deleted when all balances are zero. + * + * If you want to delete your own account, use the account information tab in + * your account settings instead. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Account 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; + } + + /** + * Returns a list of accounts connected to your platform via Connect. If you’re not a platform, the list is empty. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Account> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Updates a connected account by setting the + * values of the parameters passed. Any parameters not provided are left unchanged. + * + * For accounts where controller.requirement_collection + * is application, which includes Custom accounts, you can update any + * information on the account. + * + * For accounts where controller.requirement_collection + * is stripe, which includes Standard and Express accounts, you can + * update all information until you create an Account + * Link or Account Session to start Connect + * onboarding, after which some properties can no longer be updated. + * + * To update your own account, use the Dashboard. Refer to our + * Connect documentation to learn + * more about updating accounts. + * + * @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 \Stripe\Account 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; + } + use ApiOperations\Retrieve { retrieve as protected _retrieve; } diff --git a/lib/AccountLink.php b/lib/AccountLink.php index 2671cbe2a..339d0a1d9 100644 --- a/lib/AccountLink.php +++ b/lib/AccountLink.php @@ -19,5 +19,27 @@ class AccountLink extends ApiResource { const OBJECT_NAME = 'account_link'; - use ApiOperations\Create; + /** + * Creates an AccountLink object that includes a single-use Stripe URL that the + * platform can redirect their user to in order to take them through the Connect + * Onboarding flow. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\AccountLink 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/lib/AccountNotice.php b/lib/AccountNotice.php index dfbf60855..5727b59f3 100644 --- a/lib/AccountNotice.php +++ b/lib/AccountNotice.php @@ -24,8 +24,6 @@ class AccountNotice extends ApiResource { const OBJECT_NAME = 'account_notice'; - use ApiOperations\All; - use ApiOperations\Retrieve; use ApiOperations\Update; const REASON_ISSUING_ACCOUNT_CLOSED_FOR_INACTIVITY = 'issuing.account_closed_for_inactivity'; @@ -38,4 +36,65 @@ class AccountNotice extends ApiResource const REASON_ISSUING_DISPUTE_LOST = 'issuing.dispute_lost'; const REASON_ISSUING_DISPUTE_SUBMITTED = 'issuing.dispute_submitted'; const REASON_ISSUING_DISPUTE_WON = 'issuing.dispute_won'; + + /** + * Retrieves a list of AccountNotice objects. The objects are sorted + * in descending order by creation date, with the most-recently-created object + * appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\AccountNotice> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an AccountNotice object. + * + * @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 \Stripe\AccountNotice + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an AccountNotice object. + * + * @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 \Stripe\AccountNotice 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; + } } diff --git a/lib/AccountSession.php b/lib/AccountSession.php index a5c1fb2ef..85b04c9b3 100644 --- a/lib/AccountSession.php +++ b/lib/AccountSession.php @@ -24,5 +24,26 @@ class AccountSession extends ApiResource { const OBJECT_NAME = 'account_session'; - use ApiOperations\Create; + /** + * Creates a AccountSession object that includes a single-use token that the + * platform can use on their front-end to grant client-side API access. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\AccountSession 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/lib/ApplePayDomain.php b/lib/ApplePayDomain.php index 5f9489d47..db37b6a01 100644 --- a/lib/ApplePayDomain.php +++ b/lib/ApplePayDomain.php @@ -15,10 +15,84 @@ class ApplePayDomain extends ApiResource { const OBJECT_NAME = 'apple_pay_domain'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; + /** + * Create an apple pay domain. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\ApplePayDomain 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; + } + + /** + * Delete an apple pay domain. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\ApplePayDomain 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; + } + + /** + * List apple pay domains. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\ApplePayDomain> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve an apple pay domain. + * + * @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 \Stripe\ApplePayDomain + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } /** * @return string The class URL for this resource. It needs to be special diff --git a/lib/ApplicationFee.php b/lib/ApplicationFee.php index 468bcfd70..1843c27c4 100644 --- a/lib/ApplicationFee.php +++ b/lib/ApplicationFee.php @@ -25,9 +25,45 @@ class ApplicationFee extends ApiResource { const OBJECT_NAME = 'application_fee'; - use ApiOperations\All; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; + + /** + * Returns a list of application fees you’ve previously collected. The application + * fees are returned in sorted order, with the most recent fees appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\ApplicationFee> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an application fee that your account has collected. The + * same information is returned when refunding the application fee. + * + * @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 \Stripe\ApplicationFee + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } const PATH_REFUNDS = '/refunds'; diff --git a/lib/Apps/Secret.php b/lib/Apps/Secret.php index d5577897c..948f3dc14 100644 --- a/lib/Apps/Secret.php +++ b/lib/Apps/Secret.php @@ -29,8 +29,44 @@ class Secret extends \Stripe\ApiResource { const OBJECT_NAME = 'apps.secret'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; + /** + * Create or replace a secret in the secret store. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Apps\Secret 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; + } + + /** + * List all secrets stored on the given scope. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Apps\Secret> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } /** * @param null|array $params diff --git a/lib/Balance.php b/lib/Balance.php index d813cd808..61c8f40ef 100644 --- a/lib/Balance.php +++ b/lib/Balance.php @@ -29,5 +29,24 @@ class Balance extends SingletonApiResource { const OBJECT_NAME = 'balance'; - use ApiOperations\SingletonRetrieve; + /** + * Retrieves the current account balance, based on the authentication that was used + * to make the request. For a sample request, see Accounting + * for negative balances. + * + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Balance + */ + public static function retrieve($opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static(null, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/BalanceTransaction.php b/lib/BalanceTransaction.php index 9dcba0f08..d88cf9b52 100644 --- a/lib/BalanceTransaction.php +++ b/lib/BalanceTransaction.php @@ -30,9 +30,6 @@ class BalanceTransaction extends ApiResource { const OBJECT_NAME = 'balance_transaction'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const TYPE_ADJUSTMENT = 'adjustment'; const TYPE_ADVANCE = 'advance'; const TYPE_ADVANCE_FUNDING = 'advance_funding'; @@ -73,4 +70,48 @@ class BalanceTransaction extends ApiResource const TYPE_TRANSFER_CANCEL = 'transfer_cancel'; const TYPE_TRANSFER_FAILURE = 'transfer_failure'; const TYPE_TRANSFER_REFUND = 'transfer_refund'; + + /** + * Returns a list of transactions that have contributed to the Stripe account + * balance (e.g., charges, transfers, and so forth). The transactions are returned + * in sorted order, with the most recent transactions appearing first. + * + * Note that this endpoint was previously called “Balance history” and used the + * path /v1/balance/history. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\BalanceTransaction> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the balance transaction with the given ID. + * + * Note that this endpoint previously used the path + * /v1/balance/history/:id. + * + * @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 \Stripe\BalanceTransaction + */ + 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/lib/BankAccount.php b/lib/BankAccount.php index 1d1adff89..9654c7656 100644 --- a/lib/BankAccount.php +++ b/lib/BankAccount.php @@ -38,8 +38,26 @@ class BankAccount extends ApiResource { const OBJECT_NAME = 'bank_account'; - use ApiOperations\Delete; - use ApiOperations\Update; + /** + * Delete a specified external account for a given account. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\BankAccount 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; + } /** * Possible string representations of the bank verification status. @@ -112,6 +130,29 @@ public static function update($_id, $_params = null, $_options = null) throw new Exception\BadMethodCallException($msg); } + /** + * @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, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Billing/Meter.php b/lib/Billing/Meter.php index 88c67a2c8..e89213981 100644 --- a/lib/Billing/Meter.php +++ b/lib/Billing/Meter.php @@ -25,10 +25,7 @@ class Meter extends \Stripe\ApiResource { const OBJECT_NAME = 'billing.meter'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; use \Stripe\ApiOperations\NestedResource; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const EVENT_TIME_WINDOW_DAY = 'day'; @@ -37,6 +34,87 @@ class Meter extends \Stripe\ApiResource const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; + /** + * Creates a billing meter. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Billing\Meter 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; + } + + /** + * Retrieve a list of billing meters. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Billing\Meter> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a billing meter given an ID. + * + * @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 \Stripe\Billing\Meter + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a billing meter. + * + * @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 \Stripe\Billing\Meter 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 $params * @param null|array|string $opts diff --git a/lib/Billing/MeterEvent.php b/lib/Billing/MeterEvent.php index 2d9f3f4da..8d93eb93e 100644 --- a/lib/Billing/MeterEvent.php +++ b/lib/Billing/MeterEvent.php @@ -20,5 +20,25 @@ class MeterEvent extends \Stripe\ApiResource { const OBJECT_NAME = 'billing.meter_event'; - use \Stripe\ApiOperations\Create; + /** + * Creates a billing meter event. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Billing\MeterEvent 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/lib/Billing/MeterEventAdjustment.php b/lib/Billing/MeterEventAdjustment.php index f603887fe..90863fb68 100644 --- a/lib/Billing/MeterEventAdjustment.php +++ b/lib/Billing/MeterEventAdjustment.php @@ -18,8 +18,28 @@ class MeterEventAdjustment extends \Stripe\ApiResource { const OBJECT_NAME = 'billing.meter_event_adjustment'; - use \Stripe\ApiOperations\Create; - const STATUS_COMPLETE = 'complete'; const STATUS_PENDING = 'pending'; + + /** + * Creates a billing meter event adjustment. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Billing\MeterEventAdjustment 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/lib/BillingPortal/Configuration.php b/lib/BillingPortal/Configuration.php index bc730eb9b..04b2c6208 100644 --- a/lib/BillingPortal/Configuration.php +++ b/lib/BillingPortal/Configuration.php @@ -25,8 +25,89 @@ class Configuration extends \Stripe\ApiResource { const OBJECT_NAME = 'billing_portal.configuration'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + + /** + * Creates a configuration that describes the functionality and behavior of a + * PortalSession. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\BillingPortal\Configuration 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; + } + + /** + * Returns a list of configurations that describe the functionality of the customer + * portal. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\BillingPortal\Configuration> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a configuration that describes the functionality of the customer + * portal. + * + * @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 \Stripe\BillingPortal\Configuration + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a configuration that describes the functionality of the customer portal. + * + * @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 \Stripe\BillingPortal\Configuration 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; + } } diff --git a/lib/BillingPortal/Session.php b/lib/BillingPortal/Session.php index 1ca3fb8f0..a6554278c 100644 --- a/lib/BillingPortal/Session.php +++ b/lib/BillingPortal/Session.php @@ -36,5 +36,25 @@ class Session extends \Stripe\ApiResource { const OBJECT_NAME = 'billing_portal.session'; - use \Stripe\ApiOperations\Create; + /** + * Creates a session of the customer portal. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\BillingPortal\Session 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/lib/Capability.php b/lib/Capability.php index 7f03c98e5..d11df358f 100644 --- a/lib/Capability.php +++ b/lib/Capability.php @@ -27,8 +27,6 @@ class Capability extends ApiResource const STATUS_PENDING = 'pending'; const STATUS_UNREQUESTED = 'unrequested'; - use ApiOperations\Update; - /** * @return string the API URL for this Stripe account reversal */ @@ -78,9 +76,32 @@ public static function retrieve($_id, $_opts = null) public static function update($_id, $_params = null, $_options = null) { $msg = 'Capabilities cannot be updated without an account ID. ' . - 'Update a capability using `Account::updateCapability(' . - "'account_id', 'capability_id', \$updateParams)`."; + 'Update a capability using `Account::updateCapability(' . + "'account_id', 'capability_id', \$updateParams)`."; throw new Exception\BadMethodCallException($msg); } + + /** + * @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, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } } diff --git a/lib/Capital/FinancingOffer.php b/lib/Capital/FinancingOffer.php index c6dfa0083..8b85d2d63 100644 --- a/lib/Capital/FinancingOffer.php +++ b/lib/Capital/FinancingOffer.php @@ -29,9 +29,6 @@ class FinancingOffer extends \Stripe\ApiResource { const OBJECT_NAME = 'capital.financing_offer'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FINANCING_TYPE_CASH_ADVANCE = 'cash_advance'; const FINANCING_TYPE_FLEX_LOAN = 'flex_loan'; @@ -52,6 +49,43 @@ class FinancingOffer extends \Stripe\ApiResource const TYPE_CASH_ADVANCE = 'cash_advance'; const TYPE_FLEX_LOAN = 'flex_loan'; + /** + * Retrieves the financing offers available for Connected accounts that belong to + * your platform. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Capital\FinancingOffer> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Get the details of the financing offer. + * + * @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 \Stripe\Capital\FinancingOffer + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Capital/FinancingSummary.php b/lib/Capital/FinancingSummary.php index b49b17563..8c4feca15 100644 --- a/lib/Capital/FinancingSummary.php +++ b/lib/Capital/FinancingSummary.php @@ -17,9 +17,26 @@ class FinancingSummary extends \Stripe\SingletonApiResource { const OBJECT_NAME = 'capital.financing_summary'; - use \Stripe\ApiOperations\SingletonRetrieve; - const STATUS_ACCEPTED = 'accepted'; const STATUS_DELIVERED = 'delivered'; const STATUS_NONE = 'none'; + + /** + * Retrieve the financing state for the account that was authenticated in the + * request. + * + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Capital\FinancingSummary + */ + public static function retrieve($opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static(null, $opts); + $instance->refresh(); + + return $instance; + } } diff --git a/lib/Capital/FinancingTransaction.php b/lib/Capital/FinancingTransaction.php index a9da7bd21..bde8a3aec 100644 --- a/lib/Capital/FinancingTransaction.php +++ b/lib/Capital/FinancingTransaction.php @@ -22,10 +22,44 @@ class FinancingTransaction extends \Stripe\ApiResource { const OBJECT_NAME = 'capital.financing_transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const TYPE_PAYMENT = 'payment'; const TYPE_PAYOUT = 'payout'; const TYPE_REVERSAL = 'reversal'; + + /** + * Returns a list of financing transactions. The transactions are returned in + * sorted order, with the most recent transactions appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Capital\FinancingTransaction> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a financing transaction for a financing offer. + * + * @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 \Stripe\Capital\FinancingTransaction + */ + 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/lib/Card.php b/lib/Card.php index 47721b37a..b8a6b344a 100644 --- a/lib/Card.php +++ b/lib/Card.php @@ -45,8 +45,26 @@ class Card extends ApiResource { const OBJECT_NAME = 'card'; - use ApiOperations\Delete; - use ApiOperations\Update; + /** + * Delete a specified external account for a given account. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Card 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; + } /** * Possible string representations of the CVC check status. @@ -135,4 +153,27 @@ public static function update($_id, $_params = null, $_options = null) throw new Exception\BadMethodCallException($msg); } + + /** + * @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, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } } diff --git a/lib/Charge.php b/lib/Charge.php index 52a4c9a94..4b1d575ec 100644 --- a/lib/Charge.php +++ b/lib/Charge.php @@ -63,10 +63,7 @@ class Charge extends ApiResource { const OBJECT_NAME = 'charge'; - use ApiOperations\All; - use ApiOperations\Create; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -74,6 +71,95 @@ class Charge extends ApiResource const STATUS_PENDING = 'pending'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * This method is no longer recommended—use the Payment Intents API to initiate a new + * payment instead. Confirmation of the PaymentIntent creates the + * Charge object used to request payment. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Charge 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; + } + + /** + * Returns a list of charges you’ve previously created. The charges are returned in + * sorted order, with the most recent charges appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Charge> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a charge that has previously been created. Supply the + * unique charge ID that was returned from your previous request, and Stripe will + * return the corresponding charge information. The same information is returned + * when creating or refunding the charge. + * + * @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 \Stripe\Charge + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified charge by setting the values of the parameters passed. Any + * parameters not provided will be left unchanged. + * + * @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 \Stripe\Charge 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; + } + /** * Possible string representations of decline codes. * These strings are applicable to the decline_code property of the \Stripe\Exception\CardException exception. diff --git a/lib/Checkout/Session.php b/lib/Checkout/Session.php index 539cadd4e..e9101421e 100644 --- a/lib/Checkout/Session.php +++ b/lib/Checkout/Session.php @@ -80,10 +80,6 @@ class Session extends \Stripe\ApiResource { const OBJECT_NAME = 'checkout.session'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const BILLING_ADDRESS_COLLECTION_AUTO = 'auto'; const BILLING_ADDRESS_COLLECTION_REQUIRED = 'required'; @@ -117,6 +113,64 @@ class Session extends \Stripe\ApiResource const UI_MODE_EMBEDDED = 'embedded'; const UI_MODE_HOSTED = 'hosted'; + /** + * Creates a Session object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Checkout\Session 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; + } + + /** + * Returns a list of Checkout Sessions. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Checkout\Session> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Session object. + * + * @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 \Stripe\Checkout\Session + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Climate/Order.php b/lib/Climate/Order.php index 72763a9f0..5d96204c2 100644 --- a/lib/Climate/Order.php +++ b/lib/Climate/Order.php @@ -35,9 +35,6 @@ class Order extends \Stripe\ApiResource { const OBJECT_NAME = 'climate.order'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const CANCELLATION_REASON_EXPIRED = 'expired'; @@ -50,6 +47,90 @@ class Order extends \Stripe\ApiResource const STATUS_DELIVERED = 'delivered'; const STATUS_OPEN = 'open'; + /** + * Creates a Climate order object for a given Climate product. The order will be + * processed immediately after creation and payment will be deducted your Stripe + * balance. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Climate\Order 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; + } + + /** + * Lists all Climate order objects. The orders are returned sorted by creation + * date, with the most recently created orders appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Climate\Order> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Climate order object with the given ID. + * + * @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 \Stripe\Climate\Order + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified order by setting the values of the parameters passed. + * + * @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 \Stripe\Climate\Order 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 $params * @param null|array|string $opts diff --git a/lib/Climate/Product.php b/lib/Climate/Product.php index 2c33a294c..3b7bc61c1 100644 --- a/lib/Climate/Product.php +++ b/lib/Climate/Product.php @@ -22,6 +22,39 @@ class Product extends \Stripe\ApiResource { const OBJECT_NAME = 'climate.product'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; + /** + * Lists all available Climate product objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Climate\Product> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Climate product with the given ID. + * + * @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 \Stripe\Climate\Product + */ + 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/lib/Climate/Supplier.php b/lib/Climate/Supplier.php index b32943868..4b298c9d6 100644 --- a/lib/Climate/Supplier.php +++ b/lib/Climate/Supplier.php @@ -19,10 +19,43 @@ class Supplier extends \Stripe\ApiResource { const OBJECT_NAME = 'climate.supplier'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const REMOVAL_PATHWAY_BIOMASS_CARBON_REMOVAL_AND_STORAGE = 'biomass_carbon_removal_and_storage'; const REMOVAL_PATHWAY_DIRECT_AIR_CAPTURE = 'direct_air_capture'; const REMOVAL_PATHWAY_ENHANCED_WEATHERING = 'enhanced_weathering'; + + /** + * Lists all available Climate supplier objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Climate\Supplier> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Climate supplier object. + * + * @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 \Stripe\Climate\Supplier + */ + 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/lib/ConfirmationToken.php b/lib/ConfirmationToken.php index 8fbd8eb16..0ef4b8a99 100644 --- a/lib/ConfirmationToken.php +++ b/lib/ConfirmationToken.php @@ -32,8 +32,25 @@ class ConfirmationToken extends ApiResource { const OBJECT_NAME = 'confirmation_token'; - use ApiOperations\Retrieve; - const SETUP_FUTURE_USAGE_OFF_SESSION = 'off_session'; const SETUP_FUTURE_USAGE_ON_SESSION = 'on_session'; + + /** + * Retrieves an existing ConfirmationToken object. + * + * @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 \Stripe\ConfirmationToken + */ + 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/lib/CountrySpec.php b/lib/CountrySpec.php index 260e54892..aa601a7ac 100644 --- a/lib/CountrySpec.php +++ b/lib/CountrySpec.php @@ -25,6 +25,39 @@ class CountrySpec extends ApiResource { const OBJECT_NAME = 'country_spec'; - use ApiOperations\All; - use ApiOperations\Retrieve; + /** + * Lists all Country Spec objects available in the API. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\CountrySpec> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns a Country Spec for a given Country code. + * + * @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 \Stripe\CountrySpec + */ + 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/lib/Coupon.php b/lib/Coupon.php index 720b33a09..2f7ea7b54 100644 --- a/lib/Coupon.php +++ b/lib/Coupon.php @@ -31,14 +31,130 @@ class Coupon extends ApiResource { const OBJECT_NAME = 'coupon'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; use ApiOperations\Update; const DURATION_FOREVER = 'forever'; const DURATION_ONCE = 'once'; const DURATION_REPEATING = 'repeating'; const DURATION_VARIABLE = 'variable'; + + /** + * You can create coupons easily via the coupon management page of the + * Stripe dashboard. Coupon creation is also accessible via the API if you need to + * create coupons on the fly. + * + * A coupon has either a percent_off or an amount_off and + * currency. If you set an amount_off, that amount will + * be subtracted from any invoice’s subtotal. For example, an invoice with a + * subtotal of 100 will have a final total of + * 0 if a coupon with an amount_off of + * 200 is applied to it and an invoice with a subtotal of + * 300 will have a final total of 100 if + * a coupon with an amount_off of 200 is applied to + * it. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Coupon 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; + } + + /** + * You can delete coupons via the coupon management page of the + * Stripe dashboard. However, deleting a coupon does not affect any customers who + * have already applied the coupon; it means that new customers can’t redeem the + * coupon. You can also delete coupons via the API. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Coupon 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; + } + + /** + * Returns a list of your coupons. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Coupon> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the coupon with the given ID. + * + * @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 \Stripe\Coupon + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the metadata of a coupon. Other coupon details (currency, duration, + * amount_off) are, by design, not editable. + * + * @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 \Stripe\Coupon 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; + } } diff --git a/lib/CreditNote.php b/lib/CreditNote.php index 9ab135a3d..24f9f8689 100644 --- a/lib/CreditNote.php +++ b/lib/CreditNote.php @@ -47,10 +47,7 @@ class CreditNote extends ApiResource { const OBJECT_NAME = 'credit_note'; - use ApiOperations\All; - use ApiOperations\Create; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Update; const REASON_DUPLICATE = 'duplicate'; @@ -64,6 +61,106 @@ class CreditNote extends ApiResource const TYPE_POST_PAYMENT = 'post_payment'; const TYPE_PRE_PAYMENT = 'pre_payment'; + /** + * Issue a credit note to adjust the amount of a finalized invoice. For a + * status=open invoice, a credit note reduces its + * amount_due. For a status=paid invoice, a credit note + * does not affect its amount_due. Instead, it can result in any + * combination of the following:. + * + * + * + * For post-payment credit notes the sum of the refund, credit and outside of + * Stripe amounts must equal the credit note total. + * + * You may issue multiple credit notes for an invoice. Each credit note will + * increment the invoice’s pre_payment_credit_notes_amount or + * post_payment_credit_notes_amount depending on its + * status at the time of credit note creation. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\CreditNote 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; + } + + /** + * Returns a list of credit notes. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\CreditNote> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the credit note object with the given identifier. + * + * @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 \Stripe\CreditNote + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing credit note. + * + * @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 \Stripe\CreditNote 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 $params * @param null|array|string $opts diff --git a/lib/Customer.php b/lib/Customer.php index f4a5c9f83..a89347462 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -42,11 +42,7 @@ class Customer extends ApiResource { const OBJECT_NAME = 'customer'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -54,6 +50,122 @@ class Customer extends ApiResource const TAX_EXEMPT_NONE = 'none'; const TAX_EXEMPT_REVERSE = 'reverse'; + /** + * Creates a new customer object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Customer 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; + } + + /** + * Permanently deletes a customer. It cannot be undone. Also immediately cancels + * any active subscriptions on the customer. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Customer 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; + } + + /** + * Returns a list of your customers. The customers are returned sorted by creation + * date, with the most recent customers appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Customer> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Customer object. + * + * @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 \Stripe\Customer + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified customer by setting the values of the parameters passed. + * Any parameters not provided will be left unchanged. For example, if you pass the + * source parameter, that becomes the customer’s active source + * (e.g., a card) to be used for all charges in the future. When you update a + * customer to a new valid card source by passing the source + * parameter: for each of the customer’s current subscriptions, if the subscription + * bills automatically and is in the past_due state, then the latest + * open invoice for the subscription with automatic collection enabled will be + * retried. This retry will not count as an automatic retry, and will not affect + * the next regularly scheduled payment for the invoice. Changing the + * default_source for a customer will not trigger this behavior. + * + * This request accepts mostly the same arguments as the customer creation call. + * + * @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 \Stripe\Customer 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; + } + public static function getSavedNestedResources() { static $savedNestedResources = null; diff --git a/lib/CustomerSession.php b/lib/CustomerSession.php index 3d0038989..6c4db5d72 100644 --- a/lib/CustomerSession.php +++ b/lib/CustomerSession.php @@ -20,5 +20,27 @@ class CustomerSession extends ApiResource { const OBJECT_NAME = 'customer_session'; - use ApiOperations\Create; + /** + * Creates a customer session object that includes a single-use client secret that + * you can use on your front-end to grant client-side API access for certain + * customer resources. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\CustomerSession 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/lib/Dispute.php b/lib/Dispute.php index 7f1eb7fae..4db0661bb 100644 --- a/lib/Dispute.php +++ b/lib/Dispute.php @@ -34,8 +34,6 @@ class Dispute extends ApiResource { const OBJECT_NAME = 'dispute'; - use ApiOperations\All; - use ApiOperations\Retrieve; use ApiOperations\Update; const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process'; @@ -61,6 +59,73 @@ class Dispute extends ApiResource const STATUS_WARNING_UNDER_REVIEW = 'warning_under_review'; const STATUS_WON = 'won'; + /** + * Returns a list of your disputes. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Dispute> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the dispute with the given ID. + * + * @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 \Stripe\Dispute + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * When you get a dispute, contacting your customer is always the best first step. + * If that doesn’t work, you can submit evidence to help us resolve the dispute in + * your favor. You can do this in your dashboard, but if you prefer, + * you can use the API to submit evidence programmatically. + * + * Depending on your dispute type, different evidence fields will give you a better + * chance of winning your dispute. To figure out which evidence fields to provide, + * see our guide to dispute types. + * + * @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 \Stripe\Dispute 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 $params * @param null|array|string $opts diff --git a/lib/Entitlements/ActiveEntitlement.php b/lib/Entitlements/ActiveEntitlement.php index 6ada49d22..d3ea3265e 100644 --- a/lib/Entitlements/ActiveEntitlement.php +++ b/lib/Entitlements/ActiveEntitlement.php @@ -17,6 +17,39 @@ class ActiveEntitlement extends \Stripe\ApiResource { const OBJECT_NAME = 'entitlements.active_entitlement'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; + /** + * Retrieve a list of active entitlements for a customer. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Entitlements\ActiveEntitlement> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve an active entitlement. + * + * @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 \Stripe\Entitlements\ActiveEntitlement + */ + 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/lib/Entitlements/Feature.php b/lib/Entitlements/Feature.php index f7e7aa92b..f7cd75c39 100644 --- a/lib/Entitlements/Feature.php +++ b/lib/Entitlements/Feature.php @@ -20,8 +20,86 @@ class Feature extends \Stripe\ApiResource { const OBJECT_NAME = 'entitlements.feature'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + + /** + * Creates a feature. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Entitlements\Feature 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; + } + + /** + * Retrieve a list of features. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Entitlements\Feature> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a feature. + * + * @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 \Stripe\Entitlements\Feature + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update a feature’s metadata or permanently deactivate it. + * + * @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 \Stripe\Entitlements\Feature 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; + } } diff --git a/lib/EphemeralKey.php b/lib/EphemeralKey.php index 45055e8ca..b69b02220 100644 --- a/lib/EphemeralKey.php +++ b/lib/EphemeralKey.php @@ -16,12 +16,31 @@ class EphemeralKey extends ApiResource { const OBJECT_NAME = 'ephemeral_key'; + /** + * Invalidates a short-lived API key for a given resource. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\EphemeralKey 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; + } + use ApiOperations\Create { create as protected _create; } - use ApiOperations\Delete; - /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Event.php b/lib/Event.php index 88c977c3b..50f3eb26c 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -55,9 +55,6 @@ class Event extends ApiResource { const OBJECT_NAME = 'event'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const ACCOUNT_APPLICATION_AUTHORIZED = 'account.application.authorized'; const ACCOUNT_APPLICATION_DEAUTHORIZED = 'account.application.deauthorized'; const ACCOUNT_EXTERNAL_ACCOUNT_CREATED = 'account.external_account.created'; @@ -575,4 +572,45 @@ class Event extends ApiResource const TYPE_TREASURY_RECEIVED_CREDIT_FAILED = 'treasury.received_credit.failed'; const TYPE_TREASURY_RECEIVED_CREDIT_SUCCEEDED = 'treasury.received_credit.succeeded'; const TYPE_TREASURY_RECEIVED_DEBIT_CREATED = 'treasury.received_debit.created'; + + /** + * List events, going back up to 30 days. Each event data is rendered according to + * Stripe API version at its creation time, specified in event object + * api_version attribute (not according to your current Stripe API + * version or Stripe-Version header). + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Event> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an event. Supply the unique identifier of the event, + * which you might have received in a webhook. + * + * @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 \Stripe\Event + */ + 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/lib/ExchangeRate.php b/lib/ExchangeRate.php index d8c621f28..dbfda216f 100644 --- a/lib/ExchangeRate.php +++ b/lib/ExchangeRate.php @@ -40,6 +40,41 @@ class ExchangeRate extends ApiResource { const OBJECT_NAME = 'exchange_rate'; - use ApiOperations\All; - use ApiOperations\Retrieve; + /** + * Returns a list of objects that contain the rates at which foreign currencies are + * converted to one another. Only shows the currencies for which Stripe supports. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\ExchangeRate> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the exchange rates from the given currency to every supported + * currency. + * + * @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 \Stripe\ExchangeRate + */ + 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/lib/File.php b/lib/File.php index b64c77a5c..73a0a0803 100644 --- a/lib/File.php +++ b/lib/File.php @@ -29,9 +29,6 @@ class File extends ApiResource { const OBJECT_NAME = 'file'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const PURPOSE_ACCOUNT_REQUIREMENT = 'account_requirement'; const PURPOSE_ADDITIONAL_VERIFICATION = 'additional_verification'; const PURPOSE_BUSINESS_ICON = 'business_icon'; @@ -48,6 +45,46 @@ class File extends ApiResource const PURPOSE_TAX_DOCUMENT_USER_UPLOAD = 'tax_document_user_upload'; const PURPOSE_TERMINAL_READER_SPLASHSCREEN = 'terminal_reader_splashscreen'; + /** + * Returns a list of the files that your account has access to. Stripe sorts and + * returns the files by their creation dates, placing the most recently created + * files at the top. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\File> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing file object. After you supply a unique file + * ID, Stripe returns the corresponding file object. Learn how to access file contents. + * + * @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 \Stripe\File + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + // This resource can have two different object names. In latter API // versions, only `file` is used, but since stripe-php may be used with // any API version, we need to support deserializing the older diff --git a/lib/FileLink.php b/lib/FileLink.php index cab855eb6..8c449223e 100644 --- a/lib/FileLink.php +++ b/lib/FileLink.php @@ -23,8 +23,86 @@ class FileLink extends ApiResource { const OBJECT_NAME = 'file_link'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * Creates a new file link object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\FileLink 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; + } + + /** + * Returns a list of file links. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\FileLink> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the file link with the given ID. + * + * @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 \Stripe\FileLink + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing file link object. Expired links can no longer be updated. + * + * @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 \Stripe\FileLink 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; + } } diff --git a/lib/FinancialConnections/Account.php b/lib/FinancialConnections/Account.php index b06417e36..73f9f5b0b 100644 --- a/lib/FinancialConnections/Account.php +++ b/lib/FinancialConnections/Account.php @@ -32,9 +32,7 @@ class Account extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.account'; - use \Stripe\ApiOperations\All; use \Stripe\ApiOperations\NestedResource; - use \Stripe\ApiOperations\Retrieve; const CATEGORY_CASH = 'cash'; const CATEGORY_CREDIT = 'credit'; @@ -52,6 +50,42 @@ class Account extends \Stripe\ApiResource const SUBCATEGORY_OTHER = 'other'; const SUBCATEGORY_SAVINGS = 'savings'; + /** + * Returns a list of Financial Connections Account objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\FinancialConnections\Account> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an Financial Connections Account. + * + * @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 \Stripe\FinancialConnections\Account + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/FinancialConnections/Session.php b/lib/FinancialConnections/Session.php index 91fa0033a..601b28fd5 100644 --- a/lib/FinancialConnections/Session.php +++ b/lib/FinancialConnections/Session.php @@ -26,11 +26,51 @@ class Session extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.session'; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const STATUS_CANCELLED = 'cancelled'; const STATUS_FAILED = 'failed'; const STATUS_PENDING = 'pending'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * To launch the Financial Connections authorization flow, create a + * Session. The session’s client_secret can be used to + * launch the flow using Stripe.js. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\FinancialConnections\Session 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; + } + + /** + * Retrieves the details of a Financial Connections Session. + * + * @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 \Stripe\FinancialConnections\Session + */ + 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/lib/FinancialConnections/Transaction.php b/lib/FinancialConnections/Transaction.php index be27ae58a..8f90ab6be 100644 --- a/lib/FinancialConnections/Transaction.php +++ b/lib/FinancialConnections/Transaction.php @@ -24,10 +24,43 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const STATUS_PENDING = 'pending'; const STATUS_POSTED = 'posted'; const STATUS_VOID = 'void'; + + /** + * Returns a list of Financial Connections Transaction objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\FinancialConnections\Transaction> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Financial Connections Transaction. + * + * @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 \Stripe\FinancialConnections\Transaction + */ + 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/lib/Forwarding/Request.php b/lib/Forwarding/Request.php index 0af5eb74e..f772c91bf 100644 --- a/lib/Forwarding/Request.php +++ b/lib/Forwarding/Request.php @@ -37,7 +37,61 @@ class Request extends \Stripe\ApiResource { const OBJECT_NAME = 'forwarding.request'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; + /** + * Creates a ForwardingRequest object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Forwarding\Request 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; + } + + /** + * Lists all ForwardingRequest objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Forwarding\Request> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ForwardingRequest object. + * + * @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 \Stripe\Forwarding\Request + */ + 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/lib/GiftCards/Card.php b/lib/GiftCards/Card.php index 64e05ab99..871256863 100644 --- a/lib/GiftCards/Card.php +++ b/lib/GiftCards/Card.php @@ -24,11 +24,89 @@ class Card extends \Stripe\ApiResource { const OBJECT_NAME = 'gift_cards.card'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + /** + * Creates a new gift card object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\GiftCards\Card 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; + } + + /** + * List gift cards for an account. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\GiftCards\Card> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve a gift card by id. + * + * @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 \Stripe\GiftCards\Card + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update a gift card. + * + * @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 \Stripe\GiftCards\Card 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 $params * @param null|array|string $opts diff --git a/lib/GiftCards/Transaction.php b/lib/GiftCards/Transaction.php index 6a67cdf2b..3b3656250 100644 --- a/lib/GiftCards/Transaction.php +++ b/lib/GiftCards/Transaction.php @@ -29,9 +29,6 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'gift_cards.transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_CANCELED = 'canceled'; @@ -39,6 +36,87 @@ class Transaction extends \Stripe\ApiResource const STATUS_HELD = 'held'; const STATUS_INVALID = 'invalid'; + /** + * Create a gift card transaction. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\GiftCards\Transaction 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; + } + + /** + * List gift card transactions for a gift card. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\GiftCards\Transaction> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the gift card transaction. + * + * @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 \Stripe\GiftCards\Transaction + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update a gift card transaction. + * + * @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 \Stripe\GiftCards\Transaction 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 $params * @param null|array|string $opts diff --git a/lib/Identity/VerificationReport.php b/lib/Identity/VerificationReport.php index 27ae08dbe..77fa02c68 100644 --- a/lib/Identity/VerificationReport.php +++ b/lib/Identity/VerificationReport.php @@ -36,10 +36,43 @@ class VerificationReport extends \Stripe\ApiResource { const OBJECT_NAME = 'identity.verification_report'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const TYPE_DOCUMENT = 'document'; const TYPE_ID_NUMBER = 'id_number'; const TYPE_VERIFICATION_FLOW = 'verification_flow'; + + /** + * List all verification reports. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Identity\VerificationReport> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an existing VerificationReport. + * + * @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 \Stripe\Identity\VerificationReport + */ + 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/lib/Identity/VerificationSession.php b/lib/Identity/VerificationSession.php index 3760a24fc..8ba9a663c 100644 --- a/lib/Identity/VerificationSession.php +++ b/lib/Identity/VerificationSession.php @@ -39,9 +39,6 @@ class VerificationSession extends \Stripe\ApiResource { const OBJECT_NAME = 'identity.verification_session'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_CANCELED = 'canceled'; @@ -53,6 +50,104 @@ class VerificationSession extends \Stripe\ApiResource const TYPE_ID_NUMBER = 'id_number'; const TYPE_VERIFICATION_FLOW = 'verification_flow'; + /** + * Creates a VerificationSession object. + * + * After the VerificationSession is created, display a verification modal using the + * session client_secret or send your users to the session’s + * url. + * + * If your API key is in test mode, verification checks won’t actually process, + * though everything else will occur as if in live mode. + * + * Related guide: Verify your + * users’ identity documents + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Identity\VerificationSession 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; + } + + /** + * Returns a list of VerificationSessions. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Identity\VerificationSession> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a VerificationSession that was previously created. + * + * When the session status is requires_input, you can use this method + * to retrieve a valid client_secret or url to allow + * re-submission. + * + * @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 \Stripe\Identity\VerificationSession + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a VerificationSession object. + * + * When the session status is requires_input, you can use this method + * to update the verification check and options. + * + * @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 \Stripe\Identity\VerificationSession 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 $params * @param null|array|string $opts diff --git a/lib/Invoice.php b/lib/Invoice.php index 152622757..e313d7d03 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -129,11 +129,7 @@ class Invoice extends ApiResource { const OBJECT_NAME = 'invoice'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -160,6 +156,123 @@ class Invoice extends ApiResource const STATUS_UNCOLLECTIBLE = 'uncollectible'; const STATUS_VOID = 'void'; + /** + * This endpoint creates a draft invoice for a given customer. The invoice remains + * a draft until you finalize the invoice, which + * allows you to pay or send + * the invoice to your customers. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Invoice 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; + } + + /** + * Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to + * delete invoices that are no longer in a draft state will fail; once an invoice + * has been finalized or if an invoice is for a subscription, it must be voided. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Invoice 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; + } + + /** + * You can list all invoices, or list the invoices for a specific customer. The + * invoices are returned sorted by creation date, with the most recently created + * invoices appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Invoice> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the invoice with the given ID. + * + * @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 \Stripe\Invoice + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Draft invoices are fully editable. Once an invoice is finalized, monetary values, + * as well as collection_method, become uneditable. + * + * If you would like to stop the Stripe Billing engine from automatically + * finalizing, reattempting payments on, sending reminders for, or automatically reconciling + * invoices, pass auto_advance=false. + * + * @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 \Stripe\Invoice 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; + } + const BILLING_CHARGE_AUTOMATICALLY = 'charge_automatically'; const BILLING_SEND_INVOICE = 'send_invoice'; diff --git a/lib/InvoiceItem.php b/lib/InvoiceItem.php index a47d08e73..e5127b010 100644 --- a/lib/InvoiceItem.php +++ b/lib/InvoiceItem.php @@ -46,9 +46,114 @@ class InvoiceItem extends ApiResource { const OBJECT_NAME = 'invoiceitem'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * Creates an item to be added to a draft invoice (up to 250 items per invoice). If + * no invoice is specified, the item will be on the next invoice created for the + * customer specified. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\InvoiceItem 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; + } + + /** + * Deletes an invoice item, removing it from an invoice. Deleting invoice items is + * only possible when they’re not attached to invoices, or if it’s attached to a + * draft invoice. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\InvoiceItem 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; + } + + /** + * Returns a list of your invoice items. Invoice items are returned sorted by + * creation date, with the most recently created invoice items appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\InvoiceItem> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the invoice item with the given ID. + * + * @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 \Stripe\InvoiceItem + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the amount or description of an invoice item on an upcoming invoice. + * Updating an invoice item is only possible before the invoice it’s attached to is + * closed. + * + * @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 \Stripe\InvoiceItem 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; + } } diff --git a/lib/InvoiceLineItem.php b/lib/InvoiceLineItem.php index 1ff5db594..06b1272bc 100644 --- a/lib/InvoiceLineItem.php +++ b/lib/InvoiceLineItem.php @@ -38,4 +38,32 @@ class InvoiceLineItem extends ApiResource const OBJECT_NAME = 'line_item'; use ApiOperations\Update; + + /** + * Updates an invoice’s line item. Some fields, such as tax_amounts, + * only live on the invoice line item, so they can only be updated through this + * endpoint. Other fields, such as amount, live on both the invoice + * item and the invoice line item, so updates on this endpoint will propagate to + * the invoice item as well. Updating an invoice’s line item is only possible + * before the invoice is finalized. + * + * @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 \Stripe\InvoiceLineItem 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; + } } diff --git a/lib/Issuing/Authorization.php b/lib/Issuing/Authorization.php index 7fa73ffb3..f675cb167 100644 --- a/lib/Issuing/Authorization.php +++ b/lib/Issuing/Authorization.php @@ -41,8 +41,6 @@ class Authorization extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.authorization'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const AUTHORIZATION_METHOD_CHIP = 'chip'; @@ -55,6 +53,69 @@ class Authorization extends \Stripe\ApiResource const STATUS_PENDING = 'pending'; const STATUS_REVERSED = 'reversed'; + /** + * Returns a list of Issuing Authorization objects. The objects are + * sorted in descending order by creation date, with the most recently created + * object appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\Authorization> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Authorization object. + * + * @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 \Stripe\Issuing\Authorization + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Authorization object by setting the + * values of the parameters passed. Any parameters not provided will be left + * unchanged. + * + * @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 \Stripe\Issuing\Authorization 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 $params * @param null|array|string $opts diff --git a/lib/Issuing/Card.php b/lib/Issuing/Card.php index d18a07539..5f21ce58d 100644 --- a/lib/Issuing/Card.php +++ b/lib/Issuing/Card.php @@ -36,9 +36,6 @@ class Card extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.card'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const CANCELLATION_REASON_DESIGN_REJECTED = 'design_rejected'; @@ -56,4 +53,88 @@ class Card extends \Stripe\ApiResource const TYPE_PHYSICAL = 'physical'; const TYPE_VIRTUAL = 'virtual'; + + /** + * Creates an Issuing Card object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Issuing\Card 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; + } + + /** + * Returns a list of Issuing Card objects. The objects are sorted in + * descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\Card> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Card object. + * + * @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 \Stripe\Issuing\Card + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Card object by setting the values of + * the parameters passed. Any parameters not provided will be left unchanged. + * + * @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 \Stripe\Issuing\Card 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; + } } diff --git a/lib/Issuing/Cardholder.php b/lib/Issuing/Cardholder.php index b98e74d42..14de48703 100644 --- a/lib/Issuing/Cardholder.php +++ b/lib/Issuing/Cardholder.php @@ -30,9 +30,6 @@ class Cardholder extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.cardholder'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_ACTIVE = 'active'; @@ -41,4 +38,89 @@ class Cardholder extends \Stripe\ApiResource const TYPE_COMPANY = 'company'; const TYPE_INDIVIDUAL = 'individual'; + + /** + * Creates a new Issuing Cardholder object that can be issued cards. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Issuing\Cardholder 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; + } + + /** + * Returns a list of Issuing Cardholder objects. The objects are + * sorted in descending order by creation date, with the most recently created + * object appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\Cardholder> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Cardholder object. + * + * @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 \Stripe\Issuing\Cardholder + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Cardholder object by setting the + * values of the parameters passed. Any parameters not provided will be left + * unchanged. + * + * @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 \Stripe\Issuing\Cardholder 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; + } } diff --git a/lib/Issuing/CreditUnderwritingRecord.php b/lib/Issuing/CreditUnderwritingRecord.php index da121aa9c..5c690a654 100644 --- a/lib/Issuing/CreditUnderwritingRecord.php +++ b/lib/Issuing/CreditUnderwritingRecord.php @@ -26,12 +26,47 @@ class CreditUnderwritingRecord extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.credit_underwriting_record'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const CREATED_FROM_APPLICATION = 'application'; const CREATED_FROM_PROACTIVE_REVIEW = 'proactive_review'; + /** + * Retrieves a list of CreditUnderwritingRecord objects. The objects + * are sorted in descending order by creation date, with the most-recently-created + * object appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\CreditUnderwritingRecord> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a CreditUnderwritingRecord object. + * + * @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 \Stripe\Issuing\CreditUnderwritingRecord + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Issuing/Dispute.php b/lib/Issuing/Dispute.php index bc37efe27..b05c7e870 100644 --- a/lib/Issuing/Dispute.php +++ b/lib/Issuing/Dispute.php @@ -27,9 +27,6 @@ class Dispute extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.dispute'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const LOSS_REASON_CARDHOLDER_AUTHENTICATION_ISSUER_LIABILITY = 'cardholder_authentication_issuer_liability'; @@ -59,6 +56,96 @@ class Dispute extends \Stripe\ApiResource const STATUS_UNSUBMITTED = 'unsubmitted'; const STATUS_WON = 'won'; + /** + * Creates an Issuing Dispute object. Individual pieces of evidence + * within the evidence object are optional at this point. Stripe only + * validates that required evidence is present during submission. Refer to Dispute + * reasons and evidence for more details about evidence requirements. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Issuing\Dispute 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; + } + + /** + * Returns a list of Issuing Dispute objects. The objects are sorted + * in descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\Dispute> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Dispute object. + * + * @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 \Stripe\Issuing\Dispute + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Dispute object by setting the values + * of the parameters passed. Any parameters not provided will be left unchanged. + * Properties on the evidence object can be unset by passing in an + * empty string. + * + * @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 \Stripe\Issuing\Dispute 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 $params * @param null|array|string $opts diff --git a/lib/Issuing/PersonalizationDesign.php b/lib/Issuing/PersonalizationDesign.php index 74af892aa..d2e472a57 100644 --- a/lib/Issuing/PersonalizationDesign.php +++ b/lib/Issuing/PersonalizationDesign.php @@ -25,13 +25,93 @@ class PersonalizationDesign extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.personalization_design'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; const STATUS_REJECTED = 'rejected'; const STATUS_REVIEW = 'review'; + + /** + * Creates a personalization design object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Issuing\PersonalizationDesign 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; + } + + /** + * Returns a list of personalization design objects. The objects are sorted in + * descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\PersonalizationDesign> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a personalization design object. + * + * @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 \Stripe\Issuing\PersonalizationDesign + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a card personalization object. + * + * @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 \Stripe\Issuing\PersonalizationDesign 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; + } } diff --git a/lib/Issuing/PhysicalBundle.php b/lib/Issuing/PhysicalBundle.php index 3a978cba1..419a0205d 100644 --- a/lib/Issuing/PhysicalBundle.php +++ b/lib/Issuing/PhysicalBundle.php @@ -9,7 +9,7 @@ * * @property string $id Unique identifier for the object. * @property string $object String representing the object's type. Objects of the same type share the same value. - * @property null|\Stripe\StripeObject $features + * @property \Stripe\StripeObject $features * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. * @property string $name Friendly display name. * @property string $status Whether this physical bundle can be used to create cards. @@ -19,13 +19,47 @@ class PhysicalBundle extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.physical_bundle'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; const STATUS_REVIEW = 'review'; const TYPE_CUSTOM = 'custom'; const TYPE_STANDARD = 'standard'; + + /** + * Returns a list of physical bundle objects. The objects are sorted in descending + * order by creation date, with the most recently created object appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\PhysicalBundle> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a physical bundle object. + * + * @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 \Stripe\Issuing\PhysicalBundle + */ + 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/lib/Issuing/Token.php b/lib/Issuing/Token.php index d475cc5c7..196c7aba3 100644 --- a/lib/Issuing/Token.php +++ b/lib/Issuing/Token.php @@ -24,8 +24,6 @@ class Token extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.token'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const NETWORK_MASTERCARD = 'mastercard'; @@ -39,4 +37,64 @@ class Token extends \Stripe\ApiResource const WALLET_PROVIDER_APPLE_PAY = 'apple_pay'; const WALLET_PROVIDER_GOOGLE_PAY = 'google_pay'; const WALLET_PROVIDER_SAMSUNG_PAY = 'samsung_pay'; + + /** + * Lists all Issuing Token objects for a given card. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\Token> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Token object. + * + * @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 \Stripe\Issuing\Token + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Attempts to update the specified Issuing Token object to the status + * specified. + * + * @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 \Stripe\Issuing\Token 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; + } } diff --git a/lib/Issuing/Transaction.php b/lib/Issuing/Transaction.php index 50825c480..45585a010 100644 --- a/lib/Issuing/Transaction.php +++ b/lib/Issuing/Transaction.php @@ -38,8 +38,6 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'issuing.transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const TYPE_CAPTURE = 'capture'; @@ -48,4 +46,67 @@ class Transaction extends \Stripe\ApiResource const WALLET_APPLE_PAY = 'apple_pay'; const WALLET_GOOGLE_PAY = 'google_pay'; const WALLET_SAMSUNG_PAY = 'samsung_pay'; + + /** + * Returns a list of Issuing Transaction objects. The objects are + * sorted in descending order by creation date, with the most recently created + * object appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Issuing\Transaction> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Transaction object. + * + * @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 \Stripe\Issuing\Transaction + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified Issuing Transaction object by setting the + * values of the parameters passed. Any parameters not provided will be left + * unchanged. + * + * @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 \Stripe\Issuing\Transaction 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; + } } diff --git a/lib/Mandate.php b/lib/Mandate.php index 838aa47e9..0974b96a3 100644 --- a/lib/Mandate.php +++ b/lib/Mandate.php @@ -23,12 +23,29 @@ class Mandate extends ApiResource { const OBJECT_NAME = 'mandate'; - use ApiOperations\Retrieve; - const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; const STATUS_PENDING = 'pending'; const TYPE_MULTI_USE = 'multi_use'; const TYPE_SINGLE_USE = 'single_use'; + + /** + * Retrieves a Mandate object. + * + * @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 \Stripe\Mandate + */ + 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/lib/Margin.php b/lib/Margin.php index b3b57b86a..f3c2aaf3a 100644 --- a/lib/Margin.php +++ b/lib/Margin.php @@ -22,8 +22,92 @@ class Margin extends ApiResource { const OBJECT_NAME = 'margin'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * Create a margin object to be used with invoices, invoice items, and invoice line + * items for a customer to represent a partner discount.A margin has a + * percent_off which is the percent that will be taken off the + * subtotal after all items and other discounts and promotions) of any invoices for + * a customer. Calculation of prorations do not include any partner margins applied + * on the original invoice item. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Margin 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; + } + + /** + * Retrieve a list of your margins. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Margin> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve a margin object with the given ID. + * + * @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 \Stripe\Margin + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update the specified margin object. Certain fields of the margin object are not + * editable. + * + * @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 \Stripe\Margin 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; + } } diff --git a/lib/Order.php b/lib/Order.php index 12aa35596..8cdefeb21 100644 --- a/lib/Order.php +++ b/lib/Order.php @@ -41,9 +41,6 @@ class Order extends ApiResource { const OBJECT_NAME = 'order'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const STATUS_CANCELED = 'canceled'; @@ -52,6 +49,91 @@ class Order extends ApiResource const STATUS_PROCESSING = 'processing'; const STATUS_SUBMITTED = 'submitted'; + /** + * Creates a new open order object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Order 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; + } + + /** + * Returns a list of your orders. The orders are returned sorted by creation date, + * with the most recently created orders appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Order> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing order. Supply the unique order ID from + * either an order creation request or the order list, and Stripe will return the + * corresponding order information. + * + * @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 \Stripe\Order + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specific order by setting the values of the parameters passed. Any + * parameters not provided will be left unchanged. + * + * @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 \Stripe\Order 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 $params * @param null|array|string $opts diff --git a/lib/PaymentIntent.php b/lib/PaymentIntent.php index acb88b4b5..740592bd0 100644 --- a/lib/PaymentIntent.php +++ b/lib/PaymentIntent.php @@ -64,9 +64,6 @@ class PaymentIntent extends ApiResource { const OBJECT_NAME = 'payment_intent'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -99,6 +96,110 @@ class PaymentIntent extends ApiResource const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Creates a PaymentIntent object. + * + * After the PaymentIntent is created, attach a payment method and confirm to continue the payment. + * Learn more about the available payment + * flows with the Payment Intents API. + * + * When you use confirm=true during creation, it’s equivalent to + * creating and confirming the PaymentIntent in the same call. You can use any + * parameters available in the confirm + * API when you supply confirm=true. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\PaymentIntent 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; + } + + /** + * Returns a list of PaymentIntents. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\PaymentIntent> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a PaymentIntent that has previously been created. + * + * You can retrieve a PaymentIntent client-side using a publishable key when the + * client_secret is in the query string. + * + * If you retrieve a PaymentIntent with a publishable key, it only returns a subset + * of properties. Refer to the payment intent + * object reference for more details. + * + * @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 \Stripe\PaymentIntent + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates properties on a PaymentIntent object without confirming. + * + * Depending on which properties you update, you might need to confirm the + * PaymentIntent again. For example, updating the payment_method + * always requires you to confirm the PaymentIntent again. If you prefer to update + * and confirm at the same time, we recommend updating properties through the confirm API instead. + * + * @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 \Stripe\PaymentIntent 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 $params * @param null|array|string $opts diff --git a/lib/PaymentLink.php b/lib/PaymentLink.php index 2c162773a..e65546191 100644 --- a/lib/PaymentLink.php +++ b/lib/PaymentLink.php @@ -49,9 +49,6 @@ class PaymentLink extends ApiResource { const OBJECT_NAME = 'payment_link'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const BILLING_ADDRESS_COLLECTION_AUTO = 'auto'; @@ -68,6 +65,87 @@ class PaymentLink extends ApiResource const SUBMIT_TYPE_DONATE = 'donate'; const SUBMIT_TYPE_PAY = 'pay'; + /** + * Creates a payment link. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\PaymentLink 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; + } + + /** + * Returns a list of your payment links. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\PaymentLink> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve a payment link. + * + * @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 \Stripe\PaymentLink + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a payment link. + * + * @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 \Stripe\PaymentLink 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 string $id * @param null|array $params diff --git a/lib/PaymentMethod.php b/lib/PaymentMethod.php index bd757e30e..4736aed39 100644 --- a/lib/PaymentMethod.php +++ b/lib/PaymentMethod.php @@ -67,9 +67,6 @@ class PaymentMethod extends ApiResource { const OBJECT_NAME = 'payment_method'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const ALLOW_REDISPLAY_ALWAYS = 'always'; @@ -118,6 +115,102 @@ class PaymentMethod extends ApiResource const TYPE_WECHAT_PAY = 'wechat_pay'; const TYPE_ZIP = 'zip'; + /** + * Creates a PaymentMethod object. Read the Stripe.js + * reference to learn how to create PaymentMethods via Stripe.js. + * + * Instead of creating a PaymentMethod directly, we recommend using the PaymentIntents API to accept a + * payment immediately or the SetupIntent API to collect payment + * method details ahead of a future payment. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\PaymentMethod 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; + } + + /** + * Returns a list of PaymentMethods for Treasury flows. If you want to list the + * PaymentMethods attached to a Customer for payments, you should use the List a Customer’s + * PaymentMethods API instead. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\PaymentMethod> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a PaymentMethod object attached to the StripeAccount. To retrieve a + * payment method attached to a Customer, you should use Retrieve a Customer’s + * PaymentMethods. + * + * @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 \Stripe\PaymentMethod + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a PaymentMethod object. A PaymentMethod must be attached a customer to + * be updated. + * + * @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 \Stripe\PaymentMethod 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 $params * @param null|array|string $opts diff --git a/lib/PaymentMethodConfiguration.php b/lib/PaymentMethodConfiguration.php index 05add8cc3..ec8d60e8d 100644 --- a/lib/PaymentMethodConfiguration.php +++ b/lib/PaymentMethodConfiguration.php @@ -72,8 +72,86 @@ class PaymentMethodConfiguration extends ApiResource { const OBJECT_NAME = 'payment_method_configuration'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * Creates a payment method configuration. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\PaymentMethodConfiguration 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; + } + + /** + * List payment method configurations. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\PaymentMethodConfiguration> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve payment method configuration. + * + * @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 \Stripe\PaymentMethodConfiguration + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Update payment method configuration. + * + * @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 \Stripe\PaymentMethodConfiguration 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; + } } diff --git a/lib/PaymentMethodDomain.php b/lib/PaymentMethodDomain.php index 15920b7c9..2121adcc0 100644 --- a/lib/PaymentMethodDomain.php +++ b/lib/PaymentMethodDomain.php @@ -25,11 +25,89 @@ class PaymentMethodDomain extends ApiResource { const OBJECT_NAME = 'payment_method_domain'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + /** + * Creates a payment method domain. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\PaymentMethodDomain 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; + } + + /** + * Lists the details of existing payment method domains. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\PaymentMethodDomain> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing payment method domain. + * + * @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 \Stripe\PaymentMethodDomain + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing payment method domain. + * + * @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 \Stripe\PaymentMethodDomain 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 $params * @param null|array|string $opts diff --git a/lib/Payout.php b/lib/Payout.php index 2404e1a33..5757fcb63 100644 --- a/lib/Payout.php +++ b/lib/Payout.php @@ -44,9 +44,6 @@ class Payout extends ApiResource { const OBJECT_NAME = 'payout'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const METHOD_INSTANT = 'instant'; @@ -65,6 +62,103 @@ class Payout extends ApiResource const TYPE_BANK_ACCOUNT = 'bank_account'; const TYPE_CARD = 'card'; + /** + * To send funds to your own bank account, create a new payout object. Your Stripe balance must cover the payout amount. If it doesn’t, + * you receive an “Insufficient Funds” error. + * + * If your API key is in test mode, money won’t actually be sent, though every + * other action occurs as if you’re in live mode. + * + * If you create a manual payout on a Stripe account that uses multiple payment + * source types, you need to specify the source type balance that the payout draws + * from. The balance object details available and + * pending amounts by source type. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Payout 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; + } + + /** + * Returns a list of existing payouts sent to third-party bank accounts or payouts + * that Stripe sent to you. The payouts return in sorted order, with the most + * recently created payouts appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Payout> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing payout. Supply the unique payout ID from + * either a payout creation request or the payout list. Stripe returns the + * corresponding payout information. + * + * @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 \Stripe\Payout + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified payout by setting the values of the parameters you pass. + * We don’t change parameters that you don’t provide. This request only accepts the + * metadata as arguments. + * + * @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 \Stripe\Payout 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; + } + const FAILURE_ACCOUNT_CLOSED = 'account_closed'; const FAILURE_ACCOUNT_FROZEN = 'account_frozen'; const FAILURE_BANK_ACCOUNT_RESTRICTED = 'bank_account_restricted'; diff --git a/lib/Person.php b/lib/Person.php index 209efc1d2..cd79aebf4 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -58,7 +58,6 @@ class Person extends ApiResource const VERIFICATION_STATUS_VERIFIED = 'verified'; use ApiOperations\Delete; - use ApiOperations\Update; /** * @return string the API URL for this Stripe account reversal @@ -109,9 +108,32 @@ public static function retrieve($_id, $_opts = null) public static function update($_id, $_params = null, $_options = null) { $msg = 'Persons cannot be updated without an account ID. Update ' . - "a person using `Account::updatePerson('account_id', " . - "'person_id', \$updateParams)`."; + "a person using `Account::updatePerson('account_id', " . + "'person_id', \$updateParams)`."; throw new Exception\BadMethodCallException($msg); } + + /** + * @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, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } } diff --git a/lib/Plan.php b/lib/Plan.php index 348cfcbaa..53d869b71 100644 --- a/lib/Plan.php +++ b/lib/Plan.php @@ -40,10 +40,6 @@ class Plan extends ApiResource { const OBJECT_NAME = 'plan'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; use ApiOperations\Update; const AGGREGATE_USAGE_LAST_DURING_PERIOD = 'last_during_period'; @@ -64,4 +60,111 @@ class Plan extends ApiResource const USAGE_TYPE_LICENSED = 'licensed'; const USAGE_TYPE_METERED = 'metered'; + + /** + * You can now model subscriptions more flexibly using the Prices + * API. It replaces the Plans API and is backwards compatible to simplify your + * migration. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Plan 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; + } + + /** + * Deleting plans means new subscribers can’t be added. Existing subscribers aren’t + * affected. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Plan 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; + } + + /** + * Returns a list of your plans. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Plan> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the plan with the given ID. + * + * @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 \Stripe\Plan + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified plan by setting the values of the parameters passed. Any + * parameters not provided are left unchanged. By design, you cannot change a + * plan’s ID, amount, currency, or billing cycle. + * + * @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 \Stripe\Plan 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; + } } diff --git a/lib/Price.php b/lib/Price.php index 33c5e36bf..3ebe89dea 100644 --- a/lib/Price.php +++ b/lib/Price.php @@ -39,9 +39,6 @@ class Price extends ApiResource { const OBJECT_NAME = 'price'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -58,6 +55,91 @@ class Price extends ApiResource const TYPE_ONE_TIME = 'one_time'; const TYPE_RECURRING = 'recurring'; + /** + * Creates a new price for an existing product. The price can be recurring or + * one-time. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Price 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; + } + + /** + * Returns a list of your active prices, excluding inline prices. + * For the list of inactive prices, set active to false. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Price> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the price with the given ID. + * + * @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 \Stripe\Price + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified price by setting the values of the parameters passed. Any + * parameters not provided are left unchanged. + * + * @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 \Stripe\Price 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 $params * @param null|array|string $opts diff --git a/lib/Product.php b/lib/Product.php index e7f069023..49c6466d5 100644 --- a/lib/Product.php +++ b/lib/Product.php @@ -39,17 +39,121 @@ class Product extends ApiResource { const OBJECT_NAME = 'product'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; const TYPE_GOOD = 'good'; const TYPE_SERVICE = 'service'; + /** + * Creates a new product object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Product 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; + } + + /** + * Delete a product. Deleting a product is only possible if it has no prices + * associated with it. Additionally, deleting a product with type=good + * is only possible if it has no SKUs associated with it. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Product 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; + } + + /** + * Returns a list of your products. The products are returned sorted by creation + * date, with the most recently created products appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Product> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing product. Supply the unique product ID from + * either a product creation request or the product list, and Stripe will return + * the corresponding product information. + * + * @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 \Stripe\Product + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specific product by setting the values of the parameters passed. Any + * parameters not provided will be left unchanged. + * + * @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 \Stripe\Product 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 $params * @param null|array|string $opts diff --git a/lib/PromotionCode.php b/lib/PromotionCode.php index 56d395944..48a22b213 100644 --- a/lib/PromotionCode.php +++ b/lib/PromotionCode.php @@ -26,8 +26,91 @@ class PromotionCode extends ApiResource { const OBJECT_NAME = 'promotion_code'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * A promotion code points to a coupon. You can optionally restrict the code to a + * specific customer, redemption limit, and expiration date. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\PromotionCode 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; + } + + /** + * Returns a list of your promotion codes. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\PromotionCode> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the promotion code with the given ID. In order to retrieve a promotion + * code by the customer-facing code use list with the desired + * code. + * + * @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 \Stripe\PromotionCode + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified promotion code by setting the values of the parameters + * passed. Most fields are, by design, not editable. + * + * @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 \Stripe\PromotionCode 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; + } } diff --git a/lib/Quote.php b/lib/Quote.php index 0df8e2286..8247ac085 100644 --- a/lib/Quote.php +++ b/lib/Quote.php @@ -53,10 +53,7 @@ class Quote extends ApiResource { const OBJECT_NAME = 'quote'; - use ApiOperations\All; - use ApiOperations\Create; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Update; const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically'; @@ -69,6 +66,90 @@ class Quote extends ApiResource const STATUS_OPEN = 'open'; const STATUS_STALE = 'stale'; + /** + * A quote models prices and services for a customer. Default options for + * header, description, footer, and + * expires_at can be set in the dashboard via the quote template. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Quote 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; + } + + /** + * Returns a list of your quotes. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Quote> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the quote with the given ID. + * + * @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 \Stripe\Quote + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * A quote models prices and services for a customer. + * + * @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 \Stripe\Quote 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 $params * @param null|array|string $opts diff --git a/lib/QuotePhase.php b/lib/QuotePhase.php index 8176a6e9a..18e925181 100644 --- a/lib/QuotePhase.php +++ b/lib/QuotePhase.php @@ -29,9 +29,6 @@ class QuotePhase extends ApiResource { const OBJECT_NAME = 'quote_phase'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically'; const COLLECTION_METHOD_SEND_INVOICE = 'send_invoice'; @@ -39,6 +36,42 @@ class QuotePhase extends ApiResource const PRORATION_BEHAVIOR_CREATE_PRORATIONS = 'create_prorations'; const PRORATION_BEHAVIOR_NONE = 'none'; + /** + * Returns a list of quote phases. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\QuotePhase> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the quote phase with the given ID. + * + * @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 \Stripe\QuotePhase + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param string $id * @param null|array $params diff --git a/lib/Radar/EarlyFraudWarning.php b/lib/Radar/EarlyFraudWarning.php index f728ee9e6..a48ae1a5d 100644 --- a/lib/Radar/EarlyFraudWarning.php +++ b/lib/Radar/EarlyFraudWarning.php @@ -23,9 +23,6 @@ class EarlyFraudWarning extends \Stripe\ApiResource { const OBJECT_NAME = 'radar.early_fraud_warning'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FRAUD_TYPE_CARD_NEVER_RECEIVED = 'card_never_received'; const FRAUD_TYPE_FRAUDULENT_CARD_APPLICATION = 'fraudulent_card_application'; const FRAUD_TYPE_MADE_WITH_COUNTERFEIT_CARD = 'made_with_counterfeit_card'; @@ -33,4 +30,44 @@ class EarlyFraudWarning extends \Stripe\ApiResource const FRAUD_TYPE_MADE_WITH_STOLEN_CARD = 'made_with_stolen_card'; const FRAUD_TYPE_MISC = 'misc'; const FRAUD_TYPE_UNAUTHORIZED_USE_OF_CARD = 'unauthorized_use_of_card'; + + /** + * Returns a list of early fraud warnings. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Radar\EarlyFraudWarning> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an early fraud warning that has previously been + * created. + * + * Please refer to the early fraud + * warning object reference for more details. + * + * @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 \Stripe\Radar\EarlyFraudWarning + */ + 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/lib/Radar/ValueList.php b/lib/Radar/ValueList.php index f3adb8010..14afacd3b 100644 --- a/lib/Radar/ValueList.php +++ b/lib/Radar/ValueList.php @@ -24,10 +24,6 @@ class ValueList extends \Stripe\ApiResource { const OBJECT_NAME = 'radar.value_list'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const ITEM_TYPE_CARD_BIN = 'card_bin'; @@ -40,4 +36,113 @@ class ValueList extends \Stripe\ApiResource const ITEM_TYPE_SEPA_DEBIT_FINGERPRINT = 'sepa_debit_fingerprint'; const ITEM_TYPE_STRING = 'string'; const ITEM_TYPE_US_BANK_ACCOUNT_FINGERPRINT = 'us_bank_account_fingerprint'; + + /** + * Creates a new ValueList object, which can then be referenced in + * rules. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Radar\ValueList 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; + } + + /** + * Deletes a ValueList object, also deleting any items contained + * within the value list. To be deleted, a value list must not be referenced in any + * rules. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Radar\ValueList 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; + } + + /** + * Returns a list of ValueList objects. The objects are sorted in + * descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Radar\ValueList> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ValueList object. + * + * @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 \Stripe\Radar\ValueList + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a ValueList object by setting the values of the parameters + * passed. Any parameters not provided will be left unchanged. Note that + * item_type is immutable. + * + * @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 \Stripe\Radar\ValueList 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; + } } diff --git a/lib/Radar/ValueListItem.php b/lib/Radar/ValueListItem.php index f95018bdd..a40b9da88 100644 --- a/lib/Radar/ValueListItem.php +++ b/lib/Radar/ValueListItem.php @@ -21,8 +21,86 @@ class ValueListItem extends \Stripe\ApiResource { const OBJECT_NAME = 'radar.value_list_item'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; + /** + * Creates a new ValueListItem object, which is added to the specified + * parent value list. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Radar\ValueListItem 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; + } + + /** + * Deletes a ValueListItem object, removing it from its parent value + * list. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Radar\ValueListItem 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; + } + + /** + * Returns a list of ValueListItem objects. The objects are sorted in + * descending order by creation date, with the most recently created object + * appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Radar\ValueListItem> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ValueListItem object. + * + * @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 \Stripe\Radar\ValueListItem + */ + 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/lib/Refund.php b/lib/Refund.php index 7ed0b37e1..039d3b602 100644 --- a/lib/Refund.php +++ b/lib/Refund.php @@ -36,9 +36,6 @@ class Refund extends ApiResource { const OBJECT_NAME = 'refund'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const FAILURE_REASON_EXPIRED_OR_CANCELED_CARD = 'expired_or_canceled_card'; @@ -56,6 +53,104 @@ class Refund extends ApiResource const STATUS_REQUIRES_ACTION = 'requires_action'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * When you create a new refund, you must specify a Charge or a PaymentIntent + * object on which to create it. + * + * Creating a new refund will refund a charge that has previously been created but + * not yet refunded. Funds will be refunded to the credit or debit card that was + * originally charged. + * + * You can optionally refund only part of a charge. You can do so multiple times, + * until the entire charge has been refunded. + * + * Once entirely refunded, a charge can’t be refunded again. This method will raise + * an error when called on an already-refunded charge, or when trying to refund + * more money than is left on a charge. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Refund 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; + } + + /** + * Returns a list of all refunds you created. We return the refunds in sorted + * order, with the most recent refunds appearing first The 10 most recent refunds + * are always available by default on the Charge object. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Refund> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing refund. + * + * @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 \Stripe\Refund + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the refund that you specify by setting the values of the passed + * parameters. Any parameters that you don’t provide remain unchanged. + * + * This request only accepts metadata as an argument. + * + * @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 \Stripe\Refund 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 $params * @param null|array|string $opts diff --git a/lib/Reporting/ReportRun.php b/lib/Reporting/ReportRun.php index c7b1766ba..f543f657c 100644 --- a/lib/Reporting/ReportRun.php +++ b/lib/Reporting/ReportRun.php @@ -29,7 +29,62 @@ class ReportRun extends \Stripe\ApiResource { const OBJECT_NAME = 'reporting.report_run'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; + /** + * Creates a new object and begin running the report. (Certain report types require + * a live-mode API key.). + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Reporting\ReportRun 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; + } + + /** + * Returns a list of Report Runs, with the most recent appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Reporting\ReportRun> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing Report Run. + * + * @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 \Stripe\Reporting\ReportRun + */ + 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/lib/Reporting/ReportType.php b/lib/Reporting/ReportType.php index 1d98e1606..0fdeb5363 100644 --- a/lib/Reporting/ReportType.php +++ b/lib/Reporting/ReportType.php @@ -28,6 +28,40 @@ class ReportType extends \Stripe\ApiResource { const OBJECT_NAME = 'reporting.report_type'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; + /** + * Returns a full list of Report Types. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Reporting\ReportType> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Report Type. (Certain report types require a live-mode API key.). + * + * @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 \Stripe\Reporting\ReportType + */ + 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/lib/Review.php b/lib/Review.php index cb49431ab..cfb2395b0 100644 --- a/lib/Review.php +++ b/lib/Review.php @@ -29,9 +29,6 @@ class Review extends ApiResource { const OBJECT_NAME = 'review'; - use ApiOperations\All; - use ApiOperations\Retrieve; - const CLOSED_REASON_APPROVED = 'approved'; const CLOSED_REASON_DISPUTED = 'disputed'; const CLOSED_REASON_REDACTED = 'redacted'; @@ -41,6 +38,44 @@ class Review extends ApiResource const OPENED_REASON_MANUAL = 'manual'; const OPENED_REASON_RULE = 'rule'; + /** + * Returns a list of Review objects that have open set to + * true. The objects are sorted in descending order by creation date, + * with the most recently created object appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Review> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Review object. + * + * @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 \Stripe\Review + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * Possible string representations of the current, the opening or the closure reason of the review. * Not all of these enumeration apply to all of the ´reason´ fields. Please consult the Review object to diff --git a/lib/SetupAttempt.php b/lib/SetupAttempt.php index e755171dc..e766c9b20 100644 --- a/lib/SetupAttempt.php +++ b/lib/SetupAttempt.php @@ -30,5 +30,20 @@ class SetupAttempt extends ApiResource { const OBJECT_NAME = 'setup_attempt'; - use ApiOperations\All; + /** + * Returns a list of SetupAttempts that associate with a provided SetupIntent. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\SetupAttempt> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } } diff --git a/lib/SetupIntent.php b/lib/SetupIntent.php index d8d62a2ac..c81569d14 100644 --- a/lib/SetupIntent.php +++ b/lib/SetupIntent.php @@ -57,9 +57,6 @@ class SetupIntent extends ApiResource { const OBJECT_NAME = 'setup_intent'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const CANCELLATION_REASON_ABANDONED = 'abandoned'; @@ -73,6 +70,98 @@ class SetupIntent extends ApiResource const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Creates a SetupIntent object. + * + * After you create the SetupIntent, attach a payment method and confirm it to collect any required + * permissions to charge the payment method later. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\SetupIntent 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; + } + + /** + * Returns a list of SetupIntents. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\SetupIntent> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a SetupIntent that has previously been created. + * + * Client-side retrieval using a publishable key is allowed when the + * client_secret is provided in the query string. + * + * When retrieved with a publishable key, only a subset of properties will be + * returned. Please refer to the SetupIntent + * object reference for more details. + * + * @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 \Stripe\SetupIntent + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a SetupIntent object. + * + * @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 \Stripe\SetupIntent 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 $params * @param null|array|string $opts diff --git a/lib/ShippingRate.php b/lib/ShippingRate.php index c1ac21de2..c35964426 100644 --- a/lib/ShippingRate.php +++ b/lib/ShippingRate.php @@ -25,9 +25,6 @@ class ShippingRate extends ApiResource { const OBJECT_NAME = 'shipping_rate'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const TAX_BEHAVIOR_EXCLUSIVE = 'exclusive'; @@ -35,4 +32,85 @@ class ShippingRate extends ApiResource const TAX_BEHAVIOR_UNSPECIFIED = 'unspecified'; const TYPE_FIXED_AMOUNT = 'fixed_amount'; + + /** + * Creates a new shipping rate object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\ShippingRate 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; + } + + /** + * Returns a list of your shipping rates. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\ShippingRate> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns the shipping rate object with the given ID. + * + * @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 \Stripe\ShippingRate + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing shipping rate object. + * + * @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 \Stripe\ShippingRate 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; + } } diff --git a/lib/Sigma/ScheduledQueryRun.php b/lib/Sigma/ScheduledQueryRun.php index 8a139bcc2..5efd1cd81 100644 --- a/lib/Sigma/ScheduledQueryRun.php +++ b/lib/Sigma/ScheduledQueryRun.php @@ -26,8 +26,41 @@ class ScheduledQueryRun extends \Stripe\ApiResource { const OBJECT_NAME = 'scheduled_query_run'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; + /** + * Returns a list of scheduled query runs. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Sigma\ScheduledQueryRun> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an scheduled query run. + * + * @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 \Stripe\Sigma\ScheduledQueryRun + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } public static function classUrl() { diff --git a/lib/Source.php b/lib/Source.php index cf4a7fa05..17951589e 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -60,8 +60,6 @@ class Source extends ApiResource { const OBJECT_NAME = 'source'; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const FLOW_CODE_VERIFICATION = 'code_verification'; @@ -99,6 +97,78 @@ class Source extends ApiResource const USAGE_REUSABLE = 'reusable'; const USAGE_SINGLE_USE = 'single_use'; + /** + * Creates a new source object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Source 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; + } + + /** + * Retrieves an existing source object. Supply the unique source ID from a source + * creation request and Stripe will return the corresponding up-to-date source + * object information. + * + * @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 \Stripe\Source + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified source by setting the values of the parameters passed. Any + * parameters not provided will be left unchanged. + * + * This request accepts the metadata and owner as + * arguments. It is also possible to update type specific information for selected + * payment methods. Please refer to our payment method + * guides for more detail. + * + * @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 \Stripe\Source 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; + } + use ApiOperations\NestedResource; /** diff --git a/lib/Subscription.php b/lib/Subscription.php index a382e221d..5d9148319 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -60,9 +60,6 @@ class Subscription extends ApiResource { const OBJECT_NAME = 'subscription'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -78,6 +75,145 @@ class Subscription extends ApiResource const STATUS_TRIALING = 'trialing'; const STATUS_UNPAID = 'unpaid'; + /** + * Creates a new subscription on an existing customer. Each customer can have up to + * 500 active or scheduled subscriptions. + * + * When you create a subscription with + * collection_method=charge_automatically, the first invoice is + * finalized as part of the request. The payment_behavior parameter + * determines the exact behavior of the initial payment. + * + * To start subscriptions where the first invoice always begins in a + * draft status, use subscription + * schedules instead. Schedules provide the flexibility to model more complex + * billing configurations that change over time. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Subscription 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; + } + + /** + * By default, returns a list of subscriptions that have not been canceled. In + * order to list canceled subscriptions, specify status=canceled. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Subscription> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the subscription with the given ID. + * + * @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 \Stripe\Subscription + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing subscription to match the specified parameters. When + * changing prices or quantities, we optionally prorate the price we charge next + * month to make up for any price changes. To preview how the proration is + * calculated, use the upcoming invoice + * endpoint. + * + * By default, we prorate subscription changes. For example, if a customer signs up + * on May 1 for a 100 price, they’ll be billed + * 100 immediately. If on May 15 they switch to a + * 200 price, then on June 1 they’ll be billed + * 250 (200 for a renewal of her + * subscription, plus a 50 prorating adjustment for half of + * the previous month’s 100 difference). Similarly, a + * downgrade generates a credit that is applied to the next invoice. We also + * prorate when you make quantity changes. + * + * Switching prices does not normally change the billing date or generate an + * immediate charge unless: + * + * + * + * In these cases, we apply a credit for the unused time on the previous price, + * immediately charge the customer using the new price, and reset the billing date. + * + * If you want to charge for an upgrade immediately, pass + * proration_behavior as always_invoice to create + * prorations, automatically invoice the customer for those proration adjustments, + * and attempt to collect payment. If you pass create_prorations, the + * prorations are created but not automatically invoiced. If you want to bill the + * customer for the prorations before the subscription’s renewal date, you need to + * manually invoice the customer. + * + * If you don’t want to prorate, set the proration_behavior option to + * none. With this option, the customer is billed + * 100 on May 1 and 200 on June 1. + * Similarly, if you set proration_behavior to none when + * switching between different billing intervals (for example, from monthly to + * yearly), we don’t generate any credits for the old subscription’s unused time. + * We still reset the billing date and bill immediately for the new subscription. + * + * Updating the quantity on a subscription many times in an hour may result in rate limiting. If you need to bill for a frequently + * changing quantity, consider integrating usage-based billing instead. + * + * @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 \Stripe\Subscription 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; + } + use ApiOperations\Delete { delete as protected _delete; } diff --git a/lib/SubscriptionItem.php b/lib/SubscriptionItem.php index 567ce40db..1b28eea60 100644 --- a/lib/SubscriptionItem.php +++ b/lib/SubscriptionItem.php @@ -25,13 +25,113 @@ class SubscriptionItem extends ApiResource { const OBJECT_NAME = 'subscription_item'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Update; + /** + * Adds a new item to an existing subscription. No existing items will be changed + * or replaced. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\SubscriptionItem 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; + } + + /** + * Deletes an item from the subscription. Removing a subscription item from a + * subscription will not cancel the subscription. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\SubscriptionItem 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; + } + + /** + * Returns a list of your subscription items for a given subscription. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\SubscriptionItem> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the subscription item with the given ID. + * + * @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 \Stripe\SubscriptionItem + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the plan or quantity of an item on a current subscription. + * + * @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 \Stripe\SubscriptionItem 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; + } + const PATH_USAGE_RECORDS = '/usage_records'; /** diff --git a/lib/SubscriptionSchedule.php b/lib/SubscriptionSchedule.php index 15573387a..f17e6f1f8 100644 --- a/lib/SubscriptionSchedule.php +++ b/lib/SubscriptionSchedule.php @@ -34,9 +34,6 @@ class SubscriptionSchedule extends ApiResource { const OBJECT_NAME = 'subscription_schedule'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const BILLING_BEHAVIOR_PRORATE_ON_NEXT_PHASE = 'prorate_on_next_phase'; @@ -53,6 +50,90 @@ class SubscriptionSchedule extends ApiResource const STATUS_NOT_STARTED = 'not_started'; const STATUS_RELEASED = 'released'; + /** + * Creates a new subscription schedule object. Each customer can have up to 500 + * active or scheduled subscriptions. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\SubscriptionSchedule 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; + } + + /** + * Retrieves the list of your subscription schedules. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\SubscriptionSchedule> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing subscription schedule. You only need to + * supply the unique subscription schedule identifier that was returned upon + * subscription schedule creation. + * + * @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 \Stripe\SubscriptionSchedule + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing subscription schedule. + * + * @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 \Stripe\SubscriptionSchedule 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 $params * @param null|array|string $opts diff --git a/lib/Tax/Calculation.php b/lib/Tax/Calculation.php index 35b54bd73..f70b46593 100644 --- a/lib/Tax/Calculation.php +++ b/lib/Tax/Calculation.php @@ -29,7 +29,27 @@ class Calculation extends \Stripe\ApiResource { const OBJECT_NAME = 'tax.calculation'; - use \Stripe\ApiOperations\Create; + /** + * Calculates tax based on input and returns a Tax Calculation object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Calculation 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; + } /** * @param string $id diff --git a/lib/Tax/Form.php b/lib/Tax/Form.php index 8828030d3..24ab2d467 100644 --- a/lib/Tax/Form.php +++ b/lib/Tax/Form.php @@ -25,13 +25,49 @@ class Form extends \Stripe\ApiResource { const OBJECT_NAME = 'tax.form'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const TYPE_US_1099_K = 'us_1099_k'; const TYPE_US_1099_MISC = 'us_1099_misc'; const TYPE_US_1099_NEC = 'us_1099_nec'; + /** + * Returns a list of tax forms which were previously created. The tax forms are + * returned in sorted order, with the oldest tax forms appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Tax\Form> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a tax form that has previously been created. Supply the + * unique tax form ID that was returned from your previous request, and Stripe will + * return the corresponding tax form information. + * + * @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 \Stripe\Tax\Form + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param callable $readBodyChunkCallable * @param null|array $params diff --git a/lib/Tax/Registration.php b/lib/Tax/Registration.php index 6f0285f81..2126e1e99 100644 --- a/lib/Tax/Registration.php +++ b/lib/Tax/Registration.php @@ -25,12 +25,93 @@ class Registration extends \Stripe\ApiResource { const OBJECT_NAME = 'tax.registration'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_ACTIVE = 'active'; const STATUS_EXPIRED = 'expired'; const STATUS_SCHEDULED = 'scheduled'; + + /** + * Creates a new Tax Registration object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Registration 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; + } + + /** + * Returns a list of Tax Registration objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Tax\Registration> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns a Tax Registration object. + * + * @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 \Stripe\Tax\Registration + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing Tax Registration object. + * + * A registration cannot be deleted after it has been created. If you wish to end a + * registration you may do so by setting expires_at. + * + * @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 \Stripe\Tax\Registration 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; + } } diff --git a/lib/Tax/Settings.php b/lib/Tax/Settings.php index fe9638fa4..6da6e3d66 100644 --- a/lib/Tax/Settings.php +++ b/lib/Tax/Settings.php @@ -20,11 +20,27 @@ class Settings extends \Stripe\SingletonApiResource { const OBJECT_NAME = 'tax.settings'; - use \Stripe\ApiOperations\SingletonRetrieve; - const STATUS_ACTIVE = 'active'; const STATUS_PENDING = 'pending'; + /** + * Retrieves Tax Settings for a merchant. + * + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Settings + */ + public static function retrieve($opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static(null, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts @@ -44,4 +60,27 @@ public static function update($params = null, $opts = null) 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, ['save']); + $this->refreshFrom($response, $opts); + } + + return $this; + } } diff --git a/lib/Tax/Transaction.php b/lib/Tax/Transaction.php index 7dcc373b6..7a6343a2b 100644 --- a/lib/Tax/Transaction.php +++ b/lib/Tax/Transaction.php @@ -29,11 +29,28 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'tax.transaction'; - use \Stripe\ApiOperations\Retrieve; - const TYPE_REVERSAL = 'reversal'; const TYPE_TRANSACTION = 'transaction'; + /** + * Retrieves a Tax Transaction object. + * + * @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 \Stripe\Tax\Transaction + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/TaxCode.php b/lib/TaxCode.php index 9c41ce5d2..f57caaada 100644 --- a/lib/TaxCode.php +++ b/lib/TaxCode.php @@ -16,6 +16,41 @@ class TaxCode extends ApiResource { const OBJECT_NAME = 'tax_code'; - use ApiOperations\All; - use ApiOperations\Retrieve; + /** + * A list of all tax codes + * available to add to Products in order to allow specific tax calculations. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\TaxCode> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing tax code. Supply the unique tax code ID and + * Stripe will return the corresponding tax code information. + * + * @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 \Stripe\TaxCode + */ + 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/lib/TaxId.php b/lib/TaxId.php index 3f039ae01..28fa8569b 100644 --- a/lib/TaxId.php +++ b/lib/TaxId.php @@ -25,11 +25,6 @@ class TaxId extends ApiResource { const OBJECT_NAME = 'tax_id'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; - const TYPE_AD_NRT = 'ad_nrt'; const TYPE_AE_TRN = 'ae_trn'; const TYPE_AR_CUIT = 'ar_cuit'; @@ -103,6 +98,85 @@ class TaxId extends ApiResource const TYPE_VN_TIN = 'vn_tin'; const TYPE_ZA_VAT = 'za_vat'; + /** + * Creates a new account or customer tax_id object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\TaxId 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; + } + + /** + * Deletes an existing account or customer tax_id object. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\TaxId 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; + } + + /** + * Returns a list of tax IDs. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\TaxId> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an account or customer tax_id object. + * + * @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 \Stripe\TaxId + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + const VERIFICATION_STATUS_PENDING = 'pending'; const VERIFICATION_STATUS_UNAVAILABLE = 'unavailable'; const VERIFICATION_STATUS_UNVERIFIED = 'unverified'; diff --git a/lib/TaxRate.php b/lib/TaxRate.php index f0a888943..976a6e0c6 100644 --- a/lib/TaxRate.php +++ b/lib/TaxRate.php @@ -30,9 +30,6 @@ class TaxRate extends ApiResource { const OBJECT_NAME = 'tax_rate'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const JURISDICTION_LEVEL_CITY = 'city'; @@ -54,4 +51,86 @@ class TaxRate extends ApiResource const TAX_TYPE_RST = 'rst'; const TAX_TYPE_SALES_TAX = 'sales_tax'; const TAX_TYPE_VAT = 'vat'; + + /** + * Creates a new tax rate. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\TaxRate 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; + } + + /** + * Returns a list of your tax rates. Tax rates are returned sorted by creation + * date, with the most recently created tax rates appearing first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\TaxRate> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a tax rate with the given ID. + * + * @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 \Stripe\TaxRate + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates an existing tax rate. + * + * @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 \Stripe\TaxRate 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; + } } diff --git a/lib/Terminal/Configuration.php b/lib/Terminal/Configuration.php index d30ac6712..7a0e411b1 100644 --- a/lib/Terminal/Configuration.php +++ b/lib/Terminal/Configuration.php @@ -22,9 +22,107 @@ class Configuration extends \Stripe\ApiResource { const OBJECT_NAME = 'terminal.configuration'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + + /** + * Creates a new Configuration object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Configuration 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; + } + + /** + * Deletes a Configuration object. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Configuration 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; + } + + /** + * Returns a list of Configuration objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Terminal\Configuration> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Configuration object. + * + * @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 \Stripe\Terminal\Configuration + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a new Configuration object. + * + * @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 \Stripe\Terminal\Configuration 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; + } } diff --git a/lib/Terminal/ConnectionToken.php b/lib/Terminal/ConnectionToken.php index 72751f071..dd8ce032a 100644 --- a/lib/Terminal/ConnectionToken.php +++ b/lib/Terminal/ConnectionToken.php @@ -17,5 +17,27 @@ class ConnectionToken extends \Stripe\ApiResource { const OBJECT_NAME = 'terminal.connection_token'; - use \Stripe\ApiOperations\Create; + /** + * To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived + * connection token from Stripe, proxied through your server. On your backend, add + * an endpoint that creates and returns a connection token. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\ConnectionToken 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/lib/Terminal/Location.php b/lib/Terminal/Location.php index 88634b431..11a6f0f0e 100644 --- a/lib/Terminal/Location.php +++ b/lib/Terminal/Location.php @@ -21,9 +21,110 @@ class Location extends \Stripe\ApiResource { const OBJECT_NAME = 'terminal.location'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; + + /** + * Creates a new Location object. For further details, including which + * address fields are required in each country, see the Manage locations guide. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Location 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; + } + + /** + * Deletes a Location object. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Location 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; + } + + /** + * Returns a list of Location objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Terminal\Location> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Location object. + * + * @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 \Stripe\Terminal\Location + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a Location object by setting the values of the parameters + * passed. Any parameters not provided will be left unchanged. + * + * @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 \Stripe\Terminal\Location 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; + } } diff --git a/lib/Terminal/Reader.php b/lib/Terminal/Reader.php index a448668e6..497fc81bc 100644 --- a/lib/Terminal/Reader.php +++ b/lib/Terminal/Reader.php @@ -26,10 +26,6 @@ class Reader extends \Stripe\ApiResource { const OBJECT_NAME = 'terminal.reader'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const DEVICE_TYPE_BBPOS_CHIPPER2X = 'bbpos_chipper2x'; @@ -43,6 +39,109 @@ class Reader extends \Stripe\ApiResource const STATUS_OFFLINE = 'offline'; const STATUS_ONLINE = 'online'; + /** + * Creates a new Reader object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Reader 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; + } + + /** + * Deletes a Reader object. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Reader 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; + } + + /** + * Returns a list of Reader objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Terminal\Reader> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Reader object. + * + * @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 \Stripe\Terminal\Reader + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates a Reader object by setting the values of the parameters + * passed. Any parameters not provided will be left unchanged. + * + * @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 \Stripe\Terminal\Reader 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 $params * @param null|array|string $opts diff --git a/lib/TestHelpers/TestClock.php b/lib/TestHelpers/TestClock.php index badc48f85..8a8cf2644 100644 --- a/lib/TestHelpers/TestClock.php +++ b/lib/TestHelpers/TestClock.php @@ -22,15 +22,89 @@ class TestClock extends \Stripe\ApiResource { const OBJECT_NAME = 'test_helpers.test_clock'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Delete; - use \Stripe\ApiOperations\Retrieve; - const STATUS_ADVANCING = 'advancing'; const STATUS_INTERNAL_FAILURE = 'internal_failure'; const STATUS_READY = 'ready'; + /** + * Creates a new test clock that can be attached to new customers and quotes. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\TestHelpers\TestClock 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; + } + + /** + * Deletes a test clock. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\TestHelpers\TestClock 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; + } + + /** + * Returns a list of your test clocks. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\TestHelpers\TestClock> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a test clock. + * + * @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 \Stripe\TestHelpers\TestClock + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Token.php b/lib/Token.php index 4b12fda35..a4e6516da 100644 --- a/lib/Token.php +++ b/lib/Token.php @@ -40,11 +40,54 @@ class Token extends ApiResource { const OBJECT_NAME = 'token'; - use ApiOperations\Create; - use ApiOperations\Retrieve; - const TYPE_ACCOUNT = 'account'; const TYPE_BANK_ACCOUNT = 'bank_account'; const TYPE_CARD = 'card'; const TYPE_PII = 'pii'; + + /** + * Creates a single-use token that represents a bank account’s details. You can use + * this token with any API method in place of a bank account dictionary. You can + * only use this token once. To do so, attach it to a connected + * account where controller.requirement_collection + * is application, which includes Custom accounts. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Token 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; + } + + /** + * Retrieves the token with the given ID. + * + * @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 \Stripe\Token + */ + 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/lib/Topup.php b/lib/Topup.php index 32ad57fad..2954a7d1e 100644 --- a/lib/Topup.php +++ b/lib/Topup.php @@ -32,9 +32,6 @@ class Topup extends ApiResource { const OBJECT_NAME = 'topup'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const STATUS_CANCELED = 'canceled'; @@ -43,6 +40,90 @@ class Topup extends ApiResource const STATUS_REVERSED = 'reversed'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Top up the balance of an account. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Topup 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; + } + + /** + * Returns a list of top-ups. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Topup> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a top-up that has previously been created. Supply the + * unique top-up ID that was returned from your previous request, and Stripe will + * return the corresponding top-up information. + * + * @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 \Stripe\Topup + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the metadata of a top-up. Other top-up details are not editable by + * design. + * + * @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 \Stripe\Topup 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 $params * @param null|array|string $opts diff --git a/lib/Transfer.php b/lib/Transfer.php index cf0206238..d0b766db8 100644 --- a/lib/Transfer.php +++ b/lib/Transfer.php @@ -38,16 +38,103 @@ class Transfer extends ApiResource { const OBJECT_NAME = 'transfer'; - use ApiOperations\All; - use ApiOperations\Create; use ApiOperations\NestedResource; - use ApiOperations\Retrieve; use ApiOperations\Update; const SOURCE_TYPE_BANK_ACCOUNT = 'bank_account'; const SOURCE_TYPE_CARD = 'card'; const SOURCE_TYPE_FPX = 'fpx'; + /** + * To send funds from your Stripe account to a connected account, you create a new + * transfer object. Your Stripe balance must be able to + * cover the transfer amount, or you’ll receive an “Insufficient Funds” error. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Transfer 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; + } + + /** + * Returns a list of existing transfers sent to connected accounts. The transfers + * are returned in sorted order, with the most recently created transfers appearing + * first. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Transfer> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing transfer. Supply the unique transfer ID + * from either a transfer creation request or the transfer list, and Stripe will + * return the corresponding transfer information. + * + * @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 \Stripe\Transfer + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the specified transfer by setting the values of the parameters passed. + * Any parameters not provided will be left unchanged. + * + * This request accepts only metadata as an argument. + * + * @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 \Stripe\Transfer 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; + } + const PATH_REVERSALS = '/reversals'; /** diff --git a/lib/Treasury/CreditReversal.php b/lib/Treasury/CreditReversal.php index 186651758..c0df14485 100644 --- a/lib/Treasury/CreditReversal.php +++ b/lib/Treasury/CreditReversal.php @@ -26,14 +26,70 @@ class CreditReversal extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.credit_reversal'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const NETWORK_ACH = 'ach'; const NETWORK_STRIPE = 'stripe'; const STATUS_CANCELED = 'canceled'; const STATUS_POSTED = 'posted'; const STATUS_PROCESSING = 'processing'; + + /** + * Reverses a ReceivedCredit and creates a CreditReversal object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\CreditReversal 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; + } + + /** + * Returns a list of CreditReversals. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\CreditReversal> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing CreditReversal by passing the unique + * CreditReversal ID from either the CreditReversal creation request or + * CreditReversal list. + * + * @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 \Stripe\Treasury\CreditReversal + */ + 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/lib/Treasury/DebitReversal.php b/lib/Treasury/DebitReversal.php index b9100f2cd..4b83967c9 100644 --- a/lib/Treasury/DebitReversal.php +++ b/lib/Treasury/DebitReversal.php @@ -27,14 +27,68 @@ class DebitReversal extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.debit_reversal'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const NETWORK_ACH = 'ach'; const NETWORK_CARD = 'card'; const STATUS_FAILED = 'failed'; const STATUS_PROCESSING = 'processing'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * Reverses a ReceivedDebit and creates a DebitReversal object. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\DebitReversal 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; + } + + /** + * Returns a list of DebitReversals. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\DebitReversal> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a DebitReversal object. + * + * @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 \Stripe\Treasury\DebitReversal + */ + 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/lib/Treasury/FinancialAccount.php b/lib/Treasury/FinancialAccount.php index e7ae8982c..f72f533ea 100644 --- a/lib/Treasury/FinancialAccount.php +++ b/lib/Treasury/FinancialAccount.php @@ -29,14 +29,93 @@ class FinancialAccount extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.financial_account'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; use \Stripe\ApiOperations\Update; const STATUS_CLOSED = 'closed'; const STATUS_OPEN = 'open'; + /** + * Creates a new FinancialAccount. For now, each connected account can only have + * one FinancialAccount. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\FinancialAccount 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; + } + + /** + * Returns a list of FinancialAccounts. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\FinancialAccount> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a FinancialAccount. + * + * @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 \Stripe\Treasury\FinancialAccount + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the details of a FinancialAccount. + * + * @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 \Stripe\Treasury\FinancialAccount 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 $params * @param null|array|string $opts diff --git a/lib/Treasury/InboundTransfer.php b/lib/Treasury/InboundTransfer.php index bf1ceaffb..beb1dc19d 100644 --- a/lib/Treasury/InboundTransfer.php +++ b/lib/Treasury/InboundTransfer.php @@ -32,15 +32,69 @@ class InboundTransfer extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.inbound_transfer'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const STATUS_CANCELED = 'canceled'; const STATUS_FAILED = 'failed'; const STATUS_PROCESSING = 'processing'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Creates an InboundTransfer. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\InboundTransfer 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; + } + + /** + * Returns a list of InboundTransfers sent from the specified FinancialAccount. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\InboundTransfer> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing InboundTransfer. + * + * @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 \Stripe\Treasury\InboundTransfer + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Treasury/OutboundPayment.php b/lib/Treasury/OutboundPayment.php index 48f82f18c..808c5d473 100644 --- a/lib/Treasury/OutboundPayment.php +++ b/lib/Treasury/OutboundPayment.php @@ -36,16 +36,72 @@ class OutboundPayment extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.outbound_payment'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const STATUS_CANCELED = 'canceled'; const STATUS_FAILED = 'failed'; const STATUS_POSTED = 'posted'; const STATUS_PROCESSING = 'processing'; const STATUS_RETURNED = 'returned'; + /** + * Creates an OutboundPayment. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundPayment 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; + } + + /** + * Returns a list of OutboundPayments sent from the specified FinancialAccount. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\OutboundPayment> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing OutboundPayment by passing the unique + * OutboundPayment ID from either the OutboundPayment creation request or + * OutboundPayment list. + * + * @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 \Stripe\Treasury\OutboundPayment + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Treasury/OutboundTransfer.php b/lib/Treasury/OutboundTransfer.php index 136dcfb47..80a6d5677 100644 --- a/lib/Treasury/OutboundTransfer.php +++ b/lib/Treasury/OutboundTransfer.php @@ -35,16 +35,72 @@ class OutboundTransfer extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.outbound_transfer'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; - const STATUS_CANCELED = 'canceled'; const STATUS_FAILED = 'failed'; const STATUS_POSTED = 'posted'; const STATUS_PROCESSING = 'processing'; const STATUS_RETURNED = 'returned'; + /** + * Creates an OutboundTransfer. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundTransfer 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; + } + + /** + * Returns a list of OutboundTransfers sent from the specified FinancialAccount. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\OutboundTransfer> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing OutboundTransfer by passing the unique + * OutboundTransfer ID from either the OutboundTransfer creation request or + * OutboundTransfer list. + * + * @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 \Stripe\Treasury\OutboundTransfer + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Treasury/ReceivedCredit.php b/lib/Treasury/ReceivedCredit.php index b0731b325..4f2e2ebb7 100644 --- a/lib/Treasury/ReceivedCredit.php +++ b/lib/Treasury/ReceivedCredit.php @@ -29,9 +29,6 @@ class ReceivedCredit extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.received_credit'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FAILURE_CODE_ACCOUNT_CLOSED = 'account_closed'; const FAILURE_CODE_ACCOUNT_FROZEN = 'account_frozen'; const FAILURE_CODE_OTHER = 'other'; @@ -43,4 +40,41 @@ class ReceivedCredit extends \Stripe\ApiResource const STATUS_FAILED = 'failed'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * Returns a list of ReceivedCredits. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\ReceivedCredit> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing ReceivedCredit by passing the unique + * ReceivedCredit ID from the ReceivedCredit list. + * + * @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 \Stripe\Treasury\ReceivedCredit + */ + 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/lib/Treasury/ReceivedDebit.php b/lib/Treasury/ReceivedDebit.php index b825019e2..8e7a29f7b 100644 --- a/lib/Treasury/ReceivedDebit.php +++ b/lib/Treasury/ReceivedDebit.php @@ -29,9 +29,6 @@ class ReceivedDebit extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.received_debit'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FAILURE_CODE_ACCOUNT_CLOSED = 'account_closed'; const FAILURE_CODE_ACCOUNT_FROZEN = 'account_frozen'; const FAILURE_CODE_INSUFFICIENT_FUNDS = 'insufficient_funds'; @@ -43,4 +40,41 @@ class ReceivedDebit extends \Stripe\ApiResource const STATUS_FAILED = 'failed'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * Returns a list of ReceivedDebits. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\ReceivedDebit> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing ReceivedDebit by passing the unique + * ReceivedDebit ID from the ReceivedDebit list. + * + * @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 \Stripe\Treasury\ReceivedDebit + */ + 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/lib/Treasury/Transaction.php b/lib/Treasury/Transaction.php index 1705e03da..b694d68a4 100644 --- a/lib/Treasury/Transaction.php +++ b/lib/Treasury/Transaction.php @@ -27,9 +27,6 @@ class Transaction extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.transaction'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FLOW_TYPE_CREDIT_REVERSAL = 'credit_reversal'; const FLOW_TYPE_DEBIT_REVERSAL = 'debit_reversal'; const FLOW_TYPE_INBOUND_TRANSFER = 'inbound_transfer'; @@ -43,4 +40,40 @@ class Transaction extends \Stripe\ApiResource const STATUS_OPEN = 'open'; const STATUS_POSTED = 'posted'; const STATUS_VOID = 'void'; + + /** + * Retrieves a list of Transaction objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\Transaction> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing Transaction. + * + * @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 \Stripe\Treasury\Transaction + */ + 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/lib/Treasury/TransactionEntry.php b/lib/Treasury/TransactionEntry.php index 624368299..fcef7effa 100644 --- a/lib/Treasury/TransactionEntry.php +++ b/lib/Treasury/TransactionEntry.php @@ -25,9 +25,6 @@ class TransactionEntry extends \Stripe\ApiResource { const OBJECT_NAME = 'treasury.transaction_entry'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const FLOW_TYPE_CREDIT_REVERSAL = 'credit_reversal'; const FLOW_TYPE_DEBIT_REVERSAL = 'debit_reversal'; const FLOW_TYPE_INBOUND_TRANSFER = 'inbound_transfer'; @@ -58,4 +55,40 @@ class TransactionEntry extends \Stripe\ApiResource const TYPE_OUTBOUND_TRANSFER_RETURN = 'outbound_transfer_return'; const TYPE_RECEIVED_CREDIT = 'received_credit'; const TYPE_RECEIVED_DEBIT = 'received_debit'; + + /** + * Retrieves a list of TransactionEntry objects. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Treasury\TransactionEntry> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a TransactionEntry object. + * + * @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 \Stripe\Treasury\TransactionEntry + */ + 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/lib/WebhookEndpoint.php b/lib/WebhookEndpoint.php index 1200bb120..0d500f292 100644 --- a/lib/WebhookEndpoint.php +++ b/lib/WebhookEndpoint.php @@ -30,9 +30,118 @@ class WebhookEndpoint extends ApiResource { const OBJECT_NAME = 'webhook_endpoint'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; - use ApiOperations\Retrieve; use ApiOperations\Update; + + /** + * A webhook endpoint must have a url and a list of + * enabled_events. You may optionally specify the Boolean + * connect parameter. If set to true, then a Connect webhook endpoint + * that notifies the specified url about events from all connected + * accounts is created; otherwise an account webhook endpoint that notifies the + * specified url only about events from your account is created. You + * can also create webhook endpoints in the webhooks settings + * section of the Dashboard. + * + * @param null|array $params + * @param null|array|string $options + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\WebhookEndpoint 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; + } + + /** + * You can also delete webhook endpoints via the webhook endpoint + * management page of the Stripe dashboard. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\WebhookEndpoint 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; + } + + /** + * Returns a list of your webhook endpoints. + * + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\WebhookEndpoint> of ApiResources + */ + public static function all($params = null, $opts = null) + { + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the webhook endpoint with the given ID. + * + * @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 \Stripe\WebhookEndpoint + */ + public static function retrieve($id, $opts = null) + { + $opts = \Stripe\Util\RequestOptions::parse($opts); + $instance = new static($id, $opts); + $instance->refresh(); + + return $instance; + } + + /** + * Updates the webhook endpoint. You may edit the url, the list of + * enabled_events, and the status of your endpoint. + * + * @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 \Stripe\WebhookEndpoint 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; + } }