Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 42
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
TriggerEventKey
0.00% covered (danger)
0.00%
0 / 42
0.00% covered (danger)
0.00%
0 / 5
1482
0.00% covered (danger)
0.00%
0 / 1
 eventClass
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
182
 label
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
182
 category
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
72
 fromEventClass
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 fromKey
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace ImovelZapAi\Automation\Domain\Enums;
6
7use ImovelZapAi\ClientPortal\Domain\Events\PortalDocumentUploaded;
8use ImovelZapAi\Documents\Domain\Events\DocumentAccepted;
9use ImovelZapAi\Documents\Domain\Events\DocumentRejected;
10use ImovelZapAi\Financial\Domain\Events\PaymentReceived;
11use ImovelZapAi\Owners\Domain\Events\ListingPublished;
12use ImovelZapAi\Owners\Domain\Events\OwnerCreated;
13use ImovelZapAi\Sales\Domain\Events\DealCreated;
14use ImovelZapAi\Sales\Domain\Events\DealStageChanged;
15use ImovelZapAi\Sales\Domain\Events\DealWon;
16use ImovelZapAi\Signatures\Domain\Events\SignatureCompleted;
17use ImovelZapAi\Visits\Domain\Events\VisitConfirmed;
18use ImovelZapAi\Visits\Domain\Events\VisitCreated;
19
20enum TriggerEventKey: string
21{
22    case DealCreated = 'deal.created';
23    case DealStageChanged = 'deal.stage_changed';
24    case DealWon = 'deal.won';
25    case VisitCreated = 'visit.created';
26    case VisitConfirmed = 'visit.confirmed';
27    case PortalDocumentUploaded = 'portal.document_uploaded';
28    case SignatureCompleted = 'signature.completed';
29    case PaymentReceived = 'payment.received';
30    case DocumentRejected = 'document.rejected';
31    case DocumentAccepted = 'document.accepted';
32    case ListingPublished = 'listing.published';
33    case OwnerCreated = 'owner.created';
34
35    public function eventClass(): string
36    {
37        return match ($this) {
38            self::DealCreated => DealCreated::class,
39            self::DealStageChanged => DealStageChanged::class,
40            self::DealWon => DealWon::class,
41            self::VisitCreated => VisitCreated::class,
42            self::VisitConfirmed => VisitConfirmed::class,
43            self::PortalDocumentUploaded => PortalDocumentUploaded::class,
44            self::SignatureCompleted => SignatureCompleted::class,
45            self::PaymentReceived => PaymentReceived::class,
46            self::DocumentRejected => DocumentRejected::class,
47            self::DocumentAccepted => DocumentAccepted::class,
48            self::ListingPublished => ListingPublished::class,
49            self::OwnerCreated => OwnerCreated::class,
50        };
51    }
52
53    public function label(): string
54    {
55        return match ($this) {
56            self::DealCreated => 'Oportunidade criada',
57            self::DealStageChanged => 'Etapa da oportunidade alterada',
58            self::DealWon => 'Oportunidade ganha',
59            self::VisitCreated => 'Visita agendada',
60            self::VisitConfirmed => 'Visita confirmada',
61            self::PortalDocumentUploaded => 'Documento enviado no portal',
62            self::SignatureCompleted => 'Assinatura concluída',
63            self::PaymentReceived => 'Pagamento recebido',
64            self::DocumentRejected => 'Documento recusado',
65            self::DocumentAccepted => 'Documento aceito',
66            self::ListingPublished => 'Anúncio publicado',
67            self::OwnerCreated => 'Pessoa proprietária cadastrada',
68        };
69    }
70
71    public function category(): string
72    {
73        return match ($this) {
74            self::DealCreated, self::DealStageChanged, self::DealWon => 'Oportunidades',
75            self::VisitCreated, self::VisitConfirmed => 'Visitas',
76            self::PortalDocumentUploaded => 'Portal do cliente',
77            self::SignatureCompleted => 'Assinaturas',
78            self::PaymentReceived => 'Financeiro',
79            self::DocumentRejected, self::DocumentAccepted => 'Documentos',
80            self::ListingPublished, self::OwnerCreated => 'Pessoas',
81        };
82    }
83
84    public static function fromEventClass(string $class): ?self
85    {
86        foreach (self::cases() as $case) {
87            if ($case->eventClass() === $class) {
88                return $case;
89            }
90        }
91
92        return null;
93    }
94
95    public static function fromKey(string $key): ?self
96    {
97        return self::tryFrom($key);
98    }
99}