Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| PauseWorkflowAction | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| execute | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Automation\Application\Actions; |
| 6 | |
| 7 | use ImovelZapAi\Automation\Domain\Enums\WorkflowStatus; |
| 8 | use ImovelZapAi\Automation\Domain\Exceptions\AutomationException; |
| 9 | use ImovelZapAi\Automation\Infrastructure\Persistence\Eloquent\AutomationWorkflowModel; |
| 10 | |
| 11 | final class PauseWorkflowAction |
| 12 | { |
| 13 | public function execute(string $tenantId, string $workflowId): AutomationWorkflowModel |
| 14 | { |
| 15 | $workflow = AutomationWorkflowModel::query() |
| 16 | ->where('tenant_id', $tenantId) |
| 17 | ->where('id', $workflowId) |
| 18 | ->first(); |
| 19 | |
| 20 | if ($workflow === null) { |
| 21 | throw AutomationException::notFound('Automação'); |
| 22 | } |
| 23 | |
| 24 | $workflow->forceFill(['status' => WorkflowStatus::Paused])->save(); |
| 25 | |
| 26 | return $workflow->fresh(); |
| 27 | } |
| 28 | } |