Skip to content

Commit db8d8b9

Browse files
authored
Fix from is now mandatory for WA verify2 (WABA) (#469)
1 parent ba6b02a commit db8d8b9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Verify2/Request/WhatsAppRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ class WhatsAppRequest extends BaseVerifyRequest
1010
public function __construct(
1111
protected string $to,
1212
protected string $brand,
13-
protected ?string $from = null,
13+
protected string $from,
1414
protected ?VerificationLocale $locale = null,
1515
) {
1616
if (!$this->locale) {
1717
$this->locale = new VerificationLocale();
1818
}
1919

20-
$workflow = new VerificationWorkflow(VerificationWorkflow::WORKFLOW_WHATSAPP, $to);
20+
$workflow = new VerificationWorkflow(VerificationWorkflow::WORKFLOW_WHATSAPP, $to, $from);
2121

2222
$this->addWorkflow($workflow);
2323
}

test/Verify2/ClientTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,12 @@ public function testCanRequestWhatsApp(): void
255255
{
256256
$payload = [
257257
'to' => '07785254785',
258+
'from' => '07785254785',
258259
'client_ref' => 'my-verification',
259260
'brand' => 'my-brand',
260261
];
261262

262-
$whatsAppVerification = new WhatsAppRequest($payload['to'], $payload['brand']);
263+
$whatsAppVerification = new WhatsAppRequest($payload['to'], $payload['brand'], $payload['from']);
263264
$whatsAppVerification->setClientRef($payload['client_ref']);
264265

265266
$this->vonageClient->send(Argument::that(function (Request $request) use ($payload) {
@@ -269,6 +270,7 @@ public function testCanRequestWhatsApp(): void
269270
$this->assertRequestJsonBodyContains('code_length', 4, $request);
270271
$this->assertRequestJsonBodyContains('brand', $payload['brand'], $request);
271272
$this->assertRequestJsonBodyContains('to', $payload['to'], $request, true);
273+
$this->assertRequestJsonBodyContains('from', $payload['from'], $request, true);
272274
$this->assertRequestJsonBodyContains('channel', 'whatsapp', $request, true);
273275
$this->assertEquals('POST', $request->getMethod());
274276

0 commit comments

Comments
 (0)