Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| AcknowledgeAnalyticsAlertAction | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| execute | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Analytics\Application\Actions; |
| 6 | |
| 7 | use ImovelZapAi\Analytics\Domain\Enums\AlertStatus; |
| 8 | use ImovelZapAi\Analytics\Domain\Exceptions\AnalyticsException; |
| 9 | use ImovelZapAi\Analytics\Infrastructure\Persistence\Eloquent\AnalyticsAlertModel; |
| 10 | |
| 11 | final class AcknowledgeAnalyticsAlertAction |
| 12 | { |
| 13 | public function execute(string $tenantId, string $alertId): AnalyticsAlertModel |
| 14 | { |
| 15 | $alert = AnalyticsAlertModel::query() |
| 16 | ->where('tenant_id', $tenantId) |
| 17 | ->where('id', $alertId) |
| 18 | ->first(); |
| 19 | |
| 20 | if ($alert === null) { |
| 21 | throw AnalyticsException::notFound('Alerta'); |
| 22 | } |
| 23 | |
| 24 | $alert->update([ |
| 25 | 'status' => AlertStatus::Acked->value, |
| 26 | ]); |
| 27 | |
| 28 | return $alert->fresh(); |
| 29 | } |
| 30 | } |