From 87c4f0ea50a2fca6b42a6be03cf6942586b42efe Mon Sep 17 00:00:00 2001 From: Prathmesh Ranaut Date: Tue, 28 May 2024 15:13:47 -0400 Subject: [PATCH 1/3] Demagiced crudl operation --- lib/Account.php | 105 ++++++++++++++++++- lib/AccountLink.php | 19 +++- lib/AccountSession.php | 18 +++- lib/ApplePayDomain.php | 62 +++++++++++- lib/ApplicationFee.php | 30 +++++- lib/Apps/Secret.php | 29 +++++- lib/Balance.php | 17 +++- lib/BalanceTransaction.php | 37 ++++++- lib/BankAccount.php | 40 +++++++- lib/Billing/Meter.php | 64 +++++++++++- lib/Billing/MeterEvent.php | 17 +++- lib/Billing/MeterEventAdjustment.php | 19 +++- lib/BillingPortal/Configuration.php | 67 ++++++++++++- lib/BillingPortal/Session.php | 17 +++- lib/Capability.php | 23 +++++ lib/Card.php | 40 +++++++- lib/Charge.php | 72 ++++++++++++- lib/Checkout/Session.php | 47 ++++++++- lib/Climate/Order.php | 67 ++++++++++++- lib/Climate/Product.php | 27 ++++- lib/Climate/Supplier.php | 29 +++++- lib/ConfirmationToken.php | 17 +++- lib/CountrySpec.php | 27 ++++- lib/Coupon.php | 99 +++++++++++++++++- lib/CreditNote.php | 83 ++++++++++++++- lib/Customer.php | 95 +++++++++++++++++- lib/CustomerSession.php | 19 +++- lib/Dispute.php | 54 +++++++++- lib/Entitlements/ActiveEntitlement.php | 27 ++++- lib/Entitlements/Feature.php | 64 +++++++++++- lib/EphemeralKey.php | 18 +++- lib/Event.php | 34 ++++++- lib/ExchangeRate.php | 29 +++++- lib/File.php | 33 +++++- lib/FileLink.php | 64 +++++++++++- lib/FinancialConnections/Account.php | 29 +++++- lib/FinancialConnections/Session.php | 35 ++++++- lib/FinancialConnections/Transaction.php | 29 +++++- lib/Forwarding/Request.php | 45 ++++++++- lib/Identity/VerificationReport.php | 29 +++++- lib/Identity/VerificationSession.php | 81 ++++++++++++++- lib/Invoice.php | 96 +++++++++++++++++- lib/InvoiceItem.php | 88 +++++++++++++++- lib/InvoiceLineItem.php | 23 +++++ lib/Issuing/Authorization.php | 50 +++++++++- lib/Issuing/Card.php | 67 ++++++++++++- lib/Issuing/Cardholder.php | 68 ++++++++++++- lib/Issuing/Dispute.php | 73 +++++++++++++- lib/Issuing/PersonalizationDesign.php | 66 +++++++++++- lib/Issuing/PhysicalBundle.php | 30 +++++- lib/Issuing/Token.php | 47 ++++++++- lib/Issuing/Transaction.php | 50 +++++++++- lib/Mandate.php | 17 +++- lib/PaymentIntent.php | 87 +++++++++++++++- lib/PaymentLink.php | 64 +++++++++++- lib/PaymentMethod.php | 79 ++++++++++++++- lib/PaymentMethodConfiguration.php | 64 +++++++++++- lib/PaymentMethodDomain.php | 64 +++++++++++- lib/Payout.php | 80 ++++++++++++++- lib/Person.php | 23 +++++ lib/Plan.php | 86 +++++++++++++++- lib/Price.php | 68 ++++++++++++- lib/Product.php | 87 +++++++++++++++- lib/PromotionCode.php | 69 ++++++++++++- lib/Quote.php | 67 ++++++++++++- lib/Radar/EarlyFraudWarning.php | 33 +++++- lib/Radar/ValueList.php | 88 +++++++++++++++- lib/Radar/ValueListItem.php | 66 +++++++++++- lib/Refund.php | 81 ++++++++++++++- lib/Reporting/ReportRun.php | 46 ++++++++- lib/Reporting/ReportType.php | 28 +++++- lib/Review.php | 31 +++++- lib/SetupAttempt.php | 11 +- lib/SetupIntent.php | 75 +++++++++++++- lib/ShippingRate.php | 64 +++++++++++- lib/Sigma/ScheduledQueryRun.php | 27 ++++- lib/Source.php | 60 ++++++++++- lib/Subscription.php | 122 ++++++++++++++++++++++- lib/SubscriptionItem.php | 83 ++++++++++++++- lib/SubscriptionSchedule.php | 67 ++++++++++++- lib/Tax/Calculation.php | 17 +++- lib/Tax/Registration.php | 67 ++++++++++++- lib/Tax/Settings.php | 39 +++++++- lib/Tax/Transaction.php | 17 +++- lib/TaxCode.php | 29 +++++- lib/TaxId.php | 64 +++++++++++- lib/TaxRate.php | 65 +++++++++++- lib/Terminal/Configuration.php | 81 ++++++++++++++- lib/Terminal/ConnectionToken.php | 19 +++- lib/Terminal/Location.php | 84 +++++++++++++++- lib/Terminal/Reader.php | 82 ++++++++++++++- lib/TestHelpers/TestClock.php | 64 +++++++++++- lib/Token.php | 40 +++++++- lib/Topup.php | 67 ++++++++++++- lib/Transfer.php | 73 +++++++++++++- lib/Treasury/CreditReversal.php | 49 ++++++++- lib/Treasury/DebitReversal.php | 47 ++++++++- lib/Treasury/FinancialAccount.php | 65 +++++++++++- lib/Treasury/InboundTransfer.php | 47 ++++++++- lib/Treasury/OutboundPayment.php | 49 ++++++++- lib/Treasury/OutboundTransfer.php | 49 ++++++++- lib/Treasury/ReceivedCredit.php | 30 +++++- lib/Treasury/ReceivedDebit.php | 30 +++++- lib/Treasury/Transaction.php | 29 +++++- lib/Treasury/TransactionEntry.php | 29 +++++- lib/WebhookEndpoint.php | 92 ++++++++++++++++- 106 files changed, 5184 insertions(+), 292 deletions(-) diff --git a/lib/Account.php b/lib/Account.php index 86a556d35..4904a86b8 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -45,9 +45,6 @@ class Account extends ApiResource { const OBJECT_NAME = 'account'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Delete; use ApiOperations\NestedResource; use ApiOperations\Update; @@ -61,6 +58,108 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/accounts', \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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..19604fe84 100644 --- a/lib/AccountLink.php +++ b/lib/AccountLink.php @@ -19,5 +19,22 @@ 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|mixed $params + * @param null|mixed $options + */ + 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/AccountSession.php b/lib/AccountSession.php index a5c1fb2ef..5b575119e 100644 --- a/lib/AccountSession.php +++ b/lib/AccountSession.php @@ -24,5 +24,21 @@ 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|mixed $params + * @param null|mixed $options + */ + 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..e22589e3a 100644 --- a/lib/ApplePayDomain.php +++ b/lib/ApplePayDomain.php @@ -15,10 +15,64 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/apple_pay/domains', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve an apple pay domain. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..f031a7bbe 100644 --- a/lib/ApplicationFee.php +++ b/lib/ApplicationFee.php @@ -25,9 +25,35 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/application_fees', \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 mixed $id + * @param null|mixed $opts + */ + 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..1faa9c9b7 100644 --- a/lib/Apps/Secret.php +++ b/lib/Apps/Secret.php @@ -29,8 +29,33 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/apps/secrets', \Stripe\Collection::class, $params, $opts); + } /** * @param null|array $params diff --git a/lib/Balance.php b/lib/Balance.php index d813cd808..947c7829d 100644 --- a/lib/Balance.php +++ b/lib/Balance.php @@ -29,5 +29,20 @@ 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|mixed $opts + */ + 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..51551424f 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,38 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/balance_transactions', \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 mixed $id + * @param null|mixed $opts + */ + 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..02b7b9a48 100644 --- a/lib/BankAccount.php +++ b/lib/BankAccount.php @@ -38,8 +38,21 @@ 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|mixed $params + * @param null|mixed $opts + */ + 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 +125,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..e2703007b 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,67 @@ class Meter extends \Stripe\ApiResource const STATUS_ACTIVE = 'active'; const STATUS_INACTIVE = 'inactive'; + /** + * Creates a billing meter. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/billing/meters', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a billing meter given an ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..8606c6bea 100644 --- a/lib/Billing/MeterEvent.php +++ b/lib/Billing/MeterEvent.php @@ -20,5 +20,20 @@ class MeterEvent extends \Stripe\ApiResource { const OBJECT_NAME = 'billing.meter_event'; - use \Stripe\ApiOperations\Create; + /** + * Creates a billing meter event. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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..2920825e9 100644 --- a/lib/Billing/MeterEventAdjustment.php +++ b/lib/Billing/MeterEventAdjustment.php @@ -18,8 +18,23 @@ 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|mixed $params + * @param null|mixed $options + */ + 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..78e6739a3 100644 --- a/lib/BillingPortal/Configuration.php +++ b/lib/BillingPortal/Configuration.php @@ -25,8 +25,69 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/billing_portal/configurations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a configuration that describes the functionality of the customer + * portal. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..bb8c77fdb 100644 --- a/lib/BillingPortal/Session.php +++ b/lib/BillingPortal/Session.php @@ -36,5 +36,20 @@ class Session extends \Stripe\ApiResource { const OBJECT_NAME = 'billing_portal.session'; - use \Stripe\ApiOperations\Create; + /** + * Creates a session of the customer portal. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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..23bdba470 100644 --- a/lib/Capability.php +++ b/lib/Capability.php @@ -83,4 +83,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/Card.php b/lib/Card.php index 47721b37a..9670da424 100644 --- a/lib/Card.php +++ b/lib/Card.php @@ -45,8 +45,21 @@ 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|mixed $params + * @param null|mixed $opts + */ + 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 +148,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..792f7af4a 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,75 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/charges', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..103086401 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,49 @@ class Session extends \Stripe\ApiResource const UI_MODE_EMBEDDED = 'embedded'; const UI_MODE_HOSTED = 'hosted'; + /** + * Creates a Session object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/checkout/sessions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Session object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..b5d3d1dac 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,70 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/climate/orders', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Climate order object with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..987ae51df 100644 --- a/lib/Climate/Product.php +++ b/lib/Climate/Product.php @@ -22,6 +22,29 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/climate/products', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Climate product with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..a38cfeb88 100644 --- a/lib/Climate/Supplier.php +++ b/lib/Climate/Supplier.php @@ -19,10 +19,33 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/climate/suppliers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Climate supplier object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 01015d907..e4cb7829f 100644 --- a/lib/ConfirmationToken.php +++ b/lib/ConfirmationToken.php @@ -31,8 +31,21 @@ 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 mixed $id + * @param null|mixed $opts + */ + 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..be1ae660c 100644 --- a/lib/CountrySpec.php +++ b/lib/CountrySpec.php @@ -25,6 +25,29 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/country_specs', \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns a Country Spec for a given Country code. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 4e2348d07..bdc157bbe 100644 --- a/lib/Coupon.php +++ b/lib/Coupon.php @@ -31,13 +31,104 @@ 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'; + + /** + * 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/coupons', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the coupon with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 9edb4048b..bc846d6a2 100644 --- a/lib/CreditNote.php +++ b/lib/CreditNote.php @@ -44,10 +44,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'; @@ -61,6 +58,86 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/credit_notes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the credit note object with the given identifier. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..9291b9d1b 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,97 @@ class Customer extends ApiResource const TAX_EXEMPT_NONE = 'none'; const TAX_EXEMPT_REVERSE = 'reverse'; + /** + * Creates a new customer object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/customers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Customer object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..f36dcfa1c 100644 --- a/lib/CustomerSession.php +++ b/lib/CustomerSession.php @@ -20,5 +20,22 @@ 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|mixed $params + * @param null|mixed $options + */ + 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 55cc06a5a..4024816e1 100644 --- a/lib/Dispute.php +++ b/lib/Dispute.php @@ -33,8 +33,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'; @@ -60,6 +58,58 @@ class Dispute extends ApiResource const STATUS_WARNING_UNDER_REVIEW = 'warning_under_review'; const STATUS_WON = 'won'; + /** + * Returns a list of your disputes. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/disputes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the dispute with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..013967237 100644 --- a/lib/Entitlements/ActiveEntitlement.php +++ b/lib/Entitlements/ActiveEntitlement.php @@ -17,6 +17,29 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/entitlements/active_entitlements', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve an active entitlement. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..64ffb73da 100644 --- a/lib/Entitlements/Feature.php +++ b/lib/Entitlements/Feature.php @@ -20,8 +20,66 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/entitlements/features', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a feature. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..4f2d43f22 100644 --- a/lib/EphemeralKey.php +++ b/lib/EphemeralKey.php @@ -16,12 +16,26 @@ class EphemeralKey extends ApiResource { const OBJECT_NAME = 'ephemeral_key'; + /** + * Invalidates a short-lived API key for a given resource. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 7cb331aab..14adf27f7 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -54,9 +54,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'; @@ -516,4 +513,35 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/events', \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 mixed $id + * @param null|mixed $opts + */ + 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..babed598d 100644 --- a/lib/ExchangeRate.php +++ b/lib/ExchangeRate.php @@ -40,6 +40,31 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/exchange_rates', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the exchange rates from the given currency to every supported + * currency. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..f39f75d71 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,36 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/files', \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 mixed $id + * @param null|mixed $opts + */ + 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..431aebd2b 100644 --- a/lib/FileLink.php +++ b/lib/FileLink.php @@ -23,8 +23,66 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/file_links', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the file link with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 e83289bda..fbe45c4ea 100644 --- a/lib/FinancialConnections/Account.php +++ b/lib/FinancialConnections/Account.php @@ -31,9 +31,6 @@ class Account extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.account'; - use \Stripe\ApiOperations\All; - use \Stripe\ApiOperations\Retrieve; - const CATEGORY_CASH = 'cash'; const CATEGORY_CREDIT = 'credit'; const CATEGORY_INVESTMENT = 'investment'; @@ -50,6 +47,32 @@ class Account extends \Stripe\ApiResource const SUBCATEGORY_OTHER = 'other'; const SUBCATEGORY_SAVINGS = 'savings'; + /** + * Returns a list of Financial Connections Account objects. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/financial_connections/accounts', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an Financial Connections Account. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 02cbfd2dc..a8606b7ae 100644 --- a/lib/FinancialConnections/Session.php +++ b/lib/FinancialConnections/Session.php @@ -22,6 +22,37 @@ class Session extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.session'; - use \Stripe\ApiOperations\Create; - use \Stripe\ApiOperations\Retrieve; + /** + * 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|mixed $params + * @param null|mixed $options + */ + 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 mixed $id + * @param null|mixed $opts + */ + 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..8fe585534 100644 --- a/lib/FinancialConnections/Transaction.php +++ b/lib/FinancialConnections/Transaction.php @@ -24,10 +24,33 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/financial_connections/transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Financial Connections Transaction. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..a6178ff0e 100644 --- a/lib/Forwarding/Request.php +++ b/lib/Forwarding/Request.php @@ -37,7 +37,46 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/forwarding/requests', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ForwardingRequest object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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/VerificationReport.php b/lib/Identity/VerificationReport.php index 27ae08dbe..fbcbbc9d6 100644 --- a/lib/Identity/VerificationReport.php +++ b/lib/Identity/VerificationReport.php @@ -36,10 +36,33 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/identity/verification_reports', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an existing VerificationReport. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..71ff5f018 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,84 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/identity/verification_sessions', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 4024fe0b1..62f18ebfd 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -125,11 +125,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; @@ -156,6 +152,98 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/invoices', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the invoice with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 006118032..6efa24a34 100644 --- a/lib/InvoiceItem.php +++ b/lib/InvoiceItem.php @@ -45,9 +45,89 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/invoiceitems', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the invoice item with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 b286d498f..84805ca90 100644 --- a/lib/InvoiceLineItem.php +++ b/lib/InvoiceLineItem.php @@ -36,4 +36,27 @@ 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..db8cf71d2 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,54 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/authorizations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Authorization object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..55fbb0c87 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,68 @@ class Card extends \Stripe\ApiResource const TYPE_PHYSICAL = 'physical'; const TYPE_VIRTUAL = 'virtual'; + + /** + * Creates an Issuing Card object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/cards', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Card object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..0cea7ad0d 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,69 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/cardholders', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Cardholder object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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/Dispute.php b/lib/Issuing/Dispute.php index bc37efe27..afc464d8c 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,76 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/disputes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Dispute object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..b49c4f84c 100644 --- a/lib/Issuing/PersonalizationDesign.php +++ b/lib/Issuing/PersonalizationDesign.php @@ -25,13 +25,73 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/personalization_designs', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a personalization design object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..d1fb0de72 100644 --- a/lib/Issuing/PhysicalBundle.php +++ b/lib/Issuing/PhysicalBundle.php @@ -19,13 +19,37 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/physical_bundles', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a physical bundle object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..a7aeefca2 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,49 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/tokens', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Token object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..c7f07c0c3 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,52 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/issuing/transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an Issuing Transaction object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..fbd9658a5 100644 --- a/lib/Mandate.php +++ b/lib/Mandate.php @@ -23,12 +23,25 @@ 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 mixed $id + * @param null|mixed $opts + */ + 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/PaymentIntent.php b/lib/PaymentIntent.php index 82ac54f9c..15f02b0ad 100644 --- a/lib/PaymentIntent.php +++ b/lib/PaymentIntent.php @@ -62,9 +62,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; @@ -94,6 +91,90 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_intents', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..005f16887 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,67 @@ class PaymentLink extends ApiResource const SUBMIT_TYPE_DONATE = 'donate'; const SUBMIT_TYPE_PAY = 'pay'; + /** + * Creates a payment link. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_links', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve a payment link. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 fc5325dc7..859669b25 100644 --- a/lib/PaymentMethod.php +++ b/lib/PaymentMethod.php @@ -63,9 +63,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'; @@ -110,6 +107,82 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_methods', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 d6dc0877e..57271d299 100644 --- a/lib/PaymentMethodConfiguration.php +++ b/lib/PaymentMethodConfiguration.php @@ -71,8 +71,66 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_method_configurations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieve payment method configuration. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..be206e1a7 100644 --- a/lib/PaymentMethodDomain.php +++ b/lib/PaymentMethodDomain.php @@ -25,11 +25,69 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payment_method_domains', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing payment method domain. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..7abc62dca 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,83 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/payouts', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..c8491a595 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -114,4 +114,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/Plan.php b/lib/Plan.php index 348cfcbaa..61dc703a0 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,86 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/plans', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the plan with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 173193bd3..6f47138ef 100644 --- a/lib/Price.php +++ b/lib/Price.php @@ -38,9 +38,6 @@ class Price extends ApiResource { const OBJECT_NAME = 'price'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -57,6 +54,71 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/prices', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the price with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 df29fbb7a..14fb91a69 100644 --- a/lib/Product.php +++ b/lib/Product.php @@ -38,17 +38,96 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/products', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..a6c8564d7 100644 --- a/lib/PromotionCode.php +++ b/lib/PromotionCode.php @@ -26,8 +26,71 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/promotion_codes', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 48459ef63..0ce3f4312 100644 --- a/lib/Quote.php +++ b/lib/Quote.php @@ -48,9 +48,6 @@ class Quote extends ApiResource { const OBJECT_NAME = 'quote'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const COLLECTION_METHOD_CHARGE_AUTOMATICALLY = 'charge_automatically'; @@ -61,6 +58,70 @@ class Quote extends ApiResource const STATUS_DRAFT = 'draft'; const STATUS_OPEN = 'open'; + /** + * 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/quotes', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the quote with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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/Radar/EarlyFraudWarning.php b/lib/Radar/EarlyFraudWarning.php index f728ee9e6..0043453a2 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,34 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/radar/early_fraud_warnings', \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 mixed $id + * @param null|mixed $opts + */ + 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..c8b84eb4e 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,88 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/radar/value_lists', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ValueList object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..33f55b2df 100644 --- a/lib/Radar/ValueListItem.php +++ b/lib/Radar/ValueListItem.php @@ -21,8 +21,66 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/radar/value_list_items', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a ValueListItem object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..ce3a3e710 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,84 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/refunds', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing refund. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..7eaf485c2 100644 --- a/lib/Reporting/ReportRun.php +++ b/lib/Reporting/ReportRun.php @@ -29,7 +29,47 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/reporting/report_runs', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing Report Run. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..41aceb76c 100644 --- a/lib/Reporting/ReportType.php +++ b/lib/Reporting/ReportType.php @@ -28,6 +28,30 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/reporting/report_types', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a Report Type. (Certain report types require a live-mode API key.). + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..108ddc439 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,34 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/reviews', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Review object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..9cb53353d 100644 --- a/lib/SetupAttempt.php +++ b/lib/SetupAttempt.php @@ -30,5 +30,14 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/setup_attempts', \Stripe\Collection::class, $params, $opts); + } } diff --git a/lib/SetupIntent.php b/lib/SetupIntent.php index d8d62a2ac..c6399fec9 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,78 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/setup_intents', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..b4dd9f4f8 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,65 @@ class ShippingRate extends ApiResource const TAX_BEHAVIOR_UNSPECIFIED = 'unspecified'; const TYPE_FIXED_AMOUNT = 'fixed_amount'; + + /** + * Creates a new shipping rate object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/shipping_rates', \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns the shipping rate object with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..de07f7a1f 100644 --- a/lib/Sigma/ScheduledQueryRun.php +++ b/lib/Sigma/ScheduledQueryRun.php @@ -26,8 +26,31 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/sigma/scheduled_query_runs', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an scheduled query run. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 d03ede648..6f1da35fc 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -59,8 +59,6 @@ class Source extends ApiResource { const OBJECT_NAME = 'source'; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const FLOW_CODE_VERIFICATION = 'code_verification'; @@ -97,6 +95,64 @@ class Source extends ApiResource const USAGE_REUSABLE = 'reusable'; const USAGE_SINGLE_USE = 'single_use'; + /** + * Creates a new source object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 ce4f49cf4..ba4650861 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -59,9 +59,6 @@ class Subscription extends ApiResource { const OBJECT_NAME = 'subscription'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Search; use ApiOperations\Update; @@ -77,6 +74,125 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/subscriptions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the subscription with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 cde537c7d..ec7ea5baa 100644 --- a/lib/SubscriptionItem.php +++ b/lib/SubscriptionItem.php @@ -24,13 +24,88 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/subscription_items', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the subscription item with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 7434abf73..826af53f4 100644 --- a/lib/SubscriptionSchedule.php +++ b/lib/SubscriptionSchedule.php @@ -32,9 +32,6 @@ class SubscriptionSchedule extends ApiResource { const OBJECT_NAME = 'subscription_schedule'; - use ApiOperations\All; - use ApiOperations\Create; - use ApiOperations\Retrieve; use ApiOperations\Update; const END_BEHAVIOR_CANCEL = 'cancel'; @@ -48,6 +45,70 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/subscription_schedules', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..f9ab7b093 100644 --- a/lib/Tax/Calculation.php +++ b/lib/Tax/Calculation.php @@ -29,7 +29,22 @@ 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|mixed $params + * @param null|mixed $options + */ + 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/Registration.php b/lib/Tax/Registration.php index 6f0285f81..9f658db64 100644 --- a/lib/Tax/Registration.php +++ b/lib/Tax/Registration.php @@ -25,12 +25,73 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax/registrations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Returns a Tax Registration object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..ebdfeeec7 100644 --- a/lib/Tax/Settings.php +++ b/lib/Tax/Settings.php @@ -20,11 +20,23 @@ 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|mixed $opts + */ + 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 +56,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..6d51f8997 100644 --- a/lib/Tax/Transaction.php +++ b/lib/Tax/Transaction.php @@ -29,11 +29,24 @@ 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 mixed $id + * @param null|mixed $opts + */ + 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..6fe774f80 100644 --- a/lib/TaxCode.php +++ b/lib/TaxCode.php @@ -16,6 +16,31 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax_codes', \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 mixed $id + * @param null|mixed $opts + */ + 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..307a86322 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,65 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax_ids', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves an account or customer tax_id object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..016b8a934 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,66 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/tax_rates', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a tax rate with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..8f8d2465b 100644 --- a/lib/Terminal/Configuration.php +++ b/lib/Terminal/Configuration.php @@ -22,9 +22,82 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/terminal/configurations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Configuration object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..80758e5ab 100644 --- a/lib/Terminal/ConnectionToken.php +++ b/lib/Terminal/ConnectionToken.php @@ -17,5 +17,22 @@ 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|mixed $params + * @param null|mixed $options + */ + 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..7836f578b 100644 --- a/lib/Terminal/Location.php +++ b/lib/Terminal/Location.php @@ -21,9 +21,85 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/terminal/locations', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Location object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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 61e37f72a..746e0be32 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,84 @@ class Reader extends \Stripe\ApiResource const STATUS_OFFLINE = 'offline'; const STATUS_ONLINE = 'online'; + /** + * Creates a new Reader object. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/terminal/readers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a Reader object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..39de3270f 100644 --- a/lib/TestHelpers/TestClock.php +++ b/lib/TestHelpers/TestClock.php @@ -22,15 +22,69 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/test_helpers/test_clocks', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a test clock. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..892292201 100644 --- a/lib/Token.php +++ b/lib/Token.php @@ -40,11 +40,45 @@ 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|mixed $params + * @param null|mixed $options + */ + 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 mixed $id + * @param null|mixed $opts + */ + 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..566ba2560 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,70 @@ class Topup extends ApiResource const STATUS_REVERSED = 'reversed'; const STATUS_SUCCEEDED = 'succeeded'; + /** + * Top up the balance of an account. + * + * @param null|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/topups', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..a75052208 100644 --- a/lib/Transfer.php +++ b/lib/Transfer.php @@ -38,16 +38,83 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/transfers', \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 mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..2dcf7062b 100644 --- a/lib/Treasury/CreditReversal.php +++ b/lib/Treasury/CreditReversal.php @@ -26,14 +26,55 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/credit_reversals', \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 mixed $id + * @param null|mixed $opts + */ + 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..a6b3818c9 100644 --- a/lib/Treasury/DebitReversal.php +++ b/lib/Treasury/DebitReversal.php @@ -27,14 +27,53 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/debit_reversals', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a DebitReversal object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..efdc5fac6 100644 --- a/lib/Treasury/FinancialAccount.php +++ b/lib/Treasury/FinancialAccount.php @@ -29,14 +29,73 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/financial_accounts', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of a FinancialAccount. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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..03398d2b5 100644 --- a/lib/Treasury/InboundTransfer.php +++ b/lib/Treasury/InboundTransfer.php @@ -32,15 +32,54 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/inbound_transfers', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing InboundTransfer. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..395235f87 100644 --- a/lib/Treasury/OutboundPayment.php +++ b/lib/Treasury/OutboundPayment.php @@ -36,16 +36,57 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/outbound_payments', \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 mixed $id + * @param null|mixed $opts + */ + 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 a21be7bdb..c9930acd1 100644 --- a/lib/Treasury/OutboundTransfer.php +++ b/lib/Treasury/OutboundTransfer.php @@ -34,16 +34,57 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/outbound_transfers', \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 mixed $id + * @param null|mixed $opts + */ + 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 cf26ac4e3..5f0757374 100644 --- a/lib/Treasury/ReceivedCredit.php +++ b/lib/Treasury/ReceivedCredit.php @@ -28,9 +28,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'; @@ -42,4 +39,31 @@ class ReceivedCredit extends \Stripe\ApiResource const STATUS_FAILED = 'failed'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * Returns a list of ReceivedCredits. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/received_credits', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing ReceivedCredit by passing the unique + * ReceivedCredit ID from the ReceivedCredit list. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 08046dd50..393ddf089 100644 --- a/lib/Treasury/ReceivedDebit.php +++ b/lib/Treasury/ReceivedDebit.php @@ -28,9 +28,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'; @@ -42,4 +39,31 @@ class ReceivedDebit extends \Stripe\ApiResource const STATUS_FAILED = 'failed'; const STATUS_SUCCEEDED = 'succeeded'; + + /** + * Returns a list of ReceivedDebits. + * + * @param null|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/received_debits', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing ReceivedDebit by passing the unique + * ReceivedDebit ID from the ReceivedDebit list. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..8c1c080ff 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,30 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/transactions', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the details of an existing Transaction. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..79ebd445e 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,30 @@ 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/treasury/transaction_entries', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves a TransactionEntry object. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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..cc1983c5d 100644 --- a/lib/WebhookEndpoint.php +++ b/lib/WebhookEndpoint.php @@ -30,9 +30,93 @@ 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|mixed $params + * @param null|mixed $options + */ + 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|mixed $params + * @param null|mixed $opts + */ + 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|mixed $params + * @param null|mixed $opts + */ + public static function all($params = null, $opts = null) + { + return static::_requestPage('/v1/webhook_endpoints', \Stripe\Collection::class, $params, $opts); + } + + /** + * Retrieves the webhook endpoint with the given ID. + * + * @param mixed $id + * @param null|mixed $opts + */ + 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 mixed $id + * @param null|mixed $params + * @param null|mixed $opts + */ + 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; + } } From a6a3b01ccd6fd1b5c09b7fcaf6cd83e17c346a94 Mon Sep 17 00:00:00 2001 From: Prathmesh Ranaut Date: Wed, 29 May 2024 19:04:12 -0400 Subject: [PATCH 2/3] Improvements from codegen#1452 --- lib/Account.php | 41 +++++++++++++++----- lib/AccountLink.php | 9 ++++- lib/AccountSession.php | 9 ++++- lib/ApplePayDomain.php | 38 +++++++++++++----- lib/ApplicationFee.php | 20 +++++++--- lib/Apps/Secret.php | 21 +++++++--- lib/Balance.php | 6 ++- lib/BalanceTransaction.php | 20 +++++++--- lib/BankAccount.php | 17 +++++--- lib/Billing/Meter.php | 40 ++++++++++++++----- lib/Billing/MeterEvent.php | 9 ++++- lib/Billing/MeterEventAdjustment.php | 9 ++++- lib/BillingPortal/Configuration.php | 40 ++++++++++++++----- lib/BillingPortal/Session.php | 9 ++++- lib/Capability.php | 6 +-- lib/Card.php | 17 +++++--- lib/Charge.php | 40 ++++++++++++++----- lib/Checkout/Session.php | 29 ++++++++++---- lib/Climate/Order.php | 40 ++++++++++++++----- lib/Climate/Product.php | 20 +++++++--- lib/Climate/Supplier.php | 20 +++++++--- lib/ConfirmationToken.php | 8 +++- lib/CountrySpec.php | 20 +++++++--- lib/Coupon.php | 49 ++++++++++++++++++------ lib/CreditNote.php | 40 ++++++++++++++----- lib/Customer.php | 49 ++++++++++++++++++------ lib/CustomerSession.php | 9 ++++- lib/Dispute.php | 31 +++++++++++---- lib/Entitlements/ActiveEntitlement.php | 20 +++++++--- lib/Entitlements/Feature.php | 40 ++++++++++++++----- lib/EphemeralKey.php | 9 ++++- lib/Event.php | 20 +++++++--- lib/ExchangeRate.php | 20 +++++++--- lib/File.php | 20 +++++++--- lib/FileLink.php | 40 ++++++++++++++----- lib/FinancialConnections/Account.php | 20 +++++++--- lib/FinancialConnections/Session.php | 17 ++++++-- lib/FinancialConnections/Transaction.php | 20 +++++++--- lib/Forwarding/Request.php | 29 ++++++++++---- lib/Identity/VerificationReport.php | 20 +++++++--- lib/Identity/VerificationSession.php | 40 ++++++++++++++----- lib/Invoice.php | 49 ++++++++++++++++++------ lib/InvoiceItem.php | 49 ++++++++++++++++++------ lib/InvoiceLineItem.php | 11 ++++-- lib/Issuing/Authorization.php | 31 +++++++++++---- lib/Issuing/Card.php | 40 ++++++++++++++----- lib/Issuing/Cardholder.php | 40 ++++++++++++++----- lib/Issuing/Dispute.php | 40 ++++++++++++++----- lib/Issuing/PersonalizationDesign.php | 40 ++++++++++++++----- lib/Issuing/PhysicalBundle.php | 20 +++++++--- lib/Issuing/Token.php | 31 +++++++++++---- lib/Issuing/Transaction.php | 31 +++++++++++---- lib/Mandate.php | 8 +++- lib/PaymentIntent.php | 40 ++++++++++++++----- lib/PaymentLink.php | 40 ++++++++++++++----- lib/PaymentMethod.php | 40 ++++++++++++++----- lib/PaymentMethodConfiguration.php | 40 ++++++++++++++----- lib/PaymentMethodDomain.php | 40 ++++++++++++++----- lib/Payout.php | 40 ++++++++++++++----- lib/Person.php | 5 +-- lib/Plan.php | 49 ++++++++++++++++++------ lib/Price.php | 40 ++++++++++++++----- lib/Product.php | 49 ++++++++++++++++++------ lib/PromotionCode.php | 40 ++++++++++++++----- lib/Quote.php | 40 ++++++++++++++----- lib/Radar/EarlyFraudWarning.php | 20 +++++++--- lib/Radar/ValueList.php | 49 ++++++++++++++++++------ lib/Radar/ValueListItem.php | 38 +++++++++++++----- lib/Refund.php | 40 ++++++++++++++----- lib/Reporting/ReportRun.php | 29 ++++++++++---- lib/Reporting/ReportType.php | 20 +++++++--- lib/Review.php | 20 +++++++--- lib/SetupAttempt.php | 12 ++++-- lib/SetupIntent.php | 40 ++++++++++++++----- lib/ShippingRate.php | 40 ++++++++++++++----- lib/Sigma/ScheduledQueryRun.php | 20 +++++++--- lib/Source.php | 28 ++++++++++---- lib/Subscription.php | 40 ++++++++++++++----- lib/SubscriptionItem.php | 49 ++++++++++++++++++------ lib/SubscriptionSchedule.php | 40 ++++++++++++++----- lib/Tax/Calculation.php | 9 ++++- lib/Tax/Registration.php | 40 ++++++++++++++----- lib/Tax/Settings.php | 6 ++- lib/Tax/Transaction.php | 8 +++- lib/TaxCode.php | 20 +++++++--- lib/TaxId.php | 38 +++++++++++++----- lib/TaxRate.php | 40 ++++++++++++++----- lib/Terminal/Configuration.php | 49 ++++++++++++++++++------ lib/Terminal/ConnectionToken.php | 9 ++++- lib/Terminal/Location.php | 49 ++++++++++++++++++------ lib/Terminal/Reader.php | 49 ++++++++++++++++++------ lib/TestHelpers/TestClock.php | 38 +++++++++++++----- lib/Token.php | 17 ++++++-- lib/Topup.php | 40 ++++++++++++++----- lib/Transfer.php | 40 ++++++++++++++----- lib/Treasury/CreditReversal.php | 29 ++++++++++---- lib/Treasury/DebitReversal.php | 29 ++++++++++---- lib/Treasury/FinancialAccount.php | 40 ++++++++++++++----- lib/Treasury/InboundTransfer.php | 29 ++++++++++---- lib/Treasury/OutboundPayment.php | 29 ++++++++++---- lib/Treasury/OutboundTransfer.php | 29 ++++++++++---- lib/Treasury/ReceivedCredit.php | 20 +++++++--- lib/Treasury/ReceivedDebit.php | 20 +++++++--- lib/Treasury/Transaction.php | 20 +++++++--- lib/Treasury/TransactionEntry.php | 20 +++++++--- lib/WebhookEndpoint.php | 49 ++++++++++++++++++------ 106 files changed, 2316 insertions(+), 769 deletions(-) diff --git a/lib/Account.php b/lib/Account.php index 4904a86b8..d6b9bea99 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -70,13 +70,18 @@ class Account extends ApiResource * information during account onboarding. You can prefill any information on the * account. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -99,12 +104,17 @@ public static function create($params = null, $options = null) * href="https://dashboard.stripe.com/settings/account">account information tab in * your account settings instead. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -116,12 +126,18 @@ public function delete($params = null, $opts = null) * Returns a list of accounts connected to your platform via Connect. If you’re not a platform, the list is empty. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/accounts', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -145,14 +161,19 @@ public static function all($params = null, $opts = null) * Connect documentation to learn * more about updating accounts. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/AccountLink.php b/lib/AccountLink.php index 19604fe84..339d0a1d9 100644 --- a/lib/AccountLink.php +++ b/lib/AccountLink.php @@ -24,13 +24,18 @@ class AccountLink extends ApiResource * platform can redirect their user to in order to take them through the Connect * Onboarding flow. * - * @param null|mixed $params - * @param null|mixed $options + * @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); diff --git a/lib/AccountSession.php b/lib/AccountSession.php index 5b575119e..85b04c9b3 100644 --- a/lib/AccountSession.php +++ b/lib/AccountSession.php @@ -28,13 +28,18 @@ class AccountSession extends ApiResource * 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|mixed $params - * @param null|mixed $options + * @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); diff --git a/lib/ApplePayDomain.php b/lib/ApplePayDomain.php index e22589e3a..db37b6a01 100644 --- a/lib/ApplePayDomain.php +++ b/lib/ApplePayDomain.php @@ -18,13 +18,18 @@ class ApplePayDomain extends ApiResource /** * Create an apple pay domain. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -35,12 +40,17 @@ public static function create($params = null, $options = null) /** * Delete an apple pay domain. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -51,19 +61,29 @@ public function delete($params = null, $opts = null) /** * List apple pay domains. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/apple_pay/domains', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieve an apple pay domain. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/ApplicationFee.php b/lib/ApplicationFee.php index f031a7bbe..1843c27c4 100644 --- a/lib/ApplicationFee.php +++ b/lib/ApplicationFee.php @@ -31,20 +31,30 @@ class ApplicationFee extends ApiResource * 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|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/application_fees', \Stripe\Collection::class, $params, $opts); + $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 mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Apps/Secret.php b/lib/Apps/Secret.php index 1faa9c9b7..948f3dc14 100644 --- a/lib/Apps/Secret.php +++ b/lib/Apps/Secret.php @@ -32,13 +32,18 @@ class Secret extends \Stripe\ApiResource /** * Create or replace a secret in the secret store. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -49,12 +54,18 @@ public static function create($params = null, $options = null) /** * List all secrets stored on the given scope. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/apps/secrets', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** diff --git a/lib/Balance.php b/lib/Balance.php index 947c7829d..61c8f40ef 100644 --- a/lib/Balance.php +++ b/lib/Balance.php @@ -35,7 +35,11 @@ class Balance extends SingletonApiResource * href="/docs/connect/account-balances#accounting-for-negative-balances">Accounting * for negative balances. * - * @param null|mixed $opts + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Balance */ public static function retrieve($opts = null) { diff --git a/lib/BalanceTransaction.php b/lib/BalanceTransaction.php index 51551424f..d88cf9b52 100644 --- a/lib/BalanceTransaction.php +++ b/lib/BalanceTransaction.php @@ -79,12 +79,18 @@ class BalanceTransaction extends ApiResource * Note that this endpoint was previously called “Balance history” and used the * path /v1/balance/history. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/balance_transactions', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -93,8 +99,12 @@ public static function all($params = null, $opts = null) * Note that this endpoint previously used the path * /v1/balance/history/:id. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/BankAccount.php b/lib/BankAccount.php index 02b7b9a48..cbb6e7543 100644 --- a/lib/BankAccount.php +++ b/lib/BankAccount.php @@ -41,12 +41,17 @@ class BankAccount extends ApiResource /** * Delete a specified external account for a given account. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -117,10 +122,10 @@ public static function retrieve($_id, $_opts = null) public static function update($_id, $_params = null, $_options = null) { $msg = 'Bank accounts cannot be updated without a customer ID or an ' . - 'account ID. Update a bank account using ' . - "`Customer::updateSource('customer_id', 'bank_account_id', " . - '$updateParams)` or `Account::updateExternalAccount(' . - "'account_id', 'bank_account_id', \$updateParams)`."; + 'account ID. Update a bank account using ' . + "`Customer::updateSource('customer_id', 'bank_account_id', " . + '$updateParams)` or `Account::updateExternalAccount(' . + "'account_id', 'bank_account_id', \$updateParams)`."; throw new Exception\BadMethodCallException($msg); } diff --git a/lib/Billing/Meter.php b/lib/Billing/Meter.php index e2703007b..e89213981 100644 --- a/lib/Billing/Meter.php +++ b/lib/Billing/Meter.php @@ -37,13 +37,18 @@ class Meter extends \Stripe\ApiResource /** * Creates a billing meter. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -54,19 +59,29 @@ public static function create($params = null, $options = null) /** * Retrieve a list of billing meters. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/billing/meters', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a billing meter given an ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -80,14 +95,19 @@ public static function retrieve($id, $opts = null) /** * Updates a billing meter. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Billing/MeterEvent.php b/lib/Billing/MeterEvent.php index 8606c6bea..8d93eb93e 100644 --- a/lib/Billing/MeterEvent.php +++ b/lib/Billing/MeterEvent.php @@ -23,13 +23,18 @@ class MeterEvent extends \Stripe\ApiResource /** * Creates a billing meter event. * - * @param null|mixed $params - * @param null|mixed $options + * @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); diff --git a/lib/Billing/MeterEventAdjustment.php b/lib/Billing/MeterEventAdjustment.php index 2920825e9..90863fb68 100644 --- a/lib/Billing/MeterEventAdjustment.php +++ b/lib/Billing/MeterEventAdjustment.php @@ -24,13 +24,18 @@ class MeterEventAdjustment extends \Stripe\ApiResource /** * Creates a billing meter event adjustment. * - * @param null|mixed $params - * @param null|mixed $options + * @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); diff --git a/lib/BillingPortal/Configuration.php b/lib/BillingPortal/Configuration.php index 78e6739a3..04b2c6208 100644 --- a/lib/BillingPortal/Configuration.php +++ b/lib/BillingPortal/Configuration.php @@ -31,13 +31,18 @@ class Configuration extends \Stripe\ApiResource * Creates a configuration that describes the functionality and behavior of a * PortalSession. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -49,20 +54,30 @@ public static function create($params = null, $options = null) * Returns a list of configurations that describe the functionality of the customer * portal. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/billing_portal/configurations', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a configuration that describes the functionality of the customer * portal. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -76,14 +91,19 @@ public static function retrieve($id, $opts = null) /** * Updates a configuration that describes the functionality of the customer portal. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/BillingPortal/Session.php b/lib/BillingPortal/Session.php index bb8c77fdb..a6554278c 100644 --- a/lib/BillingPortal/Session.php +++ b/lib/BillingPortal/Session.php @@ -39,13 +39,18 @@ class Session extends \Stripe\ApiResource /** * Creates a session of the customer portal. * - * @param null|mixed $params - * @param null|mixed $options + * @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); diff --git a/lib/Capability.php b/lib/Capability.php index 23bdba470..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,8 +76,8 @@ 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); } diff --git a/lib/Card.php b/lib/Card.php index 9670da424..f231507c6 100644 --- a/lib/Card.php +++ b/lib/Card.php @@ -48,12 +48,17 @@ class Card extends ApiResource /** * Delete a specified external account for a given account. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -141,10 +146,10 @@ public static function retrieve($_id, $_opts = null) public static function update($_id, $_params = null, $_options = null) { $msg = 'Cards cannot be updated without a customer ID or an ' . - 'account ID. Update a card using ' . - "`Customer::updateSource('customer_id', 'card_id', " . - '$updateParams)` or `Account::updateExternalAccount(' . - "'account_id', 'card_id', \$updateParams)`."; + 'account ID. Update a card using ' . + "`Customer::updateSource('customer_id', 'card_id', " . + '$updateParams)` or `Account::updateExternalAccount(' . + "'account_id', 'card_id', \$updateParams)`."; throw new Exception\BadMethodCallException($msg); } diff --git a/lib/Charge.php b/lib/Charge.php index 792f7af4a..4b1d575ec 100644 --- a/lib/Charge.php +++ b/lib/Charge.php @@ -77,13 +77,18 @@ class Charge extends ApiResource * payment instead. Confirmation of the PaymentIntent creates the * Charge object used to request payment. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -95,12 +100,18 @@ public static function create($params = null, $options = null) * 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|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/charges', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -109,8 +120,12 @@ public static function all($params = null, $opts = null) * return the corresponding charge information. The same information is returned * when creating or refunding the charge. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -125,14 +140,19 @@ public static function retrieve($id, $opts = null) * Updates the specified charge by setting the values of the parameters passed. Any * parameters not provided will be left unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Checkout/Session.php b/lib/Checkout/Session.php index 103086401..e9101421e 100644 --- a/lib/Checkout/Session.php +++ b/lib/Checkout/Session.php @@ -116,13 +116,18 @@ class Session extends \Stripe\ApiResource /** * Creates a Session object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -133,19 +138,29 @@ public static function create($params = null, $options = null) /** * Returns a list of Checkout Sessions. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/checkout/sessions', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a Session object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Climate/Order.php b/lib/Climate/Order.php index b5d3d1dac..5d96204c2 100644 --- a/lib/Climate/Order.php +++ b/lib/Climate/Order.php @@ -52,13 +52,18 @@ class Order extends \Stripe\ApiResource * processed immediately after creation and payment will be deducted your Stripe * balance. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -70,19 +75,29 @@ public static function create($params = null, $options = null) * Lists all Climate order objects. The orders are returned sorted by creation * date, with the most recently created orders appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/climate/orders', \Stripe\Collection::class, $params, $opts); + $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 mixed $id - * @param null|mixed $opts + * @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) { @@ -96,14 +111,19 @@ public static function retrieve($id, $opts = null) /** * Updates the specified order by setting the values of the parameters passed. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Climate/Product.php b/lib/Climate/Product.php index 987ae51df..3b7bc61c1 100644 --- a/lib/Climate/Product.php +++ b/lib/Climate/Product.php @@ -25,19 +25,29 @@ class Product extends \Stripe\ApiResource /** * Lists all available Climate product objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/climate/products', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of a Climate product with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Climate/Supplier.php b/lib/Climate/Supplier.php index a38cfeb88..4b298c9d6 100644 --- a/lib/Climate/Supplier.php +++ b/lib/Climate/Supplier.php @@ -26,19 +26,29 @@ class Supplier extends \Stripe\ApiResource /** * Lists all available Climate supplier objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/climate/suppliers', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a Climate supplier object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/ConfirmationToken.php b/lib/ConfirmationToken.php index e4cb7829f..ee78a3131 100644 --- a/lib/ConfirmationToken.php +++ b/lib/ConfirmationToken.php @@ -37,8 +37,12 @@ class ConfirmationToken extends ApiResource /** * Retrieves an existing ConfirmationToken object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/CountrySpec.php b/lib/CountrySpec.php index be1ae660c..aa601a7ac 100644 --- a/lib/CountrySpec.php +++ b/lib/CountrySpec.php @@ -28,19 +28,29 @@ class CountrySpec extends ApiResource /** * Lists all Country Spec objects available in the API. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/country_specs', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Returns a Country Spec for a given Country code. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Coupon.php b/lib/Coupon.php index bdc157bbe..cf110919a 100644 --- a/lib/Coupon.php +++ b/lib/Coupon.php @@ -53,13 +53,18 @@ class Coupon extends ApiResource * a coupon with an amount_off of 200 is applied to * it. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -74,12 +79,17 @@ public static function create($params = null, $options = null) * 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|mixed $params - * @param null|mixed $opts + * @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); @@ -90,19 +100,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of your coupons. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/coupons', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the coupon with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -117,14 +137,19 @@ public static function retrieve($id, $opts = null) * Updates the metadata of a coupon. Other coupon details (currency, duration, * amount_off) are, by design, not editable. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/CreditNote.php b/lib/CreditNote.php index bc846d6a2..7173d10a4 100644 --- a/lib/CreditNote.php +++ b/lib/CreditNote.php @@ -80,13 +80,18 @@ class CreditNote extends ApiResource * post_payment_credit_notes_amount depending on its * status at the time of credit note creation. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -97,19 +102,29 @@ public static function create($params = null, $options = null) /** * Returns a list of credit notes. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/credit_notes', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the credit note object with the given identifier. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -123,14 +138,19 @@ public static function retrieve($id, $opts = null) /** * Updates an existing credit note. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Customer.php b/lib/Customer.php index 9291b9d1b..a89347462 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -53,13 +53,18 @@ class Customer extends ApiResource /** * Creates a new customer object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -71,12 +76,17 @@ public static function create($params = null, $options = null) * Permanently deletes a customer. It cannot be undone. Also immediately cancels * any active subscriptions on the customer. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -88,19 +98,29 @@ public function delete($params = null, $opts = null) * Returns a list of your customers. The customers are returned sorted by creation * date, with the most recent customers appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/customers', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a Customer object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -126,14 +146,19 @@ public static function retrieve($id, $opts = null) * * This request accepts mostly the same arguments as the customer creation call. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/CustomerSession.php b/lib/CustomerSession.php index f36dcfa1c..6c4db5d72 100644 --- a/lib/CustomerSession.php +++ b/lib/CustomerSession.php @@ -25,13 +25,18 @@ class CustomerSession extends ApiResource * you can use on your front-end to grant client-side API access for certain * customer resources. * - * @param null|mixed $params - * @param null|mixed $options + * @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); diff --git a/lib/Dispute.php b/lib/Dispute.php index 4024816e1..088f944a1 100644 --- a/lib/Dispute.php +++ b/lib/Dispute.php @@ -61,19 +61,29 @@ class Dispute extends ApiResource /** * Returns a list of your disputes. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/disputes', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the dispute with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -95,14 +105,19 @@ public static function retrieve($id, $opts = null) * chance of winning your dispute. To figure out which evidence fields to provide, * see our guide to dispute types. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Entitlements/ActiveEntitlement.php b/lib/Entitlements/ActiveEntitlement.php index 013967237..d3ea3265e 100644 --- a/lib/Entitlements/ActiveEntitlement.php +++ b/lib/Entitlements/ActiveEntitlement.php @@ -20,19 +20,29 @@ class ActiveEntitlement extends \Stripe\ApiResource /** * Retrieve a list of active entitlements for a customer. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/entitlements/active_entitlements', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieve an active entitlement. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Entitlements/Feature.php b/lib/Entitlements/Feature.php index 64ffb73da..f7cd75c39 100644 --- a/lib/Entitlements/Feature.php +++ b/lib/Entitlements/Feature.php @@ -25,13 +25,18 @@ class Feature extends \Stripe\ApiResource /** * Creates a feature. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -42,19 +47,29 @@ public static function create($params = null, $options = null) /** * Retrieve a list of features. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/entitlements/features', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a feature. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -68,14 +83,19 @@ public static function retrieve($id, $opts = null) /** * Update a feature’s metadata or permanently deactivate it. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/EphemeralKey.php b/lib/EphemeralKey.php index 4f2d43f22..b69b02220 100644 --- a/lib/EphemeralKey.php +++ b/lib/EphemeralKey.php @@ -19,12 +19,17 @@ class EphemeralKey extends ApiResource /** * Invalidates a short-lived API key for a given resource. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Event.php b/lib/Event.php index 14adf27f7..77a4857a7 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -521,20 +521,30 @@ class Event extends ApiResource * api_version attribute (not according to your current Stripe API * version or Stripe-Version header). * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/events', \Stripe\Collection::class, $params, $opts); + $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 mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/ExchangeRate.php b/lib/ExchangeRate.php index babed598d..dbfda216f 100644 --- a/lib/ExchangeRate.php +++ b/lib/ExchangeRate.php @@ -44,20 +44,30 @@ class ExchangeRate extends ApiResource * 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|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/exchange_rates', \Stripe\Collection::class, $params, $opts); + $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 mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/File.php b/lib/File.php index f39f75d71..73a0a0803 100644 --- a/lib/File.php +++ b/lib/File.php @@ -50,12 +50,18 @@ class File extends ApiResource * returns the files by their creation dates, placing the most recently created * files at the top. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/files', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -63,8 +69,12 @@ public static function all($params = null, $opts = null) * ID, Stripe returns the corresponding file object. Learn how to access file contents. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/FileLink.php b/lib/FileLink.php index 431aebd2b..8c449223e 100644 --- a/lib/FileLink.php +++ b/lib/FileLink.php @@ -28,13 +28,18 @@ class FileLink extends ApiResource /** * Creates a new file link object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -45,19 +50,29 @@ public static function create($params = null, $options = null) /** * Returns a list of file links. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/file_links', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the file link with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -71,14 +86,19 @@ public static function retrieve($id, $opts = null) /** * Updates an existing file link object. Expired links can no longer be updated. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/FinancialConnections/Account.php b/lib/FinancialConnections/Account.php index fbe45c4ea..e0f33d93d 100644 --- a/lib/FinancialConnections/Account.php +++ b/lib/FinancialConnections/Account.php @@ -50,19 +50,29 @@ class Account extends \Stripe\ApiResource /** * Returns a list of Financial Connections Account objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/financial_connections/accounts', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of an Financial Connections Account. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/FinancialConnections/Session.php b/lib/FinancialConnections/Session.php index a8606b7ae..1bfd2af90 100644 --- a/lib/FinancialConnections/Session.php +++ b/lib/FinancialConnections/Session.php @@ -27,13 +27,18 @@ class Session extends \Stripe\ApiResource * Session. The session’s client_secret can be used to * launch the flow using Stripe.js. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -44,8 +49,12 @@ public static function create($params = null, $options = null) /** * Retrieves the details of a Financial Connections Session. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/FinancialConnections/Transaction.php b/lib/FinancialConnections/Transaction.php index 8fe585534..8f90ab6be 100644 --- a/lib/FinancialConnections/Transaction.php +++ b/lib/FinancialConnections/Transaction.php @@ -31,19 +31,29 @@ class Transaction extends \Stripe\ApiResource /** * Returns a list of Financial Connections Transaction objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/financial_connections/transactions', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of a Financial Connections Transaction. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Forwarding/Request.php b/lib/Forwarding/Request.php index a6178ff0e..f772c91bf 100644 --- a/lib/Forwarding/Request.php +++ b/lib/Forwarding/Request.php @@ -40,13 +40,18 @@ class Request extends \Stripe\ApiResource /** * Creates a ForwardingRequest object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -57,19 +62,29 @@ public static function create($params = null, $options = null) /** * Lists all ForwardingRequest objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/forwarding/requests', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a ForwardingRequest object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Identity/VerificationReport.php b/lib/Identity/VerificationReport.php index fbcbbc9d6..77fa02c68 100644 --- a/lib/Identity/VerificationReport.php +++ b/lib/Identity/VerificationReport.php @@ -43,19 +43,29 @@ class VerificationReport extends \Stripe\ApiResource /** * List all verification reports. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/identity/verification_reports', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves an existing VerificationReport. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Identity/VerificationSession.php b/lib/Identity/VerificationSession.php index 71ff5f018..8ba9a663c 100644 --- a/lib/Identity/VerificationSession.php +++ b/lib/Identity/VerificationSession.php @@ -63,13 +63,18 @@ class VerificationSession extends \Stripe\ApiResource * Related guide: Verify your * users’ identity documents * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -80,12 +85,18 @@ public static function create($params = null, $options = null) /** * Returns a list of VerificationSessions. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/identity/verification_sessions', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -95,8 +106,12 @@ public static function all($params = null, $opts = null) * to retrieve a valid client_secret or url to allow * re-submission. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -113,14 +128,19 @@ public static function retrieve($id, $opts = null) * When the session status is requires_input, you can use this method * to update the verification check and options. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Invoice.php b/lib/Invoice.php index 62f18ebfd..ad158fc3f 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -158,13 +158,18 @@ class Invoice extends ApiResource * allows you to pay or send * the invoice to your customers. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -178,12 +183,17 @@ public static function create($params = null, $options = null) * has been finalized or if an invoice is for a subscription, it must be voided. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -196,19 +206,29 @@ public function delete($params = null, $opts = null) * invoices are returned sorted by creation date, with the most recently created * invoices appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/invoices', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the invoice with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -229,14 +249,19 @@ public static function retrieve($id, $opts = null) * href="/docs/billing/invoices/reconciliation">automatically reconciling * invoices, pass auto_advance=false. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/InvoiceItem.php b/lib/InvoiceItem.php index 6efa24a34..49c323ce1 100644 --- a/lib/InvoiceItem.php +++ b/lib/InvoiceItem.php @@ -52,13 +52,18 @@ class InvoiceItem extends ApiResource * no invoice is specified, the item will be on the next invoice created for the * customer specified. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -71,12 +76,17 @@ public static function create($params = null, $options = null) * only possible when they’re not attached to invoices, or if it’s attached to a * draft invoice. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -88,19 +98,29 @@ public function delete($params = null, $opts = null) * 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|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/invoiceitems', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the invoice item with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -116,14 +136,19 @@ public static function retrieve($id, $opts = null) * Updating an invoice item is only possible before the invoice it’s attached to is * closed. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/InvoiceLineItem.php b/lib/InvoiceLineItem.php index 84805ca90..51c37624c 100644 --- a/lib/InvoiceLineItem.php +++ b/lib/InvoiceLineItem.php @@ -45,14 +45,19 @@ class InvoiceLineItem extends ApiResource * the invoice item as well. Updating an invoice’s line item is only possible * before the invoice is finalized. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Issuing/Authorization.php b/lib/Issuing/Authorization.php index db8cf71d2..f675cb167 100644 --- a/lib/Issuing/Authorization.php +++ b/lib/Issuing/Authorization.php @@ -58,19 +58,29 @@ class Authorization extends \Stripe\ApiResource * sorted in descending order by creation date, with the most recently created * object appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/issuing/authorizations', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves an Issuing Authorization object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -86,14 +96,19 @@ public static function retrieve($id, $opts = null) * values of the parameters passed. Any parameters not provided will be left * unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Issuing/Card.php b/lib/Issuing/Card.php index 55fbb0c87..5f21ce58d 100644 --- a/lib/Issuing/Card.php +++ b/lib/Issuing/Card.php @@ -57,13 +57,18 @@ class Card extends \Stripe\ApiResource /** * Creates an Issuing Card object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -76,19 +81,29 @@ public static function create($params = null, $options = null) * descending order by creation date, with the most recently created object * appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/issuing/cards', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves an Issuing Card object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -103,14 +118,19 @@ public static function retrieve($id, $opts = null) * Updates the specified Issuing Card object by setting the values of * the parameters passed. Any parameters not provided will be left unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Issuing/Cardholder.php b/lib/Issuing/Cardholder.php index 0cea7ad0d..14de48703 100644 --- a/lib/Issuing/Cardholder.php +++ b/lib/Issuing/Cardholder.php @@ -42,13 +42,18 @@ class Cardholder extends \Stripe\ApiResource /** * Creates a new Issuing Cardholder object that can be issued cards. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -61,19 +66,29 @@ public static function create($params = null, $options = null) * sorted in descending order by creation date, with the most recently created * object appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/issuing/cardholders', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves an Issuing Cardholder object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -89,14 +104,19 @@ public static function retrieve($id, $opts = null) * values of the parameters passed. Any parameters not provided will be left * unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Issuing/Dispute.php b/lib/Issuing/Dispute.php index afc464d8c..b05c7e870 100644 --- a/lib/Issuing/Dispute.php +++ b/lib/Issuing/Dispute.php @@ -63,13 +63,18 @@ class Dispute extends \Stripe\ApiResource * href="/docs/issuing/purchases/disputes#dispute-reasons-and-evidence">Dispute * reasons and evidence for more details about evidence requirements. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -82,19 +87,29 @@ public static function create($params = null, $options = null) * in descending order by creation date, with the most recently created object * appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/issuing/disputes', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves an Issuing Dispute object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -111,14 +126,19 @@ public static function retrieve($id, $opts = null) * Properties on the evidence object can be unset by passing in an * empty string. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Issuing/PersonalizationDesign.php b/lib/Issuing/PersonalizationDesign.php index b49c4f84c..d2e472a57 100644 --- a/lib/Issuing/PersonalizationDesign.php +++ b/lib/Issuing/PersonalizationDesign.php @@ -35,13 +35,18 @@ class PersonalizationDesign extends \Stripe\ApiResource /** * Creates a personalization design object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -54,19 +59,29 @@ public static function create($params = null, $options = null) * descending order by creation date, with the most recently created object * appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/issuing/personalization_designs', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a personalization design object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -80,14 +95,19 @@ public static function retrieve($id, $opts = null) /** * Updates a card personalization object. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Issuing/PhysicalBundle.php b/lib/Issuing/PhysicalBundle.php index d1fb0de72..1f372a245 100644 --- a/lib/Issuing/PhysicalBundle.php +++ b/lib/Issuing/PhysicalBundle.php @@ -30,19 +30,29 @@ class PhysicalBundle extends \Stripe\ApiResource * 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|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/issuing/physical_bundles', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a physical bundle object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Issuing/Token.php b/lib/Issuing/Token.php index a7aeefca2..196c7aba3 100644 --- a/lib/Issuing/Token.php +++ b/lib/Issuing/Token.php @@ -41,19 +41,29 @@ class Token extends \Stripe\ApiResource /** * Lists all Issuing Token objects for a given card. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/issuing/tokens', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves an Issuing Token object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -68,14 +78,19 @@ public static function retrieve($id, $opts = null) * Attempts to update the specified Issuing Token object to the status * specified. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Issuing/Transaction.php b/lib/Issuing/Transaction.php index c7f07c0c3..45585a010 100644 --- a/lib/Issuing/Transaction.php +++ b/lib/Issuing/Transaction.php @@ -52,19 +52,29 @@ class Transaction extends \Stripe\ApiResource * sorted in descending order by creation date, with the most recently created * object appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/issuing/transactions', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves an Issuing Transaction object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -80,14 +90,19 @@ public static function retrieve($id, $opts = null) * values of the parameters passed. Any parameters not provided will be left * unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Mandate.php b/lib/Mandate.php index fbd9658a5..0974b96a3 100644 --- a/lib/Mandate.php +++ b/lib/Mandate.php @@ -33,8 +33,12 @@ class Mandate extends ApiResource /** * Retrieves a Mandate object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/PaymentIntent.php b/lib/PaymentIntent.php index 15f02b0ad..f3b122237 100644 --- a/lib/PaymentIntent.php +++ b/lib/PaymentIntent.php @@ -104,13 +104,18 @@ class PaymentIntent extends ApiResource * parameters available in the confirm * API when you supply confirm=true. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -121,12 +126,18 @@ public static function create($params = null, $options = null) /** * Returns a list of PaymentIntents. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/payment_intents', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -139,8 +150,12 @@ public static function all($params = null, $opts = null) * of properties. Refer to the payment intent * object reference for more details. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -160,14 +175,19 @@ public static function retrieve($id, $opts = null) * and confirm at the same time, we recommend updating properties through the confirm API instead. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/PaymentLink.php b/lib/PaymentLink.php index 005f16887..e65546191 100644 --- a/lib/PaymentLink.php +++ b/lib/PaymentLink.php @@ -68,13 +68,18 @@ class PaymentLink extends ApiResource /** * Creates a payment link. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -85,19 +90,29 @@ public static function create($params = null, $options = null) /** * Returns a list of your payment links. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/payment_links', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieve a payment link. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -111,14 +126,19 @@ public static function retrieve($id, $opts = null) /** * Updates a payment link. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/PaymentMethod.php b/lib/PaymentMethod.php index 859669b25..5f5fd3dbc 100644 --- a/lib/PaymentMethod.php +++ b/lib/PaymentMethod.php @@ -118,13 +118,18 @@ class PaymentMethod extends ApiResource * href="/docs/payments/save-and-reuse">SetupIntent API to collect payment * method details ahead of a future payment. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -138,12 +143,18 @@ public static function create($params = null, $options = null) * href="/docs/api/payment_methods/customer_list">List a Customer’s * PaymentMethods API instead. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/payment_methods', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -152,8 +163,12 @@ public static function all($params = null, $opts = null) * href="/docs/api/payment_methods/customer">Retrieve a Customer’s * PaymentMethods. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -168,14 +183,19 @@ public static function retrieve($id, $opts = null) * Updates a PaymentMethod object. A PaymentMethod must be attached a customer to * be updated. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/PaymentMethodConfiguration.php b/lib/PaymentMethodConfiguration.php index 57271d299..1815d6d84 100644 --- a/lib/PaymentMethodConfiguration.php +++ b/lib/PaymentMethodConfiguration.php @@ -76,13 +76,18 @@ class PaymentMethodConfiguration extends ApiResource /** * Creates a payment method configuration. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -93,19 +98,29 @@ public static function create($params = null, $options = null) /** * List payment method configurations. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/payment_method_configurations', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieve payment method configuration. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -119,14 +134,19 @@ public static function retrieve($id, $opts = null) /** * Update payment method configuration. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/PaymentMethodDomain.php b/lib/PaymentMethodDomain.php index be206e1a7..2121adcc0 100644 --- a/lib/PaymentMethodDomain.php +++ b/lib/PaymentMethodDomain.php @@ -30,13 +30,18 @@ class PaymentMethodDomain extends ApiResource /** * Creates a payment method domain. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -47,19 +52,29 @@ public static function create($params = null, $options = null) /** * Lists the details of existing payment method domains. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/payment_method_domains', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of an existing payment method domain. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -73,14 +88,19 @@ public static function retrieve($id, $opts = null) /** * Updates an existing payment method domain. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Payout.php b/lib/Payout.php index 7abc62dca..5757fcb63 100644 --- a/lib/Payout.php +++ b/lib/Payout.php @@ -75,13 +75,18 @@ class Payout extends ApiResource * from. The balance object details available and * pending amounts by source type. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -94,12 +99,18 @@ public static function create($params = null, $options = null) * that Stripe sent to you. The payouts return in sorted order, with the most * recently created payouts appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/payouts', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -107,8 +118,12 @@ public static function all($params = null, $opts = null) * either a payout creation request or the payout list. Stripe returns the * corresponding payout information. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -124,14 +139,19 @@ public static function retrieve($id, $opts = null) * We don’t change parameters that you don’t provide. This request only accepts the * metadata as arguments. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Person.php b/lib/Person.php index c8491a595..d2bc5cafe 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,8 +108,8 @@ 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); } diff --git a/lib/Plan.php b/lib/Plan.php index 61dc703a0..53d869b71 100644 --- a/lib/Plan.php +++ b/lib/Plan.php @@ -66,13 +66,18 @@ class Plan extends ApiResource * API. It replaces the Plans API and is backwards compatible to simplify your * migration. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -84,12 +89,17 @@ public static function create($params = null, $options = null) * Deleting plans means new subscribers can’t be added. Existing subscribers aren’t * affected. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -100,19 +110,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of your plans. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/plans', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the plan with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -128,14 +148,19 @@ public static function retrieve($id, $opts = null) * parameters not provided are left unchanged. By design, you cannot change a * plan’s ID, amount, currency, or billing cycle. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Price.php b/lib/Price.php index 6f47138ef..20d67f7a2 100644 --- a/lib/Price.php +++ b/lib/Price.php @@ -58,13 +58,18 @@ class Price extends ApiResource * Creates a new price for an existing product. The price can be recurring or * one-time. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -77,19 +82,29 @@ public static function create($params = null, $options = null) * href="/docs/products-prices/pricing-models#inline-pricing">inline prices. * For the list of inactive prices, set active to false. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/prices', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the price with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -104,14 +119,19 @@ public static function retrieve($id, $opts = null) * Updates the specified price by setting the values of the parameters passed. Any * parameters not provided are left unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Product.php b/lib/Product.php index 14fb91a69..0b2d8fc79 100644 --- a/lib/Product.php +++ b/lib/Product.php @@ -48,13 +48,18 @@ class Product extends ApiResource /** * Creates a new product object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -67,12 +72,17 @@ public static function create($params = null, $options = null) * associated with it. Additionally, deleting a product with type=good * is only possible if it has no SKUs associated with it. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -84,12 +94,18 @@ public function delete($params = null, $opts = null) * Returns a list of your products. The products are returned sorted by creation * date, with the most recently created products appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/products', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -97,8 +113,12 @@ public static function all($params = null, $opts = null) * either a product creation request or the product list, and Stripe will return * the corresponding product information. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -113,14 +133,19 @@ public static function retrieve($id, $opts = null) * Updates the specific product by setting the values of the parameters passed. Any * parameters not provided will be left unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/PromotionCode.php b/lib/PromotionCode.php index a6c8564d7..48a22b213 100644 --- a/lib/PromotionCode.php +++ b/lib/PromotionCode.php @@ -32,13 +32,18 @@ class PromotionCode extends ApiResource * A promotion code points to a coupon. You can optionally restrict the code to a * specific customer, redemption limit, and expiration date. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -49,12 +54,18 @@ public static function create($params = null, $options = null) /** * Returns a list of your promotion codes. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/promotion_codes', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -63,8 +74,12 @@ public static function all($params = null, $opts = null) * href="/docs/api/promotion_codes/list">list with the desired * code. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -79,14 +94,19 @@ public static function retrieve($id, $opts = null) * Updates the specified promotion code by setting the values of the parameters * passed. Most fields are, by design, not editable. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Quote.php b/lib/Quote.php index 0ce3f4312..3a4eb41fe 100644 --- a/lib/Quote.php +++ b/lib/Quote.php @@ -64,13 +64,18 @@ class Quote extends ApiResource * expires_at can be set in the dashboard via the quote template. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -81,19 +86,29 @@ public static function create($params = null, $options = null) /** * Returns a list of your quotes. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/quotes', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the quote with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -107,14 +122,19 @@ public static function retrieve($id, $opts = null) /** * A quote models prices and services for a customer. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Radar/EarlyFraudWarning.php b/lib/Radar/EarlyFraudWarning.php index 0043453a2..a48ae1a5d 100644 --- a/lib/Radar/EarlyFraudWarning.php +++ b/lib/Radar/EarlyFraudWarning.php @@ -34,12 +34,18 @@ class EarlyFraudWarning extends \Stripe\ApiResource /** * Returns a list of early fraud warnings. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/radar/early_fraud_warnings', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -49,8 +55,12 @@ public static function all($params = null, $opts = null) * Please refer to the early fraud * warning object reference for more details. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Radar/ValueList.php b/lib/Radar/ValueList.php index c8b84eb4e..14afacd3b 100644 --- a/lib/Radar/ValueList.php +++ b/lib/Radar/ValueList.php @@ -41,13 +41,18 @@ class ValueList extends \Stripe\ApiResource * Creates a new ValueList object, which can then be referenced in * rules. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -60,12 +65,17 @@ public static function create($params = null, $options = null) * within the value list. To be deleted, a value list must not be referenced in any * rules. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -78,19 +88,29 @@ public function delete($params = null, $opts = null) * descending order by creation date, with the most recently created object * appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/radar/value_lists', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a ValueList object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -106,14 +126,19 @@ public static function retrieve($id, $opts = null) * passed. Any parameters not provided will be left unchanged. Note that * item_type is immutable. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Radar/ValueListItem.php b/lib/Radar/ValueListItem.php index 33f55b2df..a40b9da88 100644 --- a/lib/Radar/ValueListItem.php +++ b/lib/Radar/ValueListItem.php @@ -25,13 +25,18 @@ class ValueListItem extends \Stripe\ApiResource * Creates a new ValueListItem object, which is added to the specified * parent value list. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -43,12 +48,17 @@ public static function create($params = null, $options = null) * Deletes a ValueListItem object, removing it from its parent value * list. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -61,19 +71,29 @@ public function delete($params = null, $opts = null) * descending order by creation date, with the most recently created object * appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/radar/value_list_items', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a ValueListItem object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Refund.php b/lib/Refund.php index ce3a3e710..039d3b602 100644 --- a/lib/Refund.php +++ b/lib/Refund.php @@ -68,13 +68,18 @@ class Refund extends ApiResource * an error when called on an already-refunded charge, or when trying to refund * more money than is left on a charge. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -87,19 +92,29 @@ public static function create($params = null, $options = null) * order, with the most recent refunds appearing first The 10 most recent refunds * are always available by default on the Charge object. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/refunds', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of an existing refund. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -116,14 +131,19 @@ public static function retrieve($id, $opts = null) * * This request only accepts metadata as an argument. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Reporting/ReportRun.php b/lib/Reporting/ReportRun.php index 7eaf485c2..f543f657c 100644 --- a/lib/Reporting/ReportRun.php +++ b/lib/Reporting/ReportRun.php @@ -33,13 +33,18 @@ class ReportRun extends \Stripe\ApiResource * Creates a new object and begin running the report. (Certain report types require * a live-mode API key.). * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -50,19 +55,29 @@ public static function create($params = null, $options = null) /** * Returns a list of Report Runs, with the most recent appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/reporting/report_runs', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of an existing Report Run. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Reporting/ReportType.php b/lib/Reporting/ReportType.php index 41aceb76c..0fdeb5363 100644 --- a/lib/Reporting/ReportType.php +++ b/lib/Reporting/ReportType.php @@ -31,20 +31,30 @@ class ReportType extends \Stripe\ApiResource /** * Returns a full list of Report Types. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/reporting/report_types', \Stripe\Collection::class, $params, $opts); + $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 mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Review.php b/lib/Review.php index 108ddc439..cfb2395b0 100644 --- a/lib/Review.php +++ b/lib/Review.php @@ -43,19 +43,29 @@ class Review extends ApiResource * true. The objects are sorted in descending order by creation date, * with the most recently created object appearing first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/reviews', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a Review object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/SetupAttempt.php b/lib/SetupAttempt.php index 9cb53353d..e766c9b20 100644 --- a/lib/SetupAttempt.php +++ b/lib/SetupAttempt.php @@ -33,11 +33,17 @@ class SetupAttempt extends ApiResource /** * Returns a list of SetupAttempts that associate with a provided SetupIntent. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/setup_attempts', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } } diff --git a/lib/SetupIntent.php b/lib/SetupIntent.php index c6399fec9..c81569d14 100644 --- a/lib/SetupIntent.php +++ b/lib/SetupIntent.php @@ -77,13 +77,18 @@ class SetupIntent extends ApiResource * href="/docs/api/setup_intents/confirm">confirm it to collect any required * permissions to charge the payment method later. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -94,12 +99,18 @@ public static function create($params = null, $options = null) /** * Returns a list of SetupIntents. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/setup_intents', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -112,8 +123,12 @@ public static function all($params = null, $opts = null) * returned. Please refer to the SetupIntent * object reference for more details. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -127,14 +142,19 @@ public static function retrieve($id, $opts = null) /** * Updates a SetupIntent object. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/ShippingRate.php b/lib/ShippingRate.php index b4dd9f4f8..c35964426 100644 --- a/lib/ShippingRate.php +++ b/lib/ShippingRate.php @@ -36,13 +36,18 @@ class ShippingRate extends ApiResource /** * Creates a new shipping rate object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -53,19 +58,29 @@ public static function create($params = null, $options = null) /** * Returns a list of your shipping rates. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/shipping_rates', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Returns the shipping rate object with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -79,14 +94,19 @@ public static function retrieve($id, $opts = null) /** * Updates an existing shipping rate object. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Sigma/ScheduledQueryRun.php b/lib/Sigma/ScheduledQueryRun.php index de07f7a1f..5efd1cd81 100644 --- a/lib/Sigma/ScheduledQueryRun.php +++ b/lib/Sigma/ScheduledQueryRun.php @@ -29,19 +29,29 @@ class ScheduledQueryRun extends \Stripe\ApiResource /** * Returns a list of scheduled query runs. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/sigma/scheduled_query_runs', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of an scheduled query run. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Source.php b/lib/Source.php index 6f1da35fc..ec2d31a97 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -98,13 +98,18 @@ class Source extends ApiResource /** * Creates a new source object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -117,8 +122,12 @@ public static function create($params = null, $options = null) * creation request and Stripe will return the corresponding up-to-date source * object information. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -138,14 +147,19 @@ public static function retrieve($id, $opts = null) * payment methods. Please refer to our payment method * guides for more detail. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Subscription.php b/lib/Subscription.php index ba4650861..75a3e7cfc 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -89,13 +89,18 @@ class Subscription extends ApiResource * schedules instead. Schedules provide the flexibility to model more complex * billing configurations that change over time. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -107,19 +112,29 @@ public static function create($params = null, $options = null) * By default, returns a list of subscriptions that have not been canceled. In * order to list canceled subscriptions, specify status=canceled. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/subscriptions', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the subscription with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -178,14 +193,19 @@ public static function retrieve($id, $opts = null) * changing quantity, consider integrating usage-based billing instead. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/SubscriptionItem.php b/lib/SubscriptionItem.php index ec7ea5baa..fe74493c9 100644 --- a/lib/SubscriptionItem.php +++ b/lib/SubscriptionItem.php @@ -31,13 +31,18 @@ class SubscriptionItem extends ApiResource * Adds a new item to an existing subscription. No existing items will be changed * or replaced. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -49,12 +54,17 @@ public static function create($params = null, $options = null) * Deletes an item from the subscription. Removing a subscription item from a * subscription will not cancel the subscription. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -65,19 +75,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of your subscription items for a given subscription. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/subscription_items', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the subscription item with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -91,14 +111,19 @@ public static function retrieve($id, $opts = null) /** * Updates the plan or quantity of an item on a current subscription. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/SubscriptionSchedule.php b/lib/SubscriptionSchedule.php index 826af53f4..24220e580 100644 --- a/lib/SubscriptionSchedule.php +++ b/lib/SubscriptionSchedule.php @@ -49,13 +49,18 @@ class SubscriptionSchedule extends ApiResource * Creates a new subscription schedule object. Each customer can have up to 500 * active or scheduled subscriptions. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -66,12 +71,18 @@ public static function create($params = null, $options = null) /** * Retrieves the list of your subscription schedules. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/subscription_schedules', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -79,8 +90,12 @@ public static function all($params = null, $opts = null) * supply the unique subscription schedule identifier that was returned upon * subscription schedule creation. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -94,14 +109,19 @@ public static function retrieve($id, $opts = null) /** * Updates an existing subscription schedule. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Tax/Calculation.php b/lib/Tax/Calculation.php index f9ab7b093..f70b46593 100644 --- a/lib/Tax/Calculation.php +++ b/lib/Tax/Calculation.php @@ -32,13 +32,18 @@ class Calculation extends \Stripe\ApiResource /** * Calculates tax based on input and returns a Tax Calculation object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); diff --git a/lib/Tax/Registration.php b/lib/Tax/Registration.php index 9f658db64..2126e1e99 100644 --- a/lib/Tax/Registration.php +++ b/lib/Tax/Registration.php @@ -34,13 +34,18 @@ class Registration extends \Stripe\ApiResource /** * Creates a new Tax Registration object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -51,19 +56,29 @@ public static function create($params = null, $options = null) /** * Returns a list of Tax Registration objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/tax/registrations', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Returns a Tax Registration object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -80,14 +95,19 @@ public static function retrieve($id, $opts = null) * 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 mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Tax/Settings.php b/lib/Tax/Settings.php index ebdfeeec7..6da6e3d66 100644 --- a/lib/Tax/Settings.php +++ b/lib/Tax/Settings.php @@ -26,7 +26,11 @@ class Settings extends \Stripe\SingletonApiResource /** * Retrieves Tax Settings for a merchant. * - * @param null|mixed $opts + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Settings */ public static function retrieve($opts = null) { diff --git a/lib/Tax/Transaction.php b/lib/Tax/Transaction.php index 6d51f8997..7a6343a2b 100644 --- a/lib/Tax/Transaction.php +++ b/lib/Tax/Transaction.php @@ -35,8 +35,12 @@ class Transaction extends \Stripe\ApiResource /** * Retrieves a Tax Transaction object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/TaxCode.php b/lib/TaxCode.php index 6fe774f80..f57caaada 100644 --- a/lib/TaxCode.php +++ b/lib/TaxCode.php @@ -20,20 +20,30 @@ class TaxCode extends ApiResource * A list of all tax codes * available to add to Products in order to allow specific tax calculations. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/tax_codes', \Stripe\Collection::class, $params, $opts); + $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 mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/TaxId.php b/lib/TaxId.php index 307a86322..28fa8569b 100644 --- a/lib/TaxId.php +++ b/lib/TaxId.php @@ -101,13 +101,18 @@ class TaxId extends ApiResource /** * Creates a new account or customer tax_id object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -118,12 +123,17 @@ public static function create($params = null, $options = null) /** * Deletes an existing account or customer tax_id object. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -134,19 +144,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of tax IDs. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/tax_ids', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves an account or customer tax_id object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/TaxRate.php b/lib/TaxRate.php index 016b8a934..976a6e0c6 100644 --- a/lib/TaxRate.php +++ b/lib/TaxRate.php @@ -55,13 +55,18 @@ class TaxRate extends ApiResource /** * Creates a new tax rate. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -73,19 +78,29 @@ public static function create($params = null, $options = null) * 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|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/tax_rates', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a tax rate with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -99,14 +114,19 @@ public static function retrieve($id, $opts = null) /** * Updates an existing tax rate. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Terminal/Configuration.php b/lib/Terminal/Configuration.php index 8f8d2465b..7a0e411b1 100644 --- a/lib/Terminal/Configuration.php +++ b/lib/Terminal/Configuration.php @@ -27,13 +27,18 @@ class Configuration extends \Stripe\ApiResource /** * Creates a new Configuration object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -44,12 +49,17 @@ public static function create($params = null, $options = null) /** * Deletes a Configuration object. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -60,19 +70,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of Configuration objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/terminal/configurations', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a Configuration object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -86,14 +106,19 @@ public static function retrieve($id, $opts = null) /** * Updates a new Configuration object. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Terminal/ConnectionToken.php b/lib/Terminal/ConnectionToken.php index 80758e5ab..dd8ce032a 100644 --- a/lib/Terminal/ConnectionToken.php +++ b/lib/Terminal/ConnectionToken.php @@ -22,13 +22,18 @@ class ConnectionToken extends \Stripe\ApiResource * connection token from Stripe, proxied through your server. On your backend, add * an endpoint that creates and returns a connection token. * - * @param null|mixed $params - * @param null|mixed $options + * @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); diff --git a/lib/Terminal/Location.php b/lib/Terminal/Location.php index 7836f578b..11a6f0f0e 100644 --- a/lib/Terminal/Location.php +++ b/lib/Terminal/Location.php @@ -28,13 +28,18 @@ class Location extends \Stripe\ApiResource * address fields are required in each country, see the Manage locations guide. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -45,12 +50,17 @@ public static function create($params = null, $options = null) /** * Deletes a Location object. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -61,19 +71,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of Location objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/terminal/locations', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a Location object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -88,14 +108,19 @@ public static function retrieve($id, $opts = null) * Updates a Location object by setting the values of the parameters * passed. Any parameters not provided will be left unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Terminal/Reader.php b/lib/Terminal/Reader.php index 746e0be32..af2478f18 100644 --- a/lib/Terminal/Reader.php +++ b/lib/Terminal/Reader.php @@ -42,13 +42,18 @@ class Reader extends \Stripe\ApiResource /** * Creates a new Reader object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -59,12 +64,17 @@ public static function create($params = null, $options = null) /** * Deletes a Reader object. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -75,19 +85,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of Reader objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/terminal/readers', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a Reader object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -102,14 +122,19 @@ public static function retrieve($id, $opts = null) * Updates a Reader object by setting the values of the parameters * passed. Any parameters not provided will be left unchanged. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/TestHelpers/TestClock.php b/lib/TestHelpers/TestClock.php index 39de3270f..8a8cf2644 100644 --- a/lib/TestHelpers/TestClock.php +++ b/lib/TestHelpers/TestClock.php @@ -29,13 +29,18 @@ class TestClock extends \Stripe\ApiResource /** * Creates a new test clock that can be attached to new customers and quotes. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -46,12 +51,17 @@ public static function create($params = null, $options = null) /** * Deletes a test clock. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -62,19 +72,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of your test clocks. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/test_helpers/test_clocks', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a test clock. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Token.php b/lib/Token.php index 892292201..a4e6516da 100644 --- a/lib/Token.php +++ b/lib/Token.php @@ -53,13 +53,18 @@ class Token extends ApiResource * href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection * is application, which includes Custom accounts. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -70,8 +75,12 @@ public static function create($params = null, $options = null) /** * Retrieves the token with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Topup.php b/lib/Topup.php index 566ba2560..2954a7d1e 100644 --- a/lib/Topup.php +++ b/lib/Topup.php @@ -43,13 +43,18 @@ class Topup extends ApiResource /** * Top up the balance of an account. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -60,12 +65,18 @@ public static function create($params = null, $options = null) /** * Returns a list of top-ups. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/topups', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -73,8 +84,12 @@ public static function all($params = null, $opts = null) * unique top-up ID that was returned from your previous request, and Stripe will * return the corresponding top-up information. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -89,14 +104,19 @@ public static function retrieve($id, $opts = null) * Updates the metadata of a top-up. Other top-up details are not editable by * design. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Transfer.php b/lib/Transfer.php index a75052208..d0b766db8 100644 --- a/lib/Transfer.php +++ b/lib/Transfer.php @@ -50,13 +50,18 @@ class Transfer extends ApiResource * transfer object. Your Stripe balance must be able to * cover the transfer amount, or you’ll receive an “Insufficient Funds” error. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -69,12 +74,18 @@ public static function create($params = null, $options = null) * are returned in sorted order, with the most recently created transfers appearing * first. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/transfers', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -82,8 +93,12 @@ public static function all($params = null, $opts = null) * from either a transfer creation request or the transfer list, and Stripe will * return the corresponding transfer information. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -100,14 +115,19 @@ public static function retrieve($id, $opts = null) * * This request accepts only metadata as an argument. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Treasury/CreditReversal.php b/lib/Treasury/CreditReversal.php index 2dcf7062b..c0df14485 100644 --- a/lib/Treasury/CreditReversal.php +++ b/lib/Treasury/CreditReversal.php @@ -36,13 +36,18 @@ class CreditReversal extends \Stripe\ApiResource /** * Reverses a ReceivedCredit and creates a CreditReversal object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -53,12 +58,18 @@ public static function create($params = null, $options = null) /** * Returns a list of CreditReversals. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/credit_reversals', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -66,8 +77,12 @@ public static function all($params = null, $opts = null) * CreditReversal ID from either the CreditReversal creation request or * CreditReversal list. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Treasury/DebitReversal.php b/lib/Treasury/DebitReversal.php index a6b3818c9..4b83967c9 100644 --- a/lib/Treasury/DebitReversal.php +++ b/lib/Treasury/DebitReversal.php @@ -37,13 +37,18 @@ class DebitReversal extends \Stripe\ApiResource /** * Reverses a ReceivedDebit and creates a DebitReversal object. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -54,19 +59,29 @@ public static function create($params = null, $options = null) /** * Returns a list of DebitReversals. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/debit_reversals', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a DebitReversal object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Treasury/FinancialAccount.php b/lib/Treasury/FinancialAccount.php index efdc5fac6..f72f533ea 100644 --- a/lib/Treasury/FinancialAccount.php +++ b/lib/Treasury/FinancialAccount.php @@ -38,13 +38,18 @@ class FinancialAccount extends \Stripe\ApiResource * Creates a new FinancialAccount. For now, each connected account can only have * one FinancialAccount. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -55,19 +60,29 @@ public static function create($params = null, $options = null) /** * Returns a list of FinancialAccounts. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/financial_accounts', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of a FinancialAccount. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -81,14 +96,19 @@ public static function retrieve($id, $opts = null) /** * Updates the details of a FinancialAccount. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); diff --git a/lib/Treasury/InboundTransfer.php b/lib/Treasury/InboundTransfer.php index 03398d2b5..beb1dc19d 100644 --- a/lib/Treasury/InboundTransfer.php +++ b/lib/Treasury/InboundTransfer.php @@ -40,13 +40,18 @@ class InboundTransfer extends \Stripe\ApiResource /** * Creates an InboundTransfer. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -57,19 +62,29 @@ public static function create($params = null, $options = null) /** * Returns a list of InboundTransfers sent from the specified FinancialAccount. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/inbound_transfers', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of an existing InboundTransfer. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Treasury/OutboundPayment.php b/lib/Treasury/OutboundPayment.php index 395235f87..808c5d473 100644 --- a/lib/Treasury/OutboundPayment.php +++ b/lib/Treasury/OutboundPayment.php @@ -45,13 +45,18 @@ class OutboundPayment extends \Stripe\ApiResource /** * Creates an OutboundPayment. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -62,12 +67,18 @@ public static function create($params = null, $options = null) /** * Returns a list of OutboundPayments sent from the specified FinancialAccount. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/outbound_payments', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -75,8 +86,12 @@ public static function all($params = null, $opts = null) * OutboundPayment ID from either the OutboundPayment creation request or * OutboundPayment list. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Treasury/OutboundTransfer.php b/lib/Treasury/OutboundTransfer.php index c9930acd1..ff50403f1 100644 --- a/lib/Treasury/OutboundTransfer.php +++ b/lib/Treasury/OutboundTransfer.php @@ -43,13 +43,18 @@ class OutboundTransfer extends \Stripe\ApiResource /** * Creates an OutboundTransfer. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -60,12 +65,18 @@ public static function create($params = null, $options = null) /** * Returns a list of OutboundTransfers sent from the specified FinancialAccount. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/outbound_transfers', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** @@ -73,8 +84,12 @@ public static function all($params = null, $opts = null) * OutboundTransfer ID from either the OutboundTransfer creation request or * OutboundTransfer list. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Treasury/ReceivedCredit.php b/lib/Treasury/ReceivedCredit.php index 5f0757374..5694e4365 100644 --- a/lib/Treasury/ReceivedCredit.php +++ b/lib/Treasury/ReceivedCredit.php @@ -43,20 +43,30 @@ class ReceivedCredit extends \Stripe\ApiResource /** * Returns a list of ReceivedCredits. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/received_credits', \Stripe\Collection::class, $params, $opts); + $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 mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Treasury/ReceivedDebit.php b/lib/Treasury/ReceivedDebit.php index 393ddf089..230a25dd0 100644 --- a/lib/Treasury/ReceivedDebit.php +++ b/lib/Treasury/ReceivedDebit.php @@ -43,20 +43,30 @@ class ReceivedDebit extends \Stripe\ApiResource /** * Returns a list of ReceivedDebits. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/received_debits', \Stripe\Collection::class, $params, $opts); + $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 mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Treasury/Transaction.php b/lib/Treasury/Transaction.php index 8c1c080ff..b694d68a4 100644 --- a/lib/Treasury/Transaction.php +++ b/lib/Treasury/Transaction.php @@ -44,19 +44,29 @@ class Transaction extends \Stripe\ApiResource /** * Retrieves a list of Transaction objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/transactions', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the details of an existing Transaction. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/Treasury/TransactionEntry.php b/lib/Treasury/TransactionEntry.php index 79ebd445e..fcef7effa 100644 --- a/lib/Treasury/TransactionEntry.php +++ b/lib/Treasury/TransactionEntry.php @@ -59,19 +59,29 @@ class TransactionEntry extends \Stripe\ApiResource /** * Retrieves a list of TransactionEntry objects. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/treasury/transaction_entries', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves a TransactionEntry object. * - * @param mixed $id - * @param null|mixed $opts + * @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) { diff --git a/lib/WebhookEndpoint.php b/lib/WebhookEndpoint.php index cc1983c5d..0d500f292 100644 --- a/lib/WebhookEndpoint.php +++ b/lib/WebhookEndpoint.php @@ -43,13 +43,18 @@ class WebhookEndpoint extends ApiResource * href="https://dashboard.stripe.com/account/webhooks">webhooks settings * section of the Dashboard. * - * @param null|mixed $params - * @param null|mixed $options + * @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); @@ -62,12 +67,17 @@ public static function create($params = null, $options = null) * href="https://dashboard.stripe.com/account/webhooks">webhook endpoint * management page of the Stripe dashboard. * - * @param null|mixed $params - * @param null|mixed $opts + * @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); @@ -78,19 +88,29 @@ public function delete($params = null, $opts = null) /** * Returns a list of your webhook endpoints. * - * @param null|mixed $params - * @param null|mixed $opts + * @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) { - return static::_requestPage('/v1/webhook_endpoints', \Stripe\Collection::class, $params, $opts); + $url = static::classUrl(); + + return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the webhook endpoint with the given ID. * - * @param mixed $id - * @param null|mixed $opts + * @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) { @@ -105,14 +125,19 @@ public static function retrieve($id, $opts = null) * Updates the webhook endpoint. You may edit the url, the list of * enabled_events, and the status of your endpoint. * - * @param mixed $id - * @param null|mixed $params - * @param null|mixed $opts + * @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); From bb8f2b1ec3bfbda8ea589e6a9b90ba954c0b24f8 Mon Sep 17 00:00:00 2001 From: Prathmesh Ranaut Date: Thu, 30 May 2024 15:35:30 -0400 Subject: [PATCH 3/3] Updated override to fix indents --- lib/BankAccount.php | 8 ++++---- lib/Card.php | 8 ++++---- lib/Person.php | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/BankAccount.php b/lib/BankAccount.php index cbb6e7543..9654c7656 100644 --- a/lib/BankAccount.php +++ b/lib/BankAccount.php @@ -122,10 +122,10 @@ public static function retrieve($_id, $_opts = null) public static function update($_id, $_params = null, $_options = null) { $msg = 'Bank accounts cannot be updated without a customer ID or an ' . - 'account ID. Update a bank account using ' . - "`Customer::updateSource('customer_id', 'bank_account_id', " . - '$updateParams)` or `Account::updateExternalAccount(' . - "'account_id', 'bank_account_id', \$updateParams)`."; + 'account ID. Update a bank account using ' . + "`Customer::updateSource('customer_id', 'bank_account_id', " . + '$updateParams)` or `Account::updateExternalAccount(' . + "'account_id', 'bank_account_id', \$updateParams)`."; throw new Exception\BadMethodCallException($msg); } diff --git a/lib/Card.php b/lib/Card.php index f231507c6..b8a6b344a 100644 --- a/lib/Card.php +++ b/lib/Card.php @@ -146,10 +146,10 @@ public static function retrieve($_id, $_opts = null) public static function update($_id, $_params = null, $_options = null) { $msg = 'Cards cannot be updated without a customer ID or an ' . - 'account ID. Update a card using ' . - "`Customer::updateSource('customer_id', 'card_id', " . - '$updateParams)` or `Account::updateExternalAccount(' . - "'account_id', 'card_id', \$updateParams)`."; + 'account ID. Update a card using ' . + "`Customer::updateSource('customer_id', 'card_id', " . + '$updateParams)` or `Account::updateExternalAccount(' . + "'account_id', 'card_id', \$updateParams)`."; throw new Exception\BadMethodCallException($msg); } diff --git a/lib/Person.php b/lib/Person.php index d2bc5cafe..cd79aebf4 100644 --- a/lib/Person.php +++ b/lib/Person.php @@ -108,8 +108,8 @@ 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); }