1 | <?PHP |
||
26 | class Mailgun |
||
27 | { |
||
28 | /** |
||
29 | * @var RestClient |
||
30 | * |
||
31 | * @depracated Will be removed in 3.0 |
||
32 | */ |
||
33 | protected $restClient; |
||
34 | |||
35 | /** |
||
36 | * @var null|string |
||
37 | */ |
||
38 | protected $apiKey; |
||
39 | |||
40 | /** |
||
41 | * @var HttpMethodsClient |
||
42 | */ |
||
43 | private $httpClient; |
||
44 | |||
45 | /** |
||
46 | * @var ResponseDeserializer |
||
47 | */ |
||
48 | private $deserializer; |
||
49 | |||
50 | /** |
||
51 | * @var RequestBuilder |
||
52 | */ |
||
53 | private $requestBuilder; |
||
54 | |||
55 | /** |
||
56 | * @param string|null $apiKey |
||
57 | * @param HttpClient|null $httpClient |
||
58 | * @param string $apiEndpoint |
||
59 | * @param ResponseDeserializer|null $deserializer |
||
60 | * @param HttpClientConfigurator|null $clientConfigurator |
||
61 | * @param RequestBuilder|null $requestBuilder |
||
62 | */ |
||
63 | 6 | public function __construct( |
|
94 | |||
95 | /** |
||
96 | * This function allows the sending of a fully formed message OR a custom |
||
97 | * MIME string. If sending MIME, the string must be passed in to the 3rd |
||
98 | * position of the function call. |
||
99 | * |
||
100 | * @param string $workingDomain |
||
101 | * @param array $postData |
||
102 | * @param array $postFiles |
||
103 | * |
||
104 | * @throws Exceptions\MissingRequiredMIMEParameters |
||
105 | * |
||
106 | * @return \stdClass |
||
107 | */ |
||
108 | 6 | public function sendMessage($workingDomain, $postData, $postFiles = []) |
|
109 | { |
||
110 | 6 | if (is_array($postFiles)) { |
|
111 | 4 | return $this->post("$workingDomain/messages", $postData, $postFiles); |
|
112 | 2 | } elseif (is_string($postFiles)) { |
|
113 | 1 | $tempFile = tempnam(sys_get_temp_dir(), 'MG_TMP_MIME'); |
|
114 | 1 | $fileHandle = fopen($tempFile, 'w'); |
|
115 | 1 | fwrite($fileHandle, $postFiles); |
|
116 | |||
117 | 1 | $result = $this->post("$workingDomain/messages.mime", $postData, ['message' => $tempFile]); |
|
118 | 1 | fclose($fileHandle); |
|
119 | 1 | unlink($tempFile); |
|
120 | |||
121 | 1 | return $result; |
|
122 | } else { |
||
123 | 1 | throw new Exceptions\MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS); |
|
124 | } |
||
125 | 1 | } |
|
126 | |||
127 | /** |
||
128 | * This function checks the signature in a POST request to see if it is |
||
129 | * authentic. |
||
130 | * |
||
131 | * Pass an array of parameters. If you pass nothing, $_POST will be |
||
132 | * used instead. |
||
133 | * |
||
134 | * If this function returns FALSE, you must not process the request. |
||
135 | * You should reject the request with status code 403 Forbidden. |
||
136 | * |
||
137 | * @param array|null $postData |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | 3 | public function verifyWebhookSignature($postData = null) |
|
158 | |||
159 | /** |
||
160 | * @param string $endpointUrl |
||
161 | * @param array $postData |
||
162 | * @param array $files |
||
163 | * |
||
164 | * @return \stdClass |
||
165 | */ |
||
166 | 7 | public function post($endpointUrl, $postData = [], $files = []) |
|
170 | |||
171 | /** |
||
172 | * @param string $endpointUrl |
||
173 | * @param array $queryString |
||
174 | * |
||
175 | * @return \stdClass |
||
176 | */ |
||
177 | public function get($endpointUrl, $queryString = []) |
||
181 | |||
182 | /** |
||
183 | * @param string $url |
||
184 | * |
||
185 | * @return \stdClass |
||
186 | */ |
||
187 | 2 | public function getAttachment($url) |
|
191 | |||
192 | /** |
||
193 | * @param string $endpointUrl |
||
194 | * |
||
195 | * @return \stdClass |
||
196 | */ |
||
197 | public function delete($endpointUrl) |
||
201 | |||
202 | /** |
||
203 | * @param string $endpointUrl |
||
204 | * @param array $putData |
||
205 | * |
||
206 | * @return \stdClass |
||
207 | */ |
||
208 | public function put($endpointUrl, $putData) |
||
212 | |||
213 | /** |
||
214 | * @param string $apiVersion |
||
215 | * |
||
216 | * @return Mailgun |
||
217 | */ |
||
218 | public function setApiVersion($apiVersion) |
||
224 | |||
225 | /** |
||
226 | * @param bool $sslEnabled |
||
227 | * |
||
228 | * @return Mailgun |
||
229 | * |
||
230 | * @deprecated This will be removed in 3.0. Mailgun does not support non-secure connections to their API. |
||
231 | */ |
||
232 | public function setSslEnabled($sslEnabled) |
||
238 | |||
239 | /** |
||
240 | * @return MessageBuilder |
||
241 | */ |
||
242 | 28 | public function MessageBuilder() |
|
246 | |||
247 | /** |
||
248 | * @return OptInHandler |
||
249 | */ |
||
250 | 3 | public function OptInHandler() |
|
254 | |||
255 | /** |
||
256 | * @param string $workingDomain |
||
257 | * @param bool $autoSend |
||
258 | * |
||
259 | * @return BatchMessage |
||
260 | */ |
||
261 | 15 | public function BatchMessage($workingDomain, $autoSend = true) |
|
265 | |||
266 | /** |
||
267 | * @return Api\Stats |
||
268 | */ |
||
269 | public function stats() |
||
273 | |||
274 | /** |
||
275 | * @return Api\Domain |
||
276 | */ |
||
277 | public function domains() |
||
281 | |||
282 | /** |
||
283 | * @return Api\Tag |
||
284 | */ |
||
285 | public function tag() |
||
289 | |||
290 | /** |
||
291 | * @return Api\Event |
||
292 | */ |
||
293 | public function events() |
||
297 | |||
298 | /** |
||
299 | * @return Api\Routes |
||
300 | */ |
||
301 | public function routes() |
||
305 | |||
306 | /** |
||
307 | * @return Api\Webhook |
||
308 | */ |
||
309 | public function webhooks() |
||
313 | |||
314 | /** |
||
315 | * @return Api\Message |
||
316 | */ |
||
317 | public function messages() |
||
321 | |||
322 | /** |
||
323 | * @return Api\Suppressions |
||
324 | */ |
||
325 | public function suppressions() |
||
329 | } |
||
330 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..