AbandonedCheckoutProtocolController.php
2 years ago
AbandonedCheckoutsController.php
3 years ago
AccountController.php
2 years ago
ActivationsController.php
3 years ago
BalanceTransactionsController.php
3 years ago
BrandController.php
2 years ago
BumpsController.php
3 years ago
CancellationActsController.php
3 years ago
CancellationReasonsController.php
3 years ago
ChargesController.php
2 years ago
CheckEmailController.php
2 years ago
CheckoutsController.php
2 years ago
CouponsController.php
3 years ago
CustomerController.php
3 years ago
CustomerLinksController.php
2 years ago
CustomerNotificationProtocolController.php
2 years ago
DownloadsController.php
3 years ago
DraftCheckoutsController.php
2 years ago
FulfillmentsController.php
3 years ago
IncomingWebhooksController.php
2 years ago
IntegrationProvidersController.php
3 years ago
IntegrationsController.php
2 years ago
InvoicesController.php
3 years ago
LicensesController.php
3 years ago
LineItemsController.php
3 years ago
LoginController.php
3 years ago
ManualPaymentMethodsController.php
3 years ago
MediasController.php
3 years ago
OrderController.php
3 years ago
OrderProtocolController.php
2 years ago
PaymentIntentsController.php
2 years ago
PaymentMethodsController.php
2 years ago
PeriodsController.php
3 years ago
PortalProtocolController.php
2 years ago
PricesController.php
3 years ago
ProcessorController.php
3 years ago
ProductGroupsController.php
3 years ago
ProductMediaController.php
3 years ago
ProductsController.php
3 years ago
PromotionsController.php
3 years ago
ProvisionalAccountController.php
3 years ago
PurchasesController.php
3 years ago
RefundsController.php
3 years ago
RegisteredWebhookController.php
2 years ago
RestController.php
2 years ago
SettingsController.php
3 years ago
ShippingMethodController.php
3 years ago
ShippingProfileController.php
3 years ago
ShippingProtocolController.php
3 years ago
ShippingRateController.php
3 years ago
ShippingZoneController.php
3 years ago
StatisticsController.php
2 years ago
SubscriptionProtocolController.php
2 years ago
SubscriptionsController.php
2 years ago
TaxProtocolController.php
2 years ago
TaxRegistrationController.php
3 years ago
TaxZoneController.php
3 years ago
UploadsController.php
3 years ago
VerificationCodeController.php
3 years ago
WebhookController.php
3 years ago
PurchasesController.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Controllers\Rest; |
| 4 | |
| 5 | use SureCart\Models\Purchase; |
| 6 | |
| 7 | /** |
| 8 | * Handle Price requests through the REST API |
| 9 | */ |
| 10 | class PurchasesController extends RestController { |
| 11 | /** |
| 12 | * Class to make the requests. |
| 13 | * |
| 14 | * @var string |
| 15 | */ |
| 16 | protected $class = Purchase::class; |
| 17 | |
| 18 | /** |
| 19 | * Revoke a purchase. |
| 20 | * |
| 21 | * @param \WP_REST_Request $request Rest Request. |
| 22 | * |
| 23 | * @return \WP_REST_Response |
| 24 | */ |
| 25 | public function revoke( \WP_REST_Request $request ) { |
| 26 | $model = $this->middleware( new $this->class(), $request ); |
| 27 | if ( is_wp_error( $model ) ) { |
| 28 | return $model; |
| 29 | } |
| 30 | return $this->class::where( $request->get_query_params() )->revoke( $request['id'] ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Invoke (un-revoke) a purchase. |
| 35 | * |
| 36 | * @param \WP_REST_Request $request Rest Request. |
| 37 | * |
| 38 | * @return \WP_REST_Response |
| 39 | */ |
| 40 | public function invoke( \WP_REST_Request $request ) { |
| 41 | $model = $this->middleware( new $this->class(), $request ); |
| 42 | if ( is_wp_error( $model ) ) { |
| 43 | return $model; |
| 44 | } |
| 45 | return $this->class::where( $request->get_query_params() )->invoke( $request['id'] ); |
| 46 | } |
| 47 | } |
| 48 |