From 2a5d4783ea53a98f88dcc9c14fd22e9e98c6f601 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 4 Jan 2018 11:45:34 +0100 Subject: [PATCH] Use traits for API operations methods --- init.php | 8 ++++ lib/Account.php | 60 +++------------------------- lib/ApiOperations/All.php | 22 ++++++++++ lib/ApiOperations/Create.php | 22 ++++++++++ lib/ApiOperations/Delete.php | 22 ++++++++++ lib/ApiOperations/Retrieve.php | 24 +++++++++++ lib/ApiOperations/Update.php | 34 ++++++++++++++++ lib/ApplePayDomain.php | 51 +++--------------------- lib/ApplicationFee.php | 26 ++---------- lib/BalanceTransaction.php | 26 ++---------- lib/BitcoinReceiver.php | 44 ++------------------ lib/Charge.php | 59 ++------------------------- lib/CountrySpec.php | 27 ++----------- lib/Coupon.php | 71 +++------------------------------ lib/Customer.php | 73 +++------------------------------- lib/Dispute.php | 47 ++-------------------- lib/EphemeralKey.php | 13 +----- lib/Event.php | 24 +---------- lib/ExchangeRate.php | 25 ++---------- lib/ExternalAccount.php | 13 +----- lib/FileUpload.php | 38 ++---------------- lib/Invoice.php | 49 ++--------------------- lib/InvoiceItem.php | 71 +++------------------------------ lib/Order.php | 59 ++------------------------- lib/OrderReturn.php | 26 ++---------- lib/Payout.php | 59 ++------------------------- lib/Plan.php | 71 +++------------------------------ lib/Product.php | 71 +++------------------------------ lib/Recipient.php | 71 +++------------------------------ lib/Refund.php | 60 ++-------------------------- lib/SKU.php | 71 +++------------------------------ lib/Source.php | 47 ++-------------------- lib/Subscription.php | 61 +++------------------------- lib/SubscriptionItem.php | 73 +++------------------------------- lib/ThreeDSecure.php | 26 ++---------- lib/Token.php | 24 +---------- lib/Transfer.php | 61 +++------------------------- 37 files changed, 254 insertions(+), 1375 deletions(-) create mode 100644 lib/ApiOperations/All.php create mode 100644 lib/ApiOperations/Create.php create mode 100644 lib/ApiOperations/Delete.php create mode 100644 lib/ApiOperations/Retrieve.php create mode 100644 lib/ApiOperations/Update.php diff --git a/init.php b/init.php index e9eb3baf54..a3f42e7c40 100644 --- a/init.php +++ b/init.php @@ -35,6 +35,14 @@ require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedGrantType.php'); require(dirname(__FILE__) . '/lib/Error/OAuth/UnsupportedResponseType.php'); +// API operations +echo "bouh"; +require(dirname(__FILE__) . '/lib/ApiOperations/All.php'); +require(dirname(__FILE__) . '/lib/ApiOperations/Create.php'); +require(dirname(__FILE__) . '/lib/ApiOperations/Delete.php'); +require(dirname(__FILE__) . '/lib/ApiOperations/Retrieve.php'); +require(dirname(__FILE__) . '/lib/ApiOperations/Update.php'); + // Plumbing require(dirname(__FILE__) . '/lib/ApiResponse.php'); require(dirname(__FILE__) . '/lib/StripeObject.php'); diff --git a/lib/Account.php b/lib/Account.php index d21f6e3b3a..ac5b36ffb3 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -37,6 +37,11 @@ */ class Account extends ApiResource { + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Update; + const PATH_EXTERNAL_ACCOUNTS = '/external_accounts'; const PATH_LOGIN_LINKS = '/login_links'; @@ -65,50 +70,6 @@ public static function retrieve($id = null, $opts = null) return self::_retrieve($id, $opts); } - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Account - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the account to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Account The updated account. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return Account - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Account The deleted account. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } - /** * @param array|null $params * @param array|string|null $opts @@ -123,17 +84,6 @@ public function reject($params = null, $opts = null) return $this; } - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Accounts - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - /** * @param array|null $clientId * @param array|string|null $opts diff --git a/lib/ApiOperations/All.php b/lib/ApiOperations/All.php new file mode 100644 index 0000000000..961d1ad31e --- /dev/null +++ b/lib/ApiOperations/All.php @@ -0,0 +1,22 @@ +_delete($params, $opts); + } +} diff --git a/lib/ApiOperations/Retrieve.php b/lib/ApiOperations/Retrieve.php new file mode 100644 index 0000000000..54798cff22 --- /dev/null +++ b/lib/ApiOperations/Retrieve.php @@ -0,0 +1,24 @@ +_save($options); + } +} diff --git a/lib/ApplePayDomain.php b/lib/ApplePayDomain.php index 99beb703e6..124c5dc063 100644 --- a/lib/ApplePayDomain.php +++ b/lib/ApplePayDomain.php @@ -9,7 +9,11 @@ */ class ApplePayDomain extends ApiResource { - + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + /** * @return string The class URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. @@ -18,49 +22,4 @@ public static function classUrl() { return '/v1/apple_pay/domains'; } - - /** - * @param array|string $id The ID of the domain to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return ApplePayDomain - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return ApplePayDomain The created domain. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return ApplePayDomain The deleted domain. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of ApplePayDomains - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } } diff --git a/lib/ApplicationFee.php b/lib/ApplicationFee.php index c6f86e36ff..2dadab5bf1 100644 --- a/lib/ApplicationFee.php +++ b/lib/ApplicationFee.php @@ -9,6 +9,9 @@ */ class ApplicationFee extends ApiResource { + use ApiOperations\All; + use ApiOperations\Retrieve; + const PATH_REFUNDS = '/refunds'; /** @@ -22,29 +25,6 @@ public static function className() return 'application_fee'; } - /** - * @param array|string $id The ID of the application fee to retrieve, or an - * options array containing an `id` key. - * @param array|string|null $opts - * - * @return ApplicationFee - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of ApplicationFees - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - /** * @param array|null $params * @param array|string|null $opts diff --git a/lib/BalanceTransaction.php b/lib/BalanceTransaction.php index 4799b69bd4..f174ae5211 100644 --- a/lib/BalanceTransaction.php +++ b/lib/BalanceTransaction.php @@ -24,6 +24,9 @@ */ class BalanceTransaction extends ApiResource { + use ApiOperations\All; + use ApiOperations\Retrieve; + /** * @return string The class URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. @@ -32,27 +35,4 @@ public static function classUrl() { return "/v1/balance/history"; } - - /** - * @param array|string $id The ID of the balance transaction to retrieve, - * or an options array containing an `id` key. - * @param array|string|null $opts - * - * @return BalanceTransaction - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of BalanceTransactions - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } } diff --git a/lib/BitcoinReceiver.php b/lib/BitcoinReceiver.php index 52bbed128d..db7dfc5f06 100644 --- a/lib/BitcoinReceiver.php +++ b/lib/BitcoinReceiver.php @@ -9,6 +9,10 @@ */ class BitcoinReceiver extends ExternalAccount { + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + /** * @return string The class URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. @@ -40,46 +44,6 @@ public function instanceUrl() } } - /** - * @param array|string $id The ID of the bitcoin receiver to retrieve, or - * an options array containing an `id` key. - * @param array|string|null $opts - * - * @return BitcoinReceiver - * - * @deprecated Please use sources instead. - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of BitcoinReceivers - * - * @deprecated Please use sources instead. - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return BitcoinReceiver The created Bitcoin Receiver item. - * - * @deprecated Please use sources instead. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - /** * @param array|null $params * @param array|string|null $options diff --git a/lib/Charge.php b/lib/Charge.php index b81057f7d4..c37f8a20ab 100644 --- a/lib/Charge.php +++ b/lib/Charge.php @@ -40,61 +40,10 @@ */ class Charge extends ApiResource { - /** - * @param array|string $id The ID of the charge to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $options - * - * @return Charge - */ - public static function retrieve($id, $options = null) - { - return self::_retrieve($id, $options); - } - - /** - * @param array|null $params - * @param array|string|null $options - * - * @return Collection of Charges - */ - public static function all($params = null, $options = null) - { - return self::_all($params, $options); - } - - /** - * @param array|null $params - * @param array|string|null $options - * - * @return Charge The created charge. - */ - public static function create($params = null, $options = null) - { - return self::_create($params, $options); - } - - /** - * @param string $id The ID of the charge to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Charge The updated charge. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $options - * - * @return Charge The saved charge. - */ - public function save($options = null) - { - return $this->_save($options); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + use ApiOperations\Update; /** * @param array|null $params diff --git a/lib/CountrySpec.php b/lib/CountrySpec.php index 81bf54b90f..1733c575ef 100644 --- a/lib/CountrySpec.php +++ b/lib/CountrySpec.php @@ -9,6 +9,9 @@ */ class CountrySpec extends ApiResource { + use ApiOperations\All; + use ApiOperations\Retrieve; + /** * This is a special case because the country specs endpoint has an * underscore in it. The parent `className` function strips underscores. @@ -19,28 +22,4 @@ public static function className() { return 'country_spec'; } - - /** - * @param array|string $country The ISO country code of the country we - * retrieve the country specfication for, or an options array - * containing an `id` containing that code. - * @param array|string|null $opts - * - * @return CountrySpec - */ - public static function retrieve($country, $opts = null) - { - return self::_retrieve($country, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of CountrySpecs - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } } diff --git a/lib/Coupon.php b/lib/Coupon.php index 803d7c81e5..4ff8d598d1 100644 --- a/lib/Coupon.php +++ b/lib/Coupon.php @@ -9,70 +9,9 @@ */ class Coupon extends ApiResource { - /** - * @param array|string $id The ID of the coupon to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return Coupon - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Coupon The created coupon. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the coupon to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Coupon The updated coupon. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Coupon The deleted coupon. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } - - /** - * @param array|string|null $opts - * - * @return Coupon The saved coupon. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Coupons - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + use ApiOperations\Update; } diff --git a/lib/Customer.php b/lib/Customer.php index 5abeabd8d8..eef7eecbcd 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -26,74 +26,13 @@ */ class Customer extends ApiResource { - const PATH_SOURCES = '/sources'; - - /** - * @param array|string $id The ID of the customer to retrieve, or an - * options array containing an `id` key. - * @param array|string|null $opts - * - * @return Customer - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Customers - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Customer The created customer. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + use ApiOperations\Update; - /** - * @param string $id The ID of the customer to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Customer The updated customer. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return Customer The saved customer. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Customer The deleted customer. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } + const PATH_SOURCES = '/sources'; /** * @param array|null $params diff --git a/lib/Dispute.php b/lib/Dispute.php index 3b7c883522..5f08fcc120 100644 --- a/lib/Dispute.php +++ b/lib/Dispute.php @@ -24,50 +24,9 @@ */ class Dispute extends ApiResource { - /** - * @param array|string $id The ID of the dispute to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $options - * - * @return Dispute - */ - public static function retrieve($id, $options = null) - { - return self::_retrieve($id, $options); - } - - /** - * @param array|null $params - * @param array|string|null $options - * - * @return array An array of Disputes. - */ - public static function all($params = null, $options = null) - { - return self::_all($params, $options); - } - - /** - * @param string $id The ID of the dispute to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Dispute The updated dispute. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $options - * - * @return Dispute The saved charge. - */ - public function save($options = null) - { - return $this->_save($options); - } + use ApiOperations\All; + use ApiOperations\Retrieve; + use ApiOperations\Update; /** * @param array|string|null $options diff --git a/lib/EphemeralKey.php b/lib/EphemeralKey.php index cd3afd132d..91754212f4 100644 --- a/lib/EphemeralKey.php +++ b/lib/EphemeralKey.php @@ -17,6 +17,8 @@ */ class EphemeralKey extends ApiResource { + use ApiOperations\Delete; + /** * This is a special case because the ephemeral key endpoint has an * underscore in it. The parent `className` function strips underscores. @@ -41,15 +43,4 @@ public static function create($params = null, $opts = null) } return self::_create($params, $opts); } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return EphemeralKey The deleted key. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } } diff --git a/lib/Event.php b/lib/Event.php index 06009f480f..354169fc16 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -19,26 +19,6 @@ */ class Event extends ApiResource { - /** - * @param array|string $id The ID of the event to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return Event - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Events - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Retrieve; } diff --git a/lib/ExchangeRate.php b/lib/ExchangeRate.php index a6a2b7d024..4076326183 100644 --- a/lib/ExchangeRate.php +++ b/lib/ExchangeRate.php @@ -9,6 +9,9 @@ */ class ExchangeRate extends ApiResource { + use ApiOperations\All; + use ApiOperations\Retrieve; + /** * This is a special case because the exchange rates endpoint has an * underscore in it. The parent `className` function strips underscores. @@ -19,26 +22,4 @@ public static function className() { return 'exchange_rate'; } - - /** - * @param array|string $currency - * @param array|string|null $opts - * - * @return ExchangeRate - */ - public static function retrieve($currency, $opts = null) - { - return self::_retrieve($currency, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return ExchangeRate - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } } diff --git a/lib/ExternalAccount.php b/lib/ExternalAccount.php index fba03075d8..dff99f7226 100644 --- a/lib/ExternalAccount.php +++ b/lib/ExternalAccount.php @@ -12,6 +12,8 @@ */ abstract class ExternalAccount extends ApiResource { + use ApiOperations\Delete; + /** * @return string The instance URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. @@ -50,17 +52,6 @@ public function instanceUrl() return "$base/$parentExtn/$path/$extn"; } - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return ExternalAccount The deleted external account. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } - /** * @param array|string|null $opts * diff --git a/lib/FileUpload.php b/lib/FileUpload.php index cfd6fce5ee..aa0b733959 100644 --- a/lib/FileUpload.php +++ b/lib/FileUpload.php @@ -16,6 +16,10 @@ */ class FileUpload extends ApiResource { + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + public static function baseUrl() { return Stripe::$apiUploadBase; @@ -25,38 +29,4 @@ public static function className() { return 'file'; } - - /** - * @param array|string $id The ID of the file upload to retrieve, or an - * options array containing an `id key. - * @param array|string|null $opts - * - * @return FileUpload - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return FileUpload The created file upload. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of FileUploads - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } } diff --git a/lib/Invoice.php b/lib/Invoice.php index f4161a7bbb..0aaae9e246 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -9,51 +9,10 @@ */ class Invoice extends ApiResource { - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Invoice The created invoice. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param array|string $id The ID of the invoice to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return Invoice - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Invoices - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param string $id The ID of the invoice to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Invoice The updated invoice. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + use ApiOperations\Update; /** * @param array|null $params diff --git a/lib/InvoiceItem.php b/lib/InvoiceItem.php index 22f1cc0775..3a2d701206 100644 --- a/lib/InvoiceItem.php +++ b/lib/InvoiceItem.php @@ -9,70 +9,9 @@ */ class InvoiceItem extends ApiResource { - /** - * @param array|string $id The ID of the invoice item to retrieve, or an - * options array containing an `id` key. - * @param array|string|null $opts - * - * @return InvoiceItem - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of InvoiceItems - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return InvoiceItem The created invoice item. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the invoice item to update. - * @param array|null $params - * @param array|string|null $options - * - * @return InvoiceItem The updated invoice item. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return InvoiceItem The saved invoice item. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return InvoiceItem The deleted invoice item. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + use ApiOperations\Update; } diff --git a/lib/Order.php b/lib/Order.php index 58a7ee2d38..e9c7a882ff 100644 --- a/lib/Order.php +++ b/lib/Order.php @@ -9,61 +9,10 @@ */ class Order extends ApiResource { - /** - * @param array|string $id The ID of the order to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return Order - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Order The created Order. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the order to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Order The updated order. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return Order The saved Order. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Orders - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + use ApiOperations\Update; /** * @return Order The paid order. diff --git a/lib/OrderReturn.php b/lib/OrderReturn.php index 551cb75c35..45a69e3783 100644 --- a/lib/OrderReturn.php +++ b/lib/OrderReturn.php @@ -9,6 +9,9 @@ */ class OrderReturn extends ApiResource { + use ApiOperations\All; + use ApiOperations\Retrieve; + /** * This is a special case because the order returns endpoint has an * underscore in it. The parent `className` function strips underscores. @@ -19,27 +22,4 @@ public static function className() { return 'order_return'; } - - /** - * @param array|string $id The ID of the order return to retrieve, or an - * options array containing an `id` field. - * @param array|string|null $opts - * - * @return Order - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of OrderReturns - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } } diff --git a/lib/Payout.php b/lib/Payout.php index 9a0eb18318..d591453f16 100644 --- a/lib/Payout.php +++ b/lib/Payout.php @@ -29,51 +29,10 @@ */ class Payout extends ApiResource { - /** - * @param array|string $id The ID of the payout to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return Payout - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Payouts - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Payout The created payout. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the payout to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Payout The updated payout. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + use ApiOperations\Update; /** * @return Payout The canceled payout. @@ -85,14 +44,4 @@ public function cancel() $this->refreshFrom($response, $opts); return $this; } - - /** - * @param array|string|null $opts - * - * @return Payout The saved payout. - */ - public function save($opts = null) - { - return $this->_save($opts); - } } diff --git a/lib/Plan.php b/lib/Plan.php index dcfffbf3d5..a1942ca72a 100644 --- a/lib/Plan.php +++ b/lib/Plan.php @@ -22,70 +22,9 @@ */ class Plan extends ApiResource { - /** - * @param array|string $id The ID of the plan to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return Plan - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Plan The created plan. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the plan to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Plan The updated plan. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Plan The deleted plan. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } - - /** - * @param array|string|null $opts - * - * @return Plan The saved plan. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Plans - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + use ApiOperations\Update; } diff --git a/lib/Product.php b/lib/Product.php index 1f8d2995b1..dd2b67dda1 100644 --- a/lib/Product.php +++ b/lib/Product.php @@ -9,70 +9,9 @@ */ class Product extends ApiResource { - /** - * @param array|string $id The ID of the product to retrieve, or an options - * array contianing an `id` key. - * @param array|string|null $opts - * - * @return Product - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Product The created Product. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the product to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Product The updated product. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return Product The saved Product. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Products - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Product The deleted product. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + use ApiOperations\Update; } diff --git a/lib/Recipient.php b/lib/Recipient.php index e08bd936ef..9ec6a1ec84 100644 --- a/lib/Recipient.php +++ b/lib/Recipient.php @@ -9,72 +9,11 @@ */ class Recipient extends ApiResource { - /** - * @param array|string $id The ID of the recipient to retrieve, or an - * options array containing an `id` key. - * @param array|string|null $opts - * - * @return Recipient - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Recipients - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Recipient The created recipient. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the recipient to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Recipient The updated recipient. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return Recipient The saved recipient. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * - * @return Recipient The deleted recipient. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } - + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + use ApiOperations\Update; /** * @param array|null $params diff --git a/lib/Refund.php b/lib/Refund.php index 62ce8c9256..73e02504f2 100644 --- a/lib/Refund.php +++ b/lib/Refund.php @@ -21,60 +21,8 @@ */ class Refund extends ApiResource { - - /** - * @param array|string $id The ID of the refund to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $options - * - * @return Refund - */ - public static function retrieve($id, $options = null) - { - return self::_retrieve($id, $options); - } - - /** - * @param string $id The ID of the refund to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Refund The updated refund. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|null $params - * @param array|string|null $options - * - * @return Collection of Refunds - */ - public static function all($params = null, $options = null) - { - return self::_all($params, $options); - } - - /** - * @param array|null $params - * @param array|string|null $options - * - * @return Refund The created refund. - */ - public static function create($params = null, $options = null) - { - return self::_create($params, $options); - } - - /** - * @param array|string|null $opts - * - * @return Refund The saved refund. - */ - public function save($opts = null) - { - return $this->_save($opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + use ApiOperations\Update; } diff --git a/lib/SKU.php b/lib/SKU.php index 19d27eac53..05b64afa94 100644 --- a/lib/SKU.php +++ b/lib/SKU.php @@ -9,70 +9,9 @@ */ class SKU extends ApiResource { - /** - * @param array|string $id The ID of the SKU to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return SKU - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return SKU The created SKU. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the SKU to update. - * @param array|null $params - * @param array|string|null $options - * - * @return SKU The updated SKU. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return SKU The saved SKU. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of SKUs - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return SKU The deleted sku. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + use ApiOperations\Update; } diff --git a/lib/Source.php b/lib/Source.php index f01af43d51..1b8d70223d 100644 --- a/lib/Source.php +++ b/lib/Source.php @@ -9,50 +9,9 @@ */ class Source extends ApiResource { - /** - * @param array|string $id The ID of the source to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return Source - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Source The created Source. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the source to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Source The updated source. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return Source The saved source. - */ - public function save($opts = null) - { - return $this->_save($opts); - } + use ApiOperations\Create; + use ApiOperations\Retrieve; + use ApiOperations\Update; /** * @param array|null $params diff --git a/lib/Subscription.php b/lib/Subscription.php index 041ed31b65..2e0ac1444c 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -9,6 +9,11 @@ */ class Subscription extends ApiResource { + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + use ApiOperations\Update; + /** * These constants are possible representations of the status field. * @@ -20,52 +25,6 @@ class Subscription extends ApiResource const STATUS_TRIALING = 'trialing'; const STATUS_UNPAID = 'unpaid'; - /** - * @param array|string $id The ID of the subscription to retrieve, or an - * options array containing an `id` key. - * @param array|string|null $opts - * - * @return Subscription - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Subscriptions - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Subscription The created subscription. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the subscription to retrieve. - * @param array|null $params - * @param array|string|null $options - * - * @return Subscription The updated subscription. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - /** * @param array|null $params * @@ -76,16 +35,6 @@ public function cancel($params = null, $opts = null) return $this->_delete($params, $opts); } - /** - * @param array|string|null $opts - * - * @return Subscription The saved subscription. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - /** * @return Subscription The updated subscription. */ diff --git a/lib/SubscriptionItem.php b/lib/SubscriptionItem.php index 98b1f91970..e0320be30e 100644 --- a/lib/SubscriptionItem.php +++ b/lib/SubscriptionItem.php @@ -9,6 +9,12 @@ */ class SubscriptionItem extends ApiResource { + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Delete; + use ApiOperations\Retrieve; + use ApiOperations\Update; + /** * This is a special case because the subscription items endpoint has an * underscore in it. The parent `className` function strips underscores. @@ -19,71 +25,4 @@ public static function className() { return 'subscription_item'; } - - /** - * @param array|string $id The ID of the subscription item to retrieve, or - * an options array containing an `id` key. - * @param array|string|null $opts - * - * @return SubscriptionItem - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of SubscriptionItems - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return SubscriptionItem The created subscription item. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } - - /** - * @param string $id The ID of the subscription item to update. - * @param array|null $params - * @param array|string|null $options - * - * @return SubscriptionItem The updated subscription item. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } - - /** - * @param array|string|null $opts - * - * @return SubscriptionItem The saved subscription item. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return SubscriptionItem The deleted subscription item. - */ - public function delete($params = null, $opts = null) - { - return $this->_delete($params, $opts); - } } diff --git a/lib/ThreeDSecure.php b/lib/ThreeDSecure.php index 11eb2f6526..7210bfd1f7 100644 --- a/lib/ThreeDSecure.php +++ b/lib/ThreeDSecure.php @@ -4,6 +4,9 @@ class ThreeDSecure extends ApiResource { + use ApiOperations\Create; + use ApiOperations\Retrieve; + /** * @return string The endpoint URL for the given class. */ @@ -11,27 +14,4 @@ public static function classUrl() { return "/v1/3d_secure"; } - - /** - * @param array|string $id The ID of the 3DS auth to retrieve, or an - * options array contianing an `id` key. - * @param array|string|null $options - * - * @return ThreeDSecure - */ - public static function retrieve($id, $options = null) - { - return self::_retrieve($id, $options); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return ThreeDSecure The created 3D Secure object. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } } diff --git a/lib/Token.php b/lib/Token.php index 93ad748db9..b3d68d0ede 100644 --- a/lib/Token.php +++ b/lib/Token.php @@ -19,26 +19,6 @@ */ class Token extends ApiResource { - /** - * @param array|string $id The ID of the token to retrieve, or an options - * array containing an `id` key. - * @param array|string|null $opts - * - * @return Token - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Token The created token. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } + use ApiOperations\Create; + use ApiOperations\Retrieve; } diff --git a/lib/Transfer.php b/lib/Transfer.php index a2184aadef..8fcf11db02 100644 --- a/lib/Transfer.php +++ b/lib/Transfer.php @@ -25,53 +25,12 @@ */ class Transfer extends ApiResource { - const PATH_REVERSALS = '/reversals'; - - /** - * @param array|string $id The ID of the transfer to retrieve, or an - * options array containing an `id` key. - * @param array|string|null $opts - * - * @return Transfer - */ - public static function retrieve($id, $opts = null) - { - return self::_retrieve($id, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Collection of Transfers - */ - public static function all($params = null, $opts = null) - { - return self::_all($params, $opts); - } - - /** - * @param array|null $params - * @param array|string|null $opts - * - * @return Transfer The created transfer. - */ - public static function create($params = null, $opts = null) - { - return self::_create($params, $opts); - } + use ApiOperations\All; + use ApiOperations\Create; + use ApiOperations\Retrieve; + use ApiOperations\Update; - /** - * @param string $id The ID of the transfer to update. - * @param array|null $params - * @param array|string|null $options - * - * @return Transfer The updated transfer. - */ - public static function update($id, $params = null, $options = null) - { - return self::_update($id, $params, $options); - } + const PATH_REVERSALS = '/reversals'; /** * @return TransferReversal The created transfer reversal. @@ -95,16 +54,6 @@ public function cancel() return $this; } - /** - * @param array|string|null $opts - * - * @return Transfer The saved transfer. - */ - public function save($opts = null) - { - return $this->_save($opts); - } - /** * @param array|null $id The ID of the transfer on which to create the reversal. * @param array|null $params