PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.3.2
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.3.2
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Rest / ReferralItemsRestServiceProvider.php
ReferralItemsRestServiceProvider.php
82 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Rest;
4
5 use SureCart\Controllers\Rest\ReferralItemsController;
6
7 /**
8 * Service provider for referral items REST Requests
9 */
10 class ReferralItemsRestServiceProvider extends RestServiceProvider implements RestServiceInterface {
11 /**
12 * Endpoint
13 *
14 * @var string
15 */
16 protected $endpoint = 'referral_items';
17
18 /**
19 * Rest Controller
20 *
21 * @var string
22 */
23 protected $controller = ReferralItemsController::class;
24
25 /**
26 * Methods allowed for the model
27 *
28 * @var array
29 */
30 protected $methods = [ 'index', 'find' ];
31
32 /**
33 * Get our sample schema for a post.
34 *
35 * @return array The sample schema for a post
36 */
37 public function get_item_schema() {
38 if ( $this->schema ) {
39 // Since WordPress 5.3, the schema can be cached in the $schema property.
40 return $this->schema;
41 }
42
43 $this->schema = [
44 // This tells the spec of JSON Schema we are using which is draft 4.
45 '$schema' => 'http://json-schema.org/draft-04/schema#',
46 // The title property marks the identity of the resource.
47 'title' => $this->endpoint,
48 'type' => 'object',
49 // In JSON Schema you can specify object properties in the properties attribute.
50 'properties' => [
51 'id' => [
52 'description' => esc_html__( 'Unique identifier for the object.', 'surecart' ),
53 'type' => 'string',
54 'readonly' => true,
55 ],
56 ],
57 ];
58
59 return $this->schema;
60 }
61
62 /**
63 * Who can list referral items?
64 *
65 * @param \WP_REST_Request $request Full details about the request.
66 * @return true|\WP_Error True if the request has access to list items, WP_Error object otherwise.
67 */
68 public function get_items_permissions_check( $request ) {
69 return current_user_can( 'read_sc_affiliates' );
70 }
71
72 /**
73 * Who can get a specific referral item?
74 *
75 * @param \WP_REST_Request $request Full details about the request.
76 * @return true|\WP_Error True if the request has access to get an item, WP_Error object otherwise.
77 */
78 public function get_item_permissions_check( $request ) {
79 return current_user_can( 'read_sc_affiliates' );
80 }
81 }
82