Skip to content

Commit

Permalink
Fix issue with overwrite API version
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Mykhailenko <[email protected]>
  • Loading branch information
oleksandr-mykhailenko committed Jul 21, 2022
1 parent d1db4ae commit 414650b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/Mailjet/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/Mailjet/MailjetApiv3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [[
Expand All @@ -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);
Expand Down

0 comments on commit 414650b

Please sign in to comment.