PluginProbe
WooCommerce Square / 3.4.2
WooCommerce Square v3.4.2
5.5.0 5.4.3 5.4.2 5.4.1 5.4.0 trunk 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 All 132 releases
woocommerce-square / includes / Framework / Api / API_JSON_Request.php
API_JSON_Request.php
106 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WooCommerce\Square\Framework\Api;
4
5 defined( 'ABSPATH' ) or exit;
6
7 /**
8 * Base JSON API request class.
9 *
10 * @since 3.0.0
11 */
12 abstract class API_JSON_Request implements API_Request {
13
14
15 /** @var string The request method, one of HEAD, GET, PUT, PATCH, POST, DELETE */
16 protected $method;
17
18 /** @var string The request path */
19 protected $path;
20
21 /** @var array The request parameters, if any */
22 protected $params = array();
23
24 /** @var array the request data */
25 protected $data = array();
26
27
28 /**
29 * Get the request method.
30 *
31 * @since 3.0.0
32 * @see API_Request::get_method()
33 * @return string
34 */
35 public function get_method() {
36 return $this->method;
37 }
38
39
40 /**
41 * Get the request path.
42 *
43 * @since 3.0.0
44 * @see API_Request::get_path()
45 * @return string
46 */
47 public function get_path() {
48 return $this->path;
49 }
50
51
52 /**
53 * Get the request parameters.
54 *
55 * @since 3.0.0
56 * @see API_Request::get_params()
57 * @return array
58 */
59 public function get_params() {
60 return $this->params;
61 }
62
63
64 /**
65 * Get the request data.
66 *
67 * @since 3.0.0
68 * @return array
69 */
70 public function get_data() {
71 return $this->data;
72 }
73
74
75 /** API Helper Methods ******************************************************/
76
77
78 /**
79 * Get the string representation of this request.
80 *
81 * @since 3.0.0
82 * @see API_Request::to_string()
83 * @return string
84 */
85 public function to_string() {
86
87 $data = $this->get_data();
88
89 return ! empty( $data ) ? wp_json_encode( $data ) : '';
90 }
91
92
93 /**
94 * Get the string representation of this request with any and all sensitive elements masked
95 * or removed.
96 *
97 * @since 3.0.0
98 * @see API_Request::to_string_safe()
99 * @return string
100 */
101 public function to_string_safe() {
102
103 return $this->to_string();
104 }
105 }
106