Skip to content

Commit

Permalink
Only render fraud check if it's been set to false. True does not need…
Browse files Browse the repository at this point in the history
… to be rendered as it's default (#407)
  • Loading branch information
SecondeJK authored May 17, 2023
1 parent 3c6d784 commit 9cc0d27
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/Verify2/Request/BaseVerifyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class BaseVerifyRequest implements RequestInterface

protected int $timeout = 300;

protected bool $fraudCheck = true;
protected ?bool $fraudCheck = null;

protected ?string $clientRef = null;

Expand Down Expand Up @@ -134,9 +134,9 @@ public function addWorkflow(VerificationWorkflow $verificationWorkflow): static
return $this;
}

public function getFraudCheck(): bool
public function getFraudCheck(): ?bool
{
return $this->fraudCheck;
return $this->fraudCheck ?? null;
}

public function setFraudCheck(bool $fraudCheck): BaseVerifyRequest
Expand All @@ -149,14 +149,17 @@ public function setFraudCheck(bool $fraudCheck): BaseVerifyRequest
public function getBaseVerifyUniversalOutputArray(): array
{
$returnArray = [
'fraud_check' => $this->getFraudCheck(),
'locale' => $this->getLocale()->getCode(),
'channel_timeout' => $this->getTimeout(),
'code_length' => $this->getLength(),
'brand' => $this->getBrand(),
'workflow' => $this->getWorkflows()
];

if ($this->getFraudCheck() === false) {
$returnArray['fraud_check'] = $this->getFraudCheck();
}

if ($this->getClientRef()) {
$returnArray['client_ref'] = $this->getClientRef();
}
Expand Down
5 changes: 2 additions & 3 deletions test/Verify2/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function testCanRequestSMS(): void
);

$this->assertRequestJsonBodyContains('locale', 'en-us', $request);
$this->assertRequestJsonBodyContains('fraud_check', true, $request);
$this->assertRequestJsonBodyMissing('fraud_check', $request);
$this->assertRequestJsonBodyContains('channel_timeout', 300, $request);
$this->assertRequestJsonBodyContains('client_ref', $payload['client_ref'], $request);
$this->assertRequestJsonBodyContains('code_length', 4, $request);
Expand All @@ -120,14 +120,13 @@ public function testCanBypassFraudCheck(): void
{
$payload = [
'to' => '07785254785',
'client_ref' => 'my-verification',
'brand' => 'my-brand',
];

$smsVerification = new SMSRequest($payload['to'], $payload['brand']);
$smsVerification->setFraudCheck(false);

$this->vonageClient->send(Argument::that(function (Request $request) use ($payload) {
$this->vonageClient->send(Argument::that(function (Request $request) {
$this->assertRequestJsonBodyContains('fraud_check', false, $request);

return true;
Expand Down

0 comments on commit 9cc0d27

Please sign in to comment.