Skip to content

Commit

Permalink
support whatsapp verification
Browse files Browse the repository at this point in the history
  • Loading branch information
ziming authored May 16, 2024
1 parent 0129a39 commit 2dfc897
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Contracts/PhoneVerificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface PhoneVerificationService
* @throws UnsupportedNumberException
* @throws FailedSendingVerificationCodeException
*/
public function send(PhoneNumber $number): void;
public function send(PhoneNumber $number, string $channel = 'sms'): void;

/**
* @throws VerificationCodeExpiredException
Expand Down
4 changes: 2 additions & 2 deletions src/Services/FakeVerificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ final class FakeVerificationService implements PhoneVerificationService
*/
private bool|Closure $verifyUsing = true;

public function send(PhoneNumber $number): void
public function send(PhoneNumber $number, string $channel = 'sms'): void
{
$this->verifications[] = $number->formatE164();

if ($this->sendUsing) {
$this->sendUsing->__invoke($number);
$this->sendUsing->__invoke($number, $channel);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Services/Twilio/TwilioVerificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function __construct(Client $twilio, string $verifyId)
$this->verificationChecks = $twilio->verificationChecks;
}

public function send(PhoneNumber $number): void
public function send(PhoneNumber $number), string $channel = 'sms'): void
{
try {
$this->verifications->create($number->formatE164(), 'sms');
$this->verifications->create($number->formatE164(), $channel);
} catch (TwilioException $e) {
throw match ($e->getCode()) {
self::ERROR_NUMBER_DOES_NOT_SUPPORT_SMS => UnsupportedNumberException::fromException($e),
Expand Down

0 comments on commit 2dfc897

Please sign in to comment.