geno/wp-content/plugins/mailpoet/lib/Automation/Engine/Endpoints/Automations/AutomationsDeleteEndpoint.php

36 lines
930 B
PHP
Raw Normal View History

2024-02-01 17:24:18 +05:30
<?php declare(strict_types = 1);
namespace MailPoet\Automation\Engine\Endpoints\Automations;
if (!defined('ABSPATH')) exit;
use MailPoet\API\REST\Request;
use MailPoet\API\REST\Response;
use MailPoet\Automation\Engine\API\Endpoint;
use MailPoet\Automation\Engine\Builder\DeleteAutomationController;
use MailPoet\Validator\Builder;
class AutomationsDeleteEndpoint extends Endpoint {
/** @var DeleteAutomationController */
private $deleteController;
public function __construct(
DeleteAutomationController $deleteController
) {
$this->deleteController = $deleteController;
}
public function handle(Request $request): Response {
$automationId = intval($request->getParam('id'));
$this->deleteController->deleteAutomation($automationId);
return new Response(null);
}
public static function getRequestSchema(): array {
return [
'id' => Builder::integer()->required(),
];
}
}