PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 3.2.0
Brevo – Email, SMS, Web Push, Chat, and more. v3.2.0
2.9.13 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.1.29 3.1.3 3.1.30 3.1.31 3.1.32 3.1.33 3.1.34 3.1.35 3.1.36 3.1.37 3.1.38 3.1.39 3.1.4 3.1.40 3.1.41 3.1.42 3.1.43 3.1.44 3.1.45 3.1.46 3.1.47 3.1.48 3.1.49 3.1.5 3.1.50 3.1.51 3.1.52 3.1.53 3.1.54 3.1.55 3.1.56 3.1.57 3.1.58 3.1.59 3.1.6 3.1.60 3.1.61 3.1.62 3.1.63 3.1.64 3.1.65 3.1.66 3.1.67 3.1.68 3.1.69 3.1.7 3.1.70 3.1.71 3.1.72 3.1.73 3.1.74 3.1.75 3.1.76 3.1.77 3.1.78 3.1.79 3.1.8 3.1.80 3.1.81 3.1.82 3.1.83 3.1.84 3.1.85 3.1.86 3.1.87 3.1.88 3.1.89 3.1.9 3.1.90 3.1.91 3.1.92 3.1.93 3.1.94 3.1.95 3.1.96 3.1.97 3.1.98 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 trunk 1.0 1.5 2.0.8 2.9.10 2.9.11 2.9.12
mailin / wonderpush-php-lib / lib / Net / Request.php
mailin / wonderpush-php-lib / lib / Net Last commit date
CurlHttpClient.php 1 year ago HttpClientInterface.php 1 year ago Request.php 1 year ago Response.php 1 year ago
Request.php
277 lines
1 <?php
2
3 namespace WonderPush\Net;
4
5 if (count(get_included_files()) === 1) { http_response_code(403); exit(); } // Prevent direct access
6
7 /**
8 * Represents an HTTP request.
9 */
10 class Request extends \WonderPush\Obj\BaseObject {
11
12 /**
13 * HTTP GET method.
14 */
15 const GET = 'GET';
16
17 /**
18 * HTTP POST method.
19 */
20 const POST = 'POST';
21
22 /**
23 * HTTP PUT method.
24 */
25 const PUT = 'PUT';
26
27 /**
28 * HTTP DELETE method.
29 */
30 const DELETE = 'DELETE';
31
32 /**
33 * HTTP PATCH method.
34 */
35 const PATCH = 'PATCH';
36
37 /**
38 * HTTP method.
39 * @var string One of the constants of this class.
40 */
41 private $method;
42
43 /**
44 * Scheme, host, port and potential path prefix of the request.
45 *
46 * Should not end with a slash.
47 *
48 * @var string
49 */
50 private $root;
51
52 /**
53 * HTTP path.
54 *
55 * Should start with a slash.
56 *
57 * @var string
58 */
59 private $path;
60
61 /**
62 * Query string parameters.
63 *
64 * These parameters will not be promoted to body parameters.
65 *
66 * @var mixed[]
67 */
68 private $qsParams;
69
70 /**
71 * Body parameters.
72 *
73 * These parameters may be promoted to query string parameters, depending on the HTTP method used.
74 *
75 * @var mixed[]
76 */
77 private $params;
78
79 /**
80 * An associative array of 'paramName' => ['tmp_name' => '/full/path','name' => 'filename.png', 'type' => 'image/png'].
81 * @var mixed
82 */
83 private $files = array();
84
85 /**
86 * HTTP headers.
87 * @var mixed[]
88 */
89 private $headers;
90
91 /**
92 * The HTTP method.
93 * @return string One of the constants of this class.
94 */
95 public function getMethod() {
96 return $this->method;
97 }
98
99 /**
100 * Set the HTTP method.
101 * @param string $method One of the constants of this class.
102 * @return self
103 */
104 public function setMethod($method) {
105 $this->method = $method;
106 return $this;
107 }
108
109 /**
110 * The scheme, host, port and potential path prefix of the request.
111 *
112 * Should not end with a slash.
113 *
114 * @return string
115 */
116 public function getRoot() {
117 return $this->root;
118 }
119
120 /**
121 * Set the scheme, host, port and potential path prefix of the request.
122 *
123 * Should not end with a slash.
124 *
125 * @param string $root
126 * @return $this
127 */
128 public function setRoot($root) {
129 $this->root = $root;
130 return $this;
131 }
132
133 /**
134 * The HTTP path.
135 *
136 * Should start with a slash.
137 *
138 * @return string
139 */
140 public function getPath() {
141 return $this->path;
142 }
143
144 /**
145 * Set the HTTP path.
146 *
147 * Should start with a slash.
148 *
149 * @param string $path
150 * @return $this
151 */
152 public function setPath($path) {
153 $this->path = $path;
154 return $this;
155 }
156
157 /**
158 * The query string parameters.
159 *
160 * These parameters will not be promoted to body parameters.
161 *
162 * @return mixed[]
163 */
164 public function getQsParams() {
165 return $this->qsParams;
166 }
167
168 /**
169 * Set the query string parameters.
170 *
171 * These parameters will not be promoted to body parameters.
172 *
173 * @param mixed[] $qsParams
174 * @return $this
175 */
176 public function setQsParams($qsParams) {
177 $this->qsParams = $qsParams;
178 return $this;
179 }
180
181 /**
182 * @param $key
183 * @param $value
184 * @return $this
185 */
186 public function setQsParam($key, $value) {
187 if ($key === null) return $this;
188 if (!$this->qsParams) {
189 $this->qsParams = array();
190 }
191 if ($value === null) {
192 unset($this->qsParams[$key]);
193 } else {
194 $this->qsParams[$key] = $value;
195 }
196 return $this;
197 }
198
199 public function addFile($paramName, $filename, $path, $type) {
200 $this->files[$paramName] = array(
201 'name' => $filename,
202 'tmp_name' => $path,
203 'type' => $type,
204 );
205 return $this;
206 }
207
208 public function removeFile($paramName) {
209 unset($this->files[$paramName]);
210 return $this;
211 }
212
213 public function getFiles() {
214 return $this->files;
215 }
216
217 /**
218 * The body parameters.
219 *
220 * These parameters may be promoted to query string parameters, depending on the HTTP method used.
221 *
222 * @return mixed[]
223 */
224 public function getParams() {
225 return $this->params;
226 }
227
228 /**
229 * Set the body parameters.
230 *
231 * These parameters may be promoted to query string parameters, depending on the HTTP method used.
232 *
233 * @param mixed[] $params
234 * @return $this
235 */
236 public function setParams($params) {
237 $this->params = $params;
238 return $this;
239 }
240
241 /**
242 * The HTTP headers.
243 * @return mixed[]
244 */
245 public function getHeaders() {
246 return $this->headers;
247 }
248
249 /**
250 * Set the HTTP headers.
251 * @param mixed[] $headers
252 * @return $this
253 */
254 public function setHeaders($headers) {
255 $this->headers = $headers;
256 return $this;
257 }
258
259 /**
260 * @param $key
261 * @param $value
262 * @return $this
263 */
264 public function setHeader($key, $value) {
265 if ($key === null) return $this;
266 if (!$this->headers) {
267 $this->headers = array();
268 }
269 if ($value === null) {
270 unset($this->headers[$key]);
271 } else {
272 $this->headers[$key] = $value;
273 }
274 return $this;
275 }
276 }
277