Skip to content

Commit 414650b

Browse files
Fix issue with overwrite API version
Signed-off-by: Alexander Mykhailenko <[email protected]>
1 parent d1db4ae commit 414650b

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/Mailjet/Client.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,11 @@ private function buildURL(string $resource, string $action, string $id, string $
377377
*/
378378
private function setOptions(array $options, array $resource): void
379379
{
380-
$this->version = (string) ($options['version'] ?? $resource[2] ?? Config::MAIN_VERSION);
381-
$this->url = (string) ($options['url'] ?? Config::MAIN_URL);
380+
if (isset($options['version'])) {
381+
$this->version = $options['version'];
382+
}
383+
384+
$this->url = (string)($options['url'] ?? Config::MAIN_URL);
382385
$this->secure = $options['secured'] ?? Config::SECURED;
383386
$this->call = $options['call'] ?? true;
384387
$this->changed = true;

test/Mailjet/MailjetApiv3Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testPost()
102102

103103
public function testPostV31()
104104
{
105-
$client = new Client($this->publicKey, $this->secretKey, false);
105+
$client = new Client($this->publicKey, $this->secretKey, false, ['version' => 'v3.1']);
106106

107107
$email = [
108108
'Messages' => [[
@@ -112,7 +112,7 @@ public function testPostV31()
112112
]],
113113
];
114114

115-
$ret = $client->post(Resources::$Email, ['body' => $email], ['version' => 'v3.1']);
115+
$ret = $client->post(Resources::$Email, ['body' => $email], ['timeout' => 1]);
116116
$this->assertUrl('/send', $ret, 'v3.1');
117117
$this->assertPayload($email, $ret);
118118
$this->assertHttpMethod('POST', $ret);

0 commit comments

Comments
 (0)