AbandonedCheckoutProtocolRestServiceProvider.php
3 years ago
AbandonedCheckoutRestServiceProvider.php
2 years ago
AccountRestServiceProvider.php
3 years ago
ActivationRestServiceProvider.php
1 year ago
AffiliationProductsRestServiceProvider.php
2 years ago
AffiliationProtocolRestServiceProvider.php
2 years ago
AffiliationRequestsRestServiceProvider.php
2 years ago
AffiliationsRestServiceProvider.php
10 months ago
AutoFeeProtocolRestServiceProvider.php
5 months ago
AutoFeeRestServiceProvider.php
5 months ago
BalanceTransactionRestServiceProvider.php
3 years ago
BlockPatternsRestServiceProvider.php
3 years ago
BrandRestServiceProvider.php
3 months ago
BumpRestServiceProvider.php
1 year ago
CancellationActRestServiceProvider.php
1 year ago
CancellationReasonRestServiceProvider.php
1 year ago
ChargesRestServiceProvider.php
3 years ago
CheckEmailRestServiceProvider.php
3 years ago
CheckoutRestServiceProvider.php
1 year ago
ClicksRestServiceProvider.php
2 years ago
CouponRestServiceProvider.php
3 years ago
CustomerNotificationProtocolRestServiceProvider.php
3 years ago
CustomerPortalProtocolRestServiceProvider.php
1 year ago
CustomerRestServiceProvider.php
3 weeks ago
DisplayCurrencyRestServiceProvider.php
1 year ago
DisputesRestServiceProvider.php
9 months ago
DownloadRestServiceProvider.php
2 months ago
DraftCheckoutRestServiceProvider.php
1 year ago
ExportsRestServiceProvider.php
2 years ago
FulfillmentRestServiceProvider.php
3 years ago
ImportRowsRestServiceProvider.php
1 month ago
IncomingWebhooksRestServiceProvider.php
2 years ago
IntegrationProvidersRestServiceProvider.php
3 years ago
IntegrationsCatalogRestServiceProvider.php
1 year ago
IntegrationsRestServiceProvider.php
3 years ago
InvoicesRestServiceProvider.php
1 year ago
LicenseRestServiceProvider.php
1 year ago
LineItemsRestServiceProvider.php
1 year ago
LoginRestServiceProvider.php
3 weeks ago
ManualPaymentMethodsRestServiceProvider.php
3 years ago
MediaRestServiceProvider.php
1 year ago
OrderProtocolRestServiceProvider.php
1 year ago
OrderRestServiceProvider.php
1 year ago
ParcelTemplateRestServiceProvider.php
3 months ago
PaymentIntentsRestServiceProvider.php
3 years ago
PaymentMethodsRestServiceProvider.php
2 years ago
PayoutGroupsRestServiceProvider.php
2 years ago
PayoutsRestServiceProvider.php
4 months ago
PeriodRestServiceProvider.php
3 years ago
PriceRestServiceProvider.php
11 months ago
ProcessorRestServiceProvider.php
3 years ago
ProductCollectionsRestServiceProvider.php
2 years ago
ProductGroupsRestServiceProvider.php
3 years ago
ProductMediaRestServiceProvider.php
1 year ago
ProductsRestServiceProvider.php
1 month ago
PromotionRestServiceProvider.php
3 years ago
ProvisionalAccountRestServiceProvider.php
3 years ago
PurchasesRestServiceProvider.php
3 years ago
ReferralItemsRestServiceProvider.php
2 years ago
ReferralsRestServiceProvider.php
2 years ago
RefundsRestServiceProvider.php
3 years ago
RegisteredWebhookRestServiceProvider.php
2 years ago
RestServiceInterface.php
3 years ago
RestServiceProvider.php
1 year ago
ReturnItemsRestServiceProvider.php
2 years ago
ReturnReasonsRestServiceProvider.php
2 years ago
ReturnRequestsRestServiceProvider.php
2 years ago
ReviewProtocolRestServiceProvider.php
4 months ago
ReviewsRestServiceProvider.php
4 months ago
RuleSchemaRestServiceProvider.php
5 months ago
SettingsRestServiceProvider.php
1 year ago
ShippingMethodRestServiceProvider.php
3 years ago
ShippingProfileRestServiceProvider.php
3 years ago
ShippingProtocolRestServiceProvider.php
1 year ago
ShippingRateRestServiceProvider.php
3 years ago
ShippingZoneRestServiceProvider.php
3 years ago
SiteHealthRestServiceProvider.php
2 years ago
StatisticRestServiceProvider.php
3 years ago
SubscriptionProtocolRestServiceProvider.php
4 months ago
SubscriptionRestServiceProvider.php
2 years ago
SwapRestServiceProvider.php
1 year ago
TaxOverrideRestServiceProvider.php
1 year ago
TaxProtocolRestServiceProvider.php
1 year ago
TaxRegistrationRestServiceProvider.php
1 year ago
TaxZoneRestServiceProvider.php
1 year ago
UploadsRestServiceProvider.php
3 years ago
UpsellFunnelRestServiceProvider.php
1 year ago
UpsellRestServiceProvider.php
1 year ago
VariantOptionsRestServiceProvider.php
2 years ago
VariantValuesRestServiceProvider.php
2 years ago
VariantsRestServiceProvider.php
2 years ago
VerificationCodeRestServiceProvider.php
3 years ago
WebhooksRestServiceProvider.php
3 years ago
VerificationCodeRestServiceProvider.php
97 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Rest; |
| 4 | |
| 5 | use SureCart\Controllers\Rest\CheckEmailController; |
| 6 | use SureCart\Rest\RestServiceInterface; |
| 7 | use SureCart\Controllers\Rest\VerificationCodeController; |
| 8 | |
| 9 | /** |
| 10 | * Service provider for Price Rest Requests |
| 11 | */ |
| 12 | class VerificationCodeRestServiceProvider extends RestServiceProvider implements RestServiceInterface { |
| 13 | /** |
| 14 | * Endpoint. |
| 15 | * |
| 16 | * @var string |
| 17 | */ |
| 18 | protected $endpoint = 'verification_codes'; |
| 19 | |
| 20 | /** |
| 21 | * Rest Controller |
| 22 | * |
| 23 | * @var string |
| 24 | */ |
| 25 | protected $controller = VerificationCodeController::class; |
| 26 | |
| 27 | /** |
| 28 | * Methods allowed for the model. |
| 29 | * |
| 30 | * @var array |
| 31 | */ |
| 32 | protected $methods = [ 'create' ]; |
| 33 | |
| 34 | /** |
| 35 | * Register additional routes (the /verify route). |
| 36 | * |
| 37 | * @return void |
| 38 | */ |
| 39 | public function registerRoutes() { |
| 40 | register_rest_route( |
| 41 | "$this->name/v$this->version", |
| 42 | $this->endpoint . '/verify/', |
| 43 | [ |
| 44 | [ |
| 45 | 'methods' => \WP_REST_Server::EDITABLE, |
| 46 | 'callback' => $this->callback( $this->controller, 'verify' ), |
| 47 | 'permission_callback' => [ $this, 'verify_permissions_check' ], |
| 48 | ], |
| 49 | // Register our schema callback. |
| 50 | 'schema' => [ $this, 'get_item_schema' ], |
| 51 | ] |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get our sample schema for a post. |
| 57 | * |
| 58 | * @return array The sample schema for a post |
| 59 | */ |
| 60 | public function get_item_schema() { |
| 61 | if ( $this->schema ) { |
| 62 | // Since WordPress 5.3, the schema can be cached in the $schema property. |
| 63 | return $this->schema; |
| 64 | } |
| 65 | |
| 66 | $this->schema = [ |
| 67 | // This tells the spec of JSON Schema we are using which is draft 4. |
| 68 | '$schema' => 'http://json-schema.org/draft-04/schema#', |
| 69 | // The title property marks the identity of the resource. |
| 70 | 'title' => $this->endpoint, |
| 71 | 'type' => 'object', |
| 72 | ]; |
| 73 | |
| 74 | return $this->schema; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Anyone can get verify a code. |
| 79 | * |
| 80 | * @param \WP_REST_Request $request Full details about the request. |
| 81 | * @return true |
| 82 | */ |
| 83 | public function verify_permissions_check( $request ) { |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Must be a WordPress user to generate a verification code. |
| 89 | * |
| 90 | * @param \WP_REST_Request $request Full details about the request. |
| 91 | * @return boolean |
| 92 | */ |
| 93 | public function create_item_permissions_check( $request ) { |
| 94 | return ( new CheckEmailController() )->checkEmail( $request ); |
| 95 | } |
| 96 | } |
| 97 |