<?php

declare(strict_types=1);

namespace KupShop\DropshipBundle\Admin\Actions;

use KupShop\AdminBundle\Admin\Actions\AbstractAction;
use KupShop\AdminBundle\Admin\Actions\ActionResult;
use KupShop\AdminBundle\Admin\Actions\IAction;
use KupShop\DropshipBundle\Util\TransferWorker;
use Symfony\Contracts\Service\Attribute\Required;

class DropshipRunAction extends AbstractAction implements IAction
{
    #[Required]
    public TransferWorker $transferWorker;

    public function getTypes(): array
    {
        return ['Dropshipment'];
    }

    public function getName(): string
    {
        return 'Spustit dropshipment';
    }

    public function execute(&$data, array $config, string $type): ActionResult
    {
        $this->transferWorker->run(
            (int) $this->getId()
        );

        return new ActionResult(true);
    }
}
