From 747518ce0eebf64d27e9903441a255c85472a139 Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sat, 15 Oct 2022 19:24:08 +0300 Subject: [PATCH] Fix issue with correct content type Signed-off-by: Oleksandr Mykhailenko --- src/Mailjet/Client.php | 9 +++++++-- src/Mailjet/Request.php | 5 +---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Mailjet/Client.php b/src/Mailjet/Client.php index 4bc27e1..182731c 100644 --- a/src/Mailjet/Client.php +++ b/src/Mailjet/Client.php @@ -298,8 +298,13 @@ private function _call(string $method, string $resource, string $action, array $ $url = $this->buildURL($resource, $action, (string) $args['id'], $args['actionid']); - $contentType = ('csvdata/text:plain' === $action || 'csverror/text:csv' === $action) ? 'text/plain' : 'application/json'; - + $contentType = 'application/json'; + if ('csvdata/text:plain' === $action) { + $contentType = 'text/plain'; + } else if ('csverror/text:csv' === $action) { + $contentType = 'text/csv'; + } + $isBasicAuth = $this->isBasicAuthentication($this->apikey, $this->apisecret); $auth = $isBasicAuth ? [$this->apikey, $this->apisecret] : [$this->apitoken]; diff --git a/src/Mailjet/Request.php b/src/Mailjet/Request.php index af7d126..9fa7416 100644 --- a/src/Mailjet/Request.php +++ b/src/Mailjet/Request.php @@ -138,10 +138,7 @@ public function call($call) if ($call) { try { - $response = \call_user_func_array( - [$this, strtolower($this->method)], - [$this->url, $payload] - ); + $response = call_user_func([$this, strtolower($this->method)], $this->url, $payload); } catch (ClientException $e) { $response = $e->getResponse(); } catch (ServerException $e) {