Skip to content

Commit

Permalink
Fix calls to removed/changed API methods
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew72ru committed Dec 18, 2022
1 parent af0ad62 commit 6f5904c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
8 changes: 5 additions & 3 deletions src/Apis/FileApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,19 @@ public function nextPage(ListResponseInterface $response): ?ListResponseInterfac
* @param int $limit A preferred amount of files in a list for a single response. Defaults to 100, while the maximum is 1000.
* @param string $orderBy specifies the way files are sorted in a returned list
* @param string|int|null $from A starting point for filtering files. The value depends on your $orderBy parameter value.
* @param array $addFields Add special fields to the file object
* @param array $addFields @dep Add special fields to the file object
* @param bool|null $stored `true` to only include files that were stored, `false` to include temporary ones. The default is unset: both stored and not stored files are returned.
* @param bool $removed `true` to only include removed files in the response, `false` to include existing files. Defaults to false.
*/
public function listFiles(int $limit = 100, string $orderBy = 'datetime_uploaded', $from = null, array $addFields = [], ?bool $stored = null, bool $removed = false): ListResponseInterface
{
if (!empty($addFields)) {
\trigger_deprecation('uploadcare/uploadcare-php', '4.0.1', 'This parameter was removed from Uploadcare API');
}
$parameters = [
'limit' => $limit,
'ordering' => $orderBy,
'removed' => $removed,
'add_fields' => $addFields,
'from' => $from,
];
if (\is_bool($stored)) {
Expand Down Expand Up @@ -121,7 +123,7 @@ public function deleteFile($id): FileInfoInterface
if ($id instanceof FileInfoInterface) {
$id = $id->getUuid();
}
$response = $this->request('DELETE', \sprintf('/files/%s/', $id));
$response = $this->request('DELETE', \sprintf('/files/%s/storage/', $id));

return $this->deserializeFileInfo($response, false);
}
Expand Down
19 changes: 6 additions & 13 deletions src/Apis/GroupApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,17 @@ public function groupInfo(string $id): GroupInterface

/**
* {@inheritDoc}
*
* @deprecated since Uploadcare API 0.7.0
* @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Changelog
*/
public function storeGroup($id): GroupInterface
{
if ($id instanceof GroupInterface) {
$strId = $id->getId();
if ($strId === null) {
throw new HttpException();
}
$id = $strId;
}
\trigger_deprecation('uploadcare/uploadcare-php', '4.0.1', 'This parameter was removed from Uploadcare API');

$uri = \sprintf('/groups/%s/storage/', $id);
$response = $this->request('PUT', $uri);
if ($response->getStatusCode() === 200) {
return $this->groupInfo($id);
}
$result = $id instanceof GroupInterface ? $id : (new Group())->setId($id);

throw new HttpException('Wrong response from API', $response->getStatusCode());
return (new GroupDecorator($result, $this))->setConfiguration($this->configuration);
}

public function removeGroup($id): void
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/Api/GroupApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function groupInfo(string $id): GroupInterface;
* @param string|GroupInterface $id Group UUID
*
* @throws HttpException
*
* @deprecated
*/
public function storeGroup($id): GroupInterface;

Expand Down
11 changes: 0 additions & 11 deletions tests/Uploader/UploaderMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@ public function testFromPathMethod(): void
self::assertInstanceOf(FileInfoInterface::class, $response);
}

/**
* @group local-only
*/
public function testFromUrlMethod(): void
{
$body = ['file' => \uuid_create()];
$uploader = $this->makeUploaderWithResponse($body);

self::assertInstanceOf(FileInfoInterface::class, $uploader->fromUrl('https://httpbin.org/image/jpeg'));
}

public function testFromResourceMethod(): void
{
$body = ['file' => \uuid_create()];
Expand Down

0 comments on commit 6f5904c

Please sign in to comment.