Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| NativeSignatureProvider | |
100.00% |
6 / 6 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| key | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| send | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| completeSigner | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| cancel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| outboundMessenger | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Signatures\Infrastructure\Providers\Drivers; |
| 6 | |
| 7 | use ImovelZapAi\Conversations\Application\Actions\SendOutboundMessageAction; |
| 8 | use ImovelZapAi\Signatures\Application\Services\NativeSignerCompletionService; |
| 9 | use ImovelZapAi\Signatures\Domain\Enums\SignatureProviderKey; |
| 10 | use ImovelZapAi\Signatures\Domain\Ports\SignatureProviderInterface; |
| 11 | use ImovelZapAi\Signatures\Infrastructure\Persistence\Eloquent\SignatureRequestModel; |
| 12 | use ImovelZapAi\Signatures\Infrastructure\Persistence\Eloquent\SignerModel; |
| 13 | use ImovelZapAi\Signatures\Infrastructure\Providers\Drivers\Concerns\NotifiesSignersViaWhatsapp; |
| 14 | |
| 15 | final class NativeSignatureProvider implements SignatureProviderInterface |
| 16 | { |
| 17 | use NotifiesSignersViaWhatsapp; |
| 18 | |
| 19 | public function __construct( |
| 20 | private readonly SendOutboundMessageAction $sendText, |
| 21 | private readonly NativeSignerCompletionService $completion, |
| 22 | ) {} |
| 23 | |
| 24 | public function key(): SignatureProviderKey |
| 25 | { |
| 26 | return SignatureProviderKey::Native; |
| 27 | } |
| 28 | |
| 29 | public function send(SignatureRequestModel $request): void |
| 30 | { |
| 31 | $this->notifySigners($request); |
| 32 | } |
| 33 | |
| 34 | public function completeSigner(SignatureRequestModel $request, SignerModel $signer, array $payload): void |
| 35 | { |
| 36 | $this->completion->complete($request, $signer, $payload); |
| 37 | } |
| 38 | |
| 39 | public function cancel(SignatureRequestModel $request): void |
| 40 | { |
| 41 | // Assinatura nativa não exige cancelamento externo. |
| 42 | } |
| 43 | |
| 44 | protected function outboundMessenger(): SendOutboundMessageAction |
| 45 | { |
| 46 | return $this->sendText; |
| 47 | } |
| 48 | } |