From db8d8b9c05f146043a7a3ca68ffa2d10098a8c9b Mon Sep 17 00:00:00 2001 From: James Seconde Date: Mon, 19 Feb 2024 10:51:11 +0000 Subject: [PATCH] Fix from is now mandatory for WA verify2 (WABA) (#469) --- src/Verify2/Request/WhatsAppRequest.php | 4 ++-- test/Verify2/ClientTest.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Verify2/Request/WhatsAppRequest.php b/src/Verify2/Request/WhatsAppRequest.php index 394112af..6b43c557 100644 --- a/src/Verify2/Request/WhatsAppRequest.php +++ b/src/Verify2/Request/WhatsAppRequest.php @@ -10,14 +10,14 @@ class WhatsAppRequest extends BaseVerifyRequest public function __construct( protected string $to, protected string $brand, - protected ?string $from = null, + protected string $from, protected ?VerificationLocale $locale = null, ) { if (!$this->locale) { $this->locale = new VerificationLocale(); } - $workflow = new VerificationWorkflow(VerificationWorkflow::WORKFLOW_WHATSAPP, $to); + $workflow = new VerificationWorkflow(VerificationWorkflow::WORKFLOW_WHATSAPP, $to, $from); $this->addWorkflow($workflow); } diff --git a/test/Verify2/ClientTest.php b/test/Verify2/ClientTest.php index 82b420cb..fe77d040 100644 --- a/test/Verify2/ClientTest.php +++ b/test/Verify2/ClientTest.php @@ -255,11 +255,12 @@ public function testCanRequestWhatsApp(): void { $payload = [ 'to' => '07785254785', + 'from' => '07785254785', 'client_ref' => 'my-verification', 'brand' => 'my-brand', ]; - $whatsAppVerification = new WhatsAppRequest($payload['to'], $payload['brand']); + $whatsAppVerification = new WhatsAppRequest($payload['to'], $payload['brand'], $payload['from']); $whatsAppVerification->setClientRef($payload['client_ref']); $this->vonageClient->send(Argument::that(function (Request $request) use ($payload) { @@ -269,6 +270,7 @@ public function testCanRequestWhatsApp(): void $this->assertRequestJsonBodyContains('code_length', 4, $request); $this->assertRequestJsonBodyContains('brand', $payload['brand'], $request); $this->assertRequestJsonBodyContains('to', $payload['to'], $request, true); + $this->assertRequestJsonBodyContains('from', $payload['from'], $request, true); $this->assertRequestJsonBodyContains('channel', 'whatsapp', $request, true); $this->assertEquals('POST', $request->getMethod());