Skip to content

Commit

Permalink
Fix from is now mandatory for WA verify2 (WABA) (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK committed Feb 19, 2024
1 parent ba6b02a commit db8d8b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Verify2/Request/WhatsAppRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion test/Verify2/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());

Expand Down

0 comments on commit db8d8b9

Please sign in to comment.