AbandonedCheckoutProtocolController.php
2 years ago
AbandonedCheckoutsController.php
3 years ago
AccountController.php
2 years ago
ActivationsController.php
3 years ago
AffiliationProductsController.php
2 years ago
AffiliationProtocolController.php
2 years ago
AffiliationRequestsController.php
2 years ago
AffiliationsController.php
2 years ago
AutoFeeProtocolController.php
5 months ago
AutoFeesController.php
5 months ago
BalanceTransactionsController.php
3 years ago
BrandController.php
3 months ago
BumpsController.php
3 years ago
CancellationActsController.php
3 years ago
CancellationReasonsController.php
3 years ago
ChargesController.php
2 years ago
CheckEmailController.php
11 months ago
CheckoutsController.php
5 months ago
ClicksController.php
2 years ago
CouponsController.php
3 years ago
CustomerController.php
3 weeks ago
CustomerNotificationProtocolController.php
2 years ago
CustomerPortalProtocolController.php
1 year ago
DisplayCurrencyController.php
1 year ago
DisputesController.php
9 months ago
DownloadsController.php
3 years ago
DraftCheckoutsController.php
2 years ago
ExportsController.php
2 years ago
FulfillmentsController.php
3 years ago
ImportRowsController.php
1 month ago
IncomingWebhooksController.php
2 months ago
IntegrationCatalogController.php
1 year ago
IntegrationProvidersController.php
3 years ago
IntegrationsController.php
2 months ago
InvoicesController.php
1 year ago
LicensesController.php
3 years ago
LineItemsController.php
1 year ago
LoginController.php
3 weeks ago
ManualPaymentMethodsController.php
3 years ago
MediasController.php
3 years ago
OrderController.php
1 year ago
OrderProtocolController.php
2 years ago
ParcelTemplateController.php
3 months ago
PaymentIntentsController.php
2 years ago
PaymentMethodsController.php
2 years ago
PayoutGroupsController.php
2 years ago
PayoutsController.php
2 years ago
PeriodsController.php
3 years ago
PricesController.php
11 months ago
ProcessorController.php
3 years ago
ProductCollectionsController.php
2 years ago
ProductGroupsController.php
3 years ago
ProductMediaController.php
1 year ago
ProductsController.php
1 month ago
PromotionsController.php
3 years ago
ProvisionalAccountController.php
3 years ago
PurchasesController.php
3 years ago
ReferralItemsController.php
2 years ago
ReferralsController.php
2 years ago
RefundsController.php
3 years ago
RegisteredWebhookController.php
2 years ago
RestController.php
1 year ago
ReturnItemsController.php
2 years ago
ReturnReasonsController.php
2 years ago
ReturnRequestsController.php
2 years ago
ReviewProtocolController.php
4 months ago
ReviewsController.php
4 months ago
RuleSchemaController.php
5 months ago
SettingsController.php
3 weeks 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
SwapsController.php
1 year ago
TaxOverrideController.php
2 years ago
TaxProtocolController.php
2 years ago
TaxRegistrationController.php
3 years ago
TaxZoneController.php
3 years ago
UploadsController.php
3 years ago
UpsellFunnelsController.php
2 years ago
UpsellsController.php
2 years ago
VariantOptionsController.php
2 years ago
VariantValuesController.php
2 years ago
VariantsController.php
2 years ago
VerificationCodeController.php
3 weeks ago
WebhookController.php
3 years ago
ReferralsController.php
75 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Controllers\Rest; |
| 4 | |
| 5 | use SureCart\Models\Referral; |
| 6 | |
| 7 | /** |
| 8 | * Handle referrals requests through the REST API |
| 9 | */ |
| 10 | class ReferralsController extends RestController { |
| 11 | /** |
| 12 | * Class to make the requests. |
| 13 | * |
| 14 | * @var string |
| 15 | */ |
| 16 | protected $class = Referral::class; |
| 17 | |
| 18 | /** |
| 19 | * Approve a referral. |
| 20 | * |
| 21 | * @param \WP_REST_Request $request Rest Request. |
| 22 | * |
| 23 | * @return \WP_REST_Response |
| 24 | */ |
| 25 | public function approve( \WP_REST_Request $request ) { |
| 26 | $class = new $this->class( $request->get_json_params() ); |
| 27 | $class->id = $request['id']; |
| 28 | $model = $this->middleware( $class, $request ); |
| 29 | |
| 30 | if ( is_wp_error( $model ) ) { |
| 31 | return $model; |
| 32 | } |
| 33 | |
| 34 | return $model->where( $request->get_query_params() )->approve( $request['id'] ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Deny a referral |
| 39 | * |
| 40 | * @param \WP_REST_Request $request Rest Request. |
| 41 | * |
| 42 | * @return \WP_REST_Response |
| 43 | */ |
| 44 | public function deny( \WP_REST_Request $request ) { |
| 45 | $class = new $this->class( $request->get_json_params() ); |
| 46 | $class->id = $request['id']; |
| 47 | $model = $this->middleware( $class, $request ); |
| 48 | |
| 49 | if ( is_wp_error( $model ) ) { |
| 50 | return $model; |
| 51 | } |
| 52 | |
| 53 | return $model->where( $request->get_query_params() )->deny( $request['id'] ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Make a referral as in review |
| 58 | * |
| 59 | * @param \WP_REST_Request $request Rest Request. |
| 60 | * |
| 61 | * @return \WP_REST_Response |
| 62 | */ |
| 63 | public function make_reviewing( \WP_REST_Request $request ) { |
| 64 | $class = new $this->class( $request->get_json_params() ); |
| 65 | $class->id = $request['id']; |
| 66 | $model = $this->middleware( $class, $request ); |
| 67 | |
| 68 | if ( is_wp_error( $model ) ) { |
| 69 | return $model; |
| 70 | } |
| 71 | |
| 72 | return $model->where( $request->get_query_params() )->make_reviewing( $request['id'] ); |
| 73 | } |
| 74 | } |
| 75 |