Create REST action to delete short URL visits

This commit is contained in:
Alejandro Celaya
2023-05-14 12:00:08 +02:00
parent 2573c2bf98
commit 84a7981dfa
9 changed files with 132 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Core\ShortUrl;
use Shlinkio\Shlink\Core\Model\BulkDeleteResult;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlIdentifier;
use Shlinkio\Shlink\Core\Visit\Repository\VisitDeleterRepositoryInterface;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
class ShortUrlVisitsDeleter implements ShortUrlVisitsDeleterInterface
{
public function __construct(
private readonly VisitDeleterRepositoryInterface $repository,
private readonly ShortUrlResolverInterface $resolver,
) {
}
public function deleteShortUrlVisits(ShortUrlIdentifier $identifier, ?ApiKey $apiKey): BulkDeleteResult
{
$this->resolver->resolveShortUrl($identifier, $apiKey);
return new BulkDeleteResult($this->repository->deleteShortUrlVisits($identifier, $apiKey));
}
}

View File

@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Core\ShortUrl;
use Shlinkio\Shlink\Core\Model\BulkDeleteResult;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlIdentifier;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
interface ShortUrlVisitsDeleterInterface
{
public function deleteShortUrlVisits(ShortUrlIdentifier $identifier, ?ApiKey $apiKey): BulkDeleteResult;
}