1
0
mirror of synced 2024-11-22 05:16:07 +03:00

Merge pull request #173 from oxy-coach/master

Fixed files/upload issue
This commit is contained in:
Andrey 2023-07-26 10:21:04 +03:00 committed by GitHub
commit bb5a205cd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -15,6 +15,7 @@ use RetailCrm\Api\Enum\RequestMethod;
use RetailCrm\Api\Exception\Client\HandlerException; use RetailCrm\Api\Exception\Client\HandlerException;
use RetailCrm\Api\Handler\AbstractHandler; use RetailCrm\Api\Handler\AbstractHandler;
use RetailCrm\Api\Interfaces\FormEncoderInterface; use RetailCrm\Api\Interfaces\FormEncoderInterface;
use RetailCrm\Api\Model\Request\Files\FilesUploadRequest;
use RetailCrm\Api\Model\RequestData; use RetailCrm\Api\Model\RequestData;
use Throwable; use Throwable;
@ -76,7 +77,9 @@ class RequestDataHandler extends AbstractHandler
} }
if ('' !== $formData) { if ('' !== $formData) {
if (static::queryShouldBeUsed($item->request->getMethod())) { if ($item->requestModel instanceof FilesUploadRequest) {
$item->request = $item->request->withBody($item->requestModel->file);
} elseif (static::queryShouldBeUsed($item->request->getMethod())) {
$item->request = $item->request->withUri( $item->request = $item->request->withUri(
$item->request->getUri()->withQuery($formData) $item->request->getUri()->withQuery($formData)
); );

View File

@ -98,7 +98,7 @@ EOF;
$request = new FilesUploadRequest($file); $request = new FilesUploadRequest($file);
$mock->matchMethod(RequestMethod::POST) $mock->matchMethod(RequestMethod::POST)
->matchBody(static::encodeForm($request)) ->matchBody($file)
->reply(200) ->reply(200)
->withBody($json); ->withBody($json);