Skip to content

Commit

Permalink
Merge pull request #14 from answear/dev
Browse files Browse the repository at this point in the history
Request - add methods returns limit
  • Loading branch information
lukasz-falda authored May 8, 2020
2 parents 42052b8 + 800dfac commit 3a62827
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/LuigisBoxBundle/Service/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
use Answear\LuigisBoxBundle\ValueObject\ContentAvailability;
use Answear\LuigisBoxBundle\ValueObject\ContentAvailabilityCollection;
use Answear\LuigisBoxBundle\ValueObject\ContentRemovalCollection;
use Answear\LuigisBoxBundle\ValueObject\ContentUpdate;
use Answear\LuigisBoxBundle\ValueObject\ContentUpdateCollection;
use Answear\LuigisBoxBundle\ValueObject\PartialContentUpdate;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -67,6 +69,8 @@ public function __construct(
*/
public function contentUpdate(ContentUpdateCollection $objects): ApiResponse
{
Assert::allIsInstanceOf($objects->getObjects(), ContentUpdate::class);

if (\count($objects) > self::CONTENT_UPDATE_OBJECTS_LIMIT) {
throw new TooManyItemsException(\count($objects), self::CONTENT_UPDATE_OBJECTS_LIMIT);
}
Expand All @@ -91,6 +95,8 @@ public function contentUpdate(ContentUpdateCollection $objects): ApiResponse
*/
public function partialContentUpdate(ContentUpdateCollection $objects): ApiResponse
{
Assert::allIsInstanceOf($objects->getObjects(), PartialContentUpdate::class);

if (\count($objects) > self::PARTIAL_CONTENT_UPDATE_OBJECTS_LIMIT) {
throw new TooManyItemsException(\count($objects), self::PARTIAL_CONTENT_UPDATE_OBJECTS_LIMIT);
}
Expand Down Expand Up @@ -149,6 +155,16 @@ public function changeAvailability($object): ApiResponse
}
}

public static function getContentUpdateLimit(): int
{
return self::CONTENT_UPDATE_OBJECTS_LIMIT;
}

public static function getPartialContentUpdateLimit(): int
{
return self::PARTIAL_CONTENT_UPDATE_OBJECTS_LIMIT;
}

/**
* @throws BadRequestException
* @throws TooManyRequestsException
Expand Down

0 comments on commit 3a62827

Please sign in to comment.