AutomationTemplateEmailPreviewEndpoint.php
1 month ago
AutomationTemplateGetEndpoint.php
1 year ago
AutomationTemplatesGetEndpoint.php
2 years ago
AutomationVersionsGetEndpoint.php
2 months ago
AutomationsCreateFromTemplateEndpoint.php
2 months ago
AutomationsDeleteEndpoint.php
2 years ago
AutomationsDuplicateEndpoint.php
2 years ago
AutomationsGetEndpoint.php
9 months ago
AutomationsPutEndpoint.php
2 months ago
index.php
3 years ago
AutomationsDeleteEndpoint.php
38 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Engine\Endpoints\Automations; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\API\REST\Request; |
| 9 | use MailPoet\API\REST\Response; |
| 10 | use MailPoet\Automation\Engine\API\Endpoint; |
| 11 | use MailPoet\Automation\Engine\Builder\DeleteAutomationController; |
| 12 | use MailPoet\Validator\Builder; |
| 13 | |
| 14 | class AutomationsDeleteEndpoint extends Endpoint { |
| 15 | /** @var DeleteAutomationController */ |
| 16 | private $deleteController; |
| 17 | |
| 18 | public function __construct( |
| 19 | DeleteAutomationController $deleteController |
| 20 | ) { |
| 21 | $this->deleteController = $deleteController; |
| 22 | } |
| 23 | |
| 24 | public function handle(Request $request): Response { |
| 25 | /** @var int $automationId */ |
| 26 | $automationId = $request->getParam('id'); |
| 27 | $automationId = intval($automationId); |
| 28 | $this->deleteController->deleteAutomation($automationId); |
| 29 | return new Response(null); |
| 30 | } |
| 31 | |
| 32 | public static function getRequestSchema(): array { |
| 33 | return [ |
| 34 | 'id' => Builder::integer()->required(), |
| 35 | ]; |
| 36 | } |
| 37 | } |
| 38 |