PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 1.2.0
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v1.2.0
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 / ProcessorRestServiceProvider.php
ProcessorRestServiceProvider.php
108 lines 2.8 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\ProcessorController;
6 use SureCart\Rest\RestServiceInterface;
7
8 /**
9 * Service provider for Price Rest Requests
10 */
11 class ProcessorRestServiceProvider extends RestServiceProvider implements RestServiceInterface {
12
13 /**
14 * Endpoint.
15 *
16 * @var string
17 */
18 protected $endpoint = 'processors';
19
20 /**
21 * Rest Controller
22 *
23 * @var string
24 */
25 protected $controller = ProcessorController::class;
26
27 /**
28 * Get our sample schema for a post.
29 *
30 * @return array The sample schema for a post
31 */
32 public function get_item_schema() {
33 if ( $this->schema ) {
34 // Since WordPress 5.3, the schema can be cached in the $schema property.
35 return $this->schema;
36 }
37
38 $this->schema = [
39 // This tells the spec of JSON Schema we are using which is draft 4.
40 '$schema' => 'http://json-schema.org/draft-04/schema#',
41 // The title property marks the identity of the resource.
42 'title' => $this->endpoint,
43 'type' => 'object',
44 // In JSON Schema you can specify object properties in the properties attribute.
45 'properties' => [
46 'id' => [
47 'description' => esc_html__( 'Unique identifier for the object.', 'surecart' ),
48 'type' => 'string',
49 'context' => [ 'view', 'edit', 'embed' ],
50 'readonly' => true,
51 ],
52 ],
53 ];
54
55 return $this->schema;
56 }
57
58 /**
59 * Read permissions.
60 *
61 * @param \WP_REST_Request $request Full details about the request.
62 * @return true|\WP_Error True if the request has access to create items, WP_Error object otherwise.
63 */
64 public function get_item_permissions_check( $request ) {
65 return true;
66 }
67
68 /**
69 * List permissions.
70 *
71 * @param \WP_REST_Request $request Full details about the request.
72 * @return true|\WP_Error True if the request has access to create items, WP_Error object otherwise.
73 */
74 public function get_items_permissions_check( $request ) {
75 return true;
76 }
77
78 /**
79 * Create permissions.
80 *
81 * @param \WP_REST_Request $request Full details about the request.
82 * @return true|\WP_Error True if the request has access to create items, WP_Error object otherwise.
83 */
84 public function create_item_permissions_check( $request ) {
85 return current_user_can( 'edit_sc_payment_methods' );
86 }
87
88 /**
89 * Update permissions.
90 *
91 * @param \WP_REST_Request $request Full details about the request.
92 * @return true|\WP_Error True if the request has access to create items, WP_Error object otherwise.
93 */
94 public function update_item_permissions_check( $request ) {
95 return current_user_can( 'edit_sc_payment_methods' );
96 }
97
98 /**
99 * Delete permissions.
100 *
101 * @param \WP_REST_Request $request Full details about the request.
102 * @return false
103 */
104 public function delete_item_permissions_check( $request ) {
105 return current_user_can( 'edit_sc_payment_methods' );
106 }
107 }
108