Skip to content

Commit

Permalink
fix fail setData(null) error
Browse files Browse the repository at this point in the history
  • Loading branch information
z985342160 committed Aug 19, 2024
1 parent 57cdd37 commit 465f45c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/ApiResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ public static function fail(string $message, ?array $data = null): static
$result = new static();

$result->setSuccess(false)
->setData($data)
->setMessage($message)
;
->setMessage($message);

if (null !== $data) {
$result->setData($data);
}

return $result;
}
Expand Down
1 change: 0 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Promise;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Throwable;
Expand Down
7 changes: 6 additions & 1 deletion src/RequestBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public function setBodyParams(array $params): static

public function getRequest(): RequestInterface
{
$this->beforeBuildRequest();;
$this->beforeBuildRequest();

// Need to be removed, generated by Guzzle
if ('multipart/form-data' === $this->headers['Content-Type']) {
unset($this->headers['Content-Type']);
}

return new Request($this->method, $this->getUri(), $this->headers, $this->getBody());
}
Expand Down

0 comments on commit 465f45c

Please sign in to comment.