Skip to content

Commit c31917a

Browse files
Merge pull request #321 from mailjet/fix-typed-error
Fix typed error when api key is not set but called
2 parents e6489fe + 9b211a7 commit c31917a

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

src/Mailjet/Client.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ public function __construct(string $key, ?string $secret = null, bool $call = tr
8686
/**
8787
* Trigger a POST request.
8888
*
89-
* @param array $resource Mailjet Resource/Action pair
90-
* @param array $args Request arguments
91-
* @param array $options
89+
* @param array $resource Mailjet Resource/Action pair
90+
* @param array $args Request arguments
91+
* @param array $options
92+
* @param string $contentType
9293
* @return Response
9394
*/
9495
public function post(array $resource, array $args = [], array $options = [], string $contentType = 'application/json'): Response
@@ -109,9 +110,10 @@ public function post(array $resource, array $args = [], array $options = [], str
109110
/**
110111
* Trigger a GET request.
111112
*
112-
* @param array $resource Mailjet Resource/Action pair
113-
* @param array $args Request arguments
114-
* @param array $options
113+
* @param array $resource Mailjet Resource/Action pair
114+
* @param array $args Request arguments
115+
* @param array $options
116+
* @param string $contentType
115117
* @return Response
116118
*/
117119
public function get(array $resource, array $args = [], array $options = [], string $contentType = 'application/json'): Response
@@ -153,9 +155,10 @@ public function get(array $resource, array $args = [], array $options = [], stri
153155
/**
154156
* Trigger a PUT request.
155157
*
156-
* @param array $resource Mailjet Resource/Action pair
157-
* @param array $args Request arguments
158-
* @param array $options
158+
* @param array $resource Mailjet Resource/Action pair
159+
* @param array $args Request arguments
160+
* @param array $options
161+
* @param string $contentType
159162
* @return Response
160163
*/
161164
public function put(array $resource, array $args = [], array $options = [], string $contentType = 'application/json'): Response
@@ -176,9 +179,10 @@ public function put(array $resource, array $args = [], array $options = [], stri
176179
/**
177180
* Trigger a DELETE request.
178181
*
179-
* @param array $resource Mailjet Resource/Action pair
180-
* @param array $args Request arguments
181-
* @param array $options
182+
* @param array $resource Mailjet Resource/Action pair
183+
* @param array $args Request arguments
184+
* @param array $options
185+
* @param string $contentType
182186
* @return Response
183187
*/
184188
public function delete(array $resource, array $args = [], array $options = [], string $contentType = 'application/json'): Response
@@ -305,6 +309,7 @@ public function setAuthentication(string $key, ?string $secret, bool $call, arra
305309
} else {
306310
$this->apitoken = $key;
307311
$this->version = Config::SMS_VERSION;
312+
$this->apikey = '';
308313
}
309314

310315
$this->initSettings($call, $settings);
@@ -378,11 +383,11 @@ private function getApiUrl(): string
378383
* Checks that both parameters are strings, which means
379384
* that basic authentication will be required.
380385
*
381-
* @param mixed $key
382-
* @param mixed $secret
386+
* @param string|null $key
387+
* @param string|null $secret
383388
* @return bool flag
384389
*/
385-
private function isBasicAuthentication($key, $secret): bool
390+
private function isBasicAuthentication(?string $key, ?string $secret): bool
386391
{
387392
return !empty($key) && !empty($secret);
388393
}

0 commit comments

Comments
 (0)