Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

991 B
Raw Blame
<?php

namespace HiEvents\Http\Actions\Organizers\Webhooks;

use HiEvents\DomainObjects\Enums\Permission;
use HiEvents\DomainObjects\OrganizerDomainObject;
use HiEvents\Http\Actions\BaseAction;
use HiEvents\Http\Attributes\RequiresPermission;
use HiEvents\Services\Application\Handlers\Webhook\DeleteWebhookHandler;
use Illuminate\Http\Response;

#[RequiresPermission(Permission::VIEW_FINANCIALS)]
class DeleteOrganizerWebhookAction extends BaseAction
{
    public function __construct(
        private readonly DeleteWebhookHandler $deleteWebhookHandler,
    ) {}

    public function __invoke(int $organizerId, int $webhookId): Response
    {
        $this->isActionAuthorized($organizerId, OrganizerDomainObject::class);

        $this->deleteWebhookHandler->handle(
            webhookId: $webhookId,
            accountId: $this->getAuthenticatedAccountId(),
            eventId: null,
            organizerId: $organizerId,
        );

        return $this->deletedResponse();
    }
}