Skip to content

Commit

Permalink
Fix issue with correct content type
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Mykhailenko <[email protected]>
  • Loading branch information
oleksandr-mykhailenko committed Oct 15, 2022
1 parent 7c285a5 commit 747518c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/Mailjet/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
5 changes: 1 addition & 4 deletions src/Mailjet/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 747518c

Please sign in to comment.