diff --git a/src/Mailjet/Client.php b/src/Mailjet/Client.php index a18d263..3303247 100644 --- a/src/Mailjet/Client.php +++ b/src/Mailjet/Client.php @@ -377,8 +377,11 @@ private function buildURL(string $resource, string $action, string $id, string $ */ private function setOptions(array $options, array $resource): void { - $this->version = (string) ($options['version'] ?? $resource[2] ?? Config::MAIN_VERSION); - $this->url = (string) ($options['url'] ?? Config::MAIN_URL); + if (isset($options['version'])) { + $this->version = $options['version']; + } + + $this->url = (string)($options['url'] ?? Config::MAIN_URL); $this->secure = $options['secured'] ?? Config::SECURED; $this->call = $options['call'] ?? true; $this->changed = true; diff --git a/test/Mailjet/MailjetApiv3Test.php b/test/Mailjet/MailjetApiv3Test.php index b804b5b..8744260 100644 --- a/test/Mailjet/MailjetApiv3Test.php +++ b/test/Mailjet/MailjetApiv3Test.php @@ -102,7 +102,7 @@ public function testPost() public function testPostV31() { - $client = new Client($this->publicKey, $this->secretKey, false); + $client = new Client($this->publicKey, $this->secretKey, false, ['version' => 'v3.1']); $email = [ 'Messages' => [[ @@ -112,7 +112,7 @@ public function testPostV31() ]], ]; - $ret = $client->post(Resources::$Email, ['body' => $email], ['version' => 'v3.1']); + $ret = $client->post(Resources::$Email, ['body' => $email], ['timeout' => 1]); $this->assertUrl('/send', $ret, 'v3.1'); $this->assertPayload($email, $ret); $this->assertHttpMethod('POST', $ret);