PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 2.0.0
WooCommerce Square v2.0.0
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 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.2.0 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 4.0.0 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.2.0 5.3.0 5.3.1 5.3.2 5.3.3
woocommerce-square / includes / API / Request.php
woocommerce-square / includes / API Last commit date
Requests 6 years ago Responses 6 years ago Request.php 6 years ago Response.php 6 years ago
Request.php
207 lines
1 <?php
2 /**
3 * WooCommerce Square
4 *
5 * This source file is subject to the GNU General Public License v3.0
6 * that is bundled with this package in the file license.txt.
7 * It is also available through the world-wide-web at this URL:
8 * http://www.gnu.org/licenses/gpl-3.0.html
9 * If you did not receive a copy of the license and are unable to
10 * obtain it through the world-wide-web, please send an email
11 * to license@woocommerce.com so we can send you a copy immediately.
12 *
13 * DISCLAIMER
14 *
15 * Do not edit or add to this file if you wish to upgrade WooCommerce Square to newer
16 * versions in the future. If you wish to customize WooCommerce Square for your
17 * needs please refer to https://docs.woocommerce.com/document/woocommerce-square/
18 *
19 * @author WooCommerce
20 * @copyright Copyright: (c) 2019, Automattic, Inc.
21 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
22 */
23
24 namespace WooCommerce\Square\API;
25
26 use SkyVerge\WooCommerce\PluginFramework\v5_4_0 as Framework;
27 use SquareConnect\Configuration;
28
29 defined( 'ABSPATH' ) or exit;
30
31 /**
32 * Base WooCommerce Square API request object.
33 *
34 * @since 2.0.0
35 */
36 class Request implements Framework\SV_WC_API_Request {
37
38
39 /** @var Configuration the configuration object */
40 protected $configuration;
41
42 /** @var mixed the Square API class instance being used for this request */
43 protected $square_api;
44
45 /** @var string method name on the square API to call */
46 protected $square_api_method;
47
48 /** @var array arguments for the method call */
49 protected $square_api_args = [];
50
51 /** @var null|object the square API request model */
52 protected $square_request;
53
54 /** @var bool whether the request is being made 'WithHTTPInfo' or not */
55 protected $with_http_info = true;
56
57
58 /**
59 * Gets the Square API instance to use for this request.
60 *
61 * @since 2.0.0
62 *
63 * @return mixed
64 */
65 public function get_square_api() {
66
67 return $this->square_api;
68 }
69
70
71 /**
72 * Get the method to call on the Square API instance.
73 *
74 * @since 2.0.0
75 *
76 * @return string
77 */
78 public function get_square_api_method() {
79
80 $method = $this->square_api_method;
81
82 return $this->with_http_info ? $method . 'WithHttpInfo' : $method;
83 }
84
85
86 /**
87 * Gets the arguments to call the Square API method with.
88 *
89 * @since 2.0.0
90 *
91 * @return array
92 */
93 public function get_square_api_args() {
94
95 return $this->square_api_args;
96 }
97
98
99 /**
100 * Returns whether this request is set to get HTTP info.
101 *
102 * @since 2.0.0
103 *
104 * @return bool
105 */
106 public function get_with_http_info() {
107
108 return $this->with_http_info;
109 }
110
111
112 /**
113 * Gets the HTTP method.
114 *
115 * @since 2.0.0
116 *
117 * @return string
118 */
119 public function get_method() {
120 // TODO: Implement get_method() method.
121 }
122
123
124 /**
125 * Gets the query parameters.
126 *
127 * @since 2.0.0
128 *
129 * @return array
130 */
131 public function get_params() {
132 // TODO: Implement get_params() method.
133 }
134
135
136 /**
137 * Gets the path.
138 *
139 * @since 2.0.0
140 *
141 * @return string
142 */
143 public function get_path() {
144 // TODO: Implement get_path() method.
145 }
146
147
148 /**
149 * Gets the request data.
150 *
151 * @since 2.0.0
152 *
153 * @return array
154 */
155 public function get_data() {
156 // TODO: Implement get_data() method.
157 }
158
159
160 /**
161 * Gets the request data as a string.
162 *
163 * @since 2.0.0
164 *
165 * @return string
166 */
167 public function to_string() {
168
169 $body = '';
170
171 if ( is_callable( [ $this->square_request, '__toString' ] ) ) {
172
173 $body = $this->square_request->__toString();
174
175 } elseif ( is_array( $this->square_api_args ) ) {
176
177 $body = [];
178
179 foreach ( $this->square_api_args as $key => $arg ) {
180
181 if ( is_callable( [ $arg, '__toString' ] ) ) {
182 $body[ $key ] = $arg->__toString();
183 }
184 }
185
186 $body = implode( ',', $body );
187 }
188
189 return $body;
190 }
191
192
193 /**
194 * Gets the request data as a string with all sensitive information masked.
195 *
196 * @since 2.0.0
197 *
198 * @return string
199 */
200 public function to_string_safe() {
201
202 return $this->to_string();
203 }
204
205
206 }
207