Skip to content

Commit 9cc0d27

Browse files
authored
Only render fraud check if it's been set to false. True does not need to be rendered as it's default (#407)
1 parent 3c6d784 commit 9cc0d27

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/Verify2/Request/BaseVerifyRequest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ abstract class BaseVerifyRequest implements RequestInterface
1616

1717
protected int $timeout = 300;
1818

19-
protected bool $fraudCheck = true;
19+
protected ?bool $fraudCheck = null;
2020

2121
protected ?string $clientRef = null;
2222

@@ -134,9 +134,9 @@ public function addWorkflow(VerificationWorkflow $verificationWorkflow): static
134134
return $this;
135135
}
136136

137-
public function getFraudCheck(): bool
137+
public function getFraudCheck(): ?bool
138138
{
139-
return $this->fraudCheck;
139+
return $this->fraudCheck ?? null;
140140
}
141141

142142
public function setFraudCheck(bool $fraudCheck): BaseVerifyRequest
@@ -149,14 +149,17 @@ public function setFraudCheck(bool $fraudCheck): BaseVerifyRequest
149149
public function getBaseVerifyUniversalOutputArray(): array
150150
{
151151
$returnArray = [
152-
'fraud_check' => $this->getFraudCheck(),
153152
'locale' => $this->getLocale()->getCode(),
154153
'channel_timeout' => $this->getTimeout(),
155154
'code_length' => $this->getLength(),
156155
'brand' => $this->getBrand(),
157156
'workflow' => $this->getWorkflows()
158157
];
159158

159+
if ($this->getFraudCheck() === false) {
160+
$returnArray['fraud_check'] = $this->getFraudCheck();
161+
}
162+
160163
if ($this->getClientRef()) {
161164
$returnArray['client_ref'] = $this->getClientRef();
162165
}

test/Verify2/ClientTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testCanRequestSMS(): void
9898
);
9999

100100
$this->assertRequestJsonBodyContains('locale', 'en-us', $request);
101-
$this->assertRequestJsonBodyContains('fraud_check', true, $request);
101+
$this->assertRequestJsonBodyMissing('fraud_check', $request);
102102
$this->assertRequestJsonBodyContains('channel_timeout', 300, $request);
103103
$this->assertRequestJsonBodyContains('client_ref', $payload['client_ref'], $request);
104104
$this->assertRequestJsonBodyContains('code_length', 4, $request);
@@ -120,14 +120,13 @@ public function testCanBypassFraudCheck(): void
120120
{
121121
$payload = [
122122
'to' => '07785254785',
123-
'client_ref' => 'my-verification',
124123
'brand' => 'my-brand',
125124
];
126125

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

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

133132
return true;

0 commit comments

Comments
 (0)