Skip to content

Commit 37cb171

Browse files
committed
SDK-1744: Add support for biometric consent
1 parent d0d3992 commit 37cb171

File tree

5 files changed

+216
-70
lines changed

5 files changed

+216
-70
lines changed

src/DocScan/Session/Create/SessionSpecification.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
use Yoti\DocScan\Session\Create\Check\RequestedCheck;
99
use Yoti\DocScan\Session\Create\Filters\RequiredDocument;
1010
use Yoti\DocScan\Session\Create\Task\RequestedTask;
11+
use Yoti\Util\Json;
1112

1213
class SessionSpecification implements JsonSerializable
1314
{
14-
1515
/**
1616
* @var int|null
1717
*/
@@ -52,6 +52,11 @@ class SessionSpecification implements JsonSerializable
5252
*/
5353
private $sdkConfig;
5454

55+
/**
56+
* @var bool|null
57+
*/
58+
private $blockBiometricConsent;
59+
5560
/**
5661
* SessionSpecification constructor.
5762
* @param int|null $clientSessionTokenTtl
@@ -62,6 +67,7 @@ class SessionSpecification implements JsonSerializable
6267
* @param RequestedTask[] $requestedTasks
6368
* @param SdkConfig|null $sdkConfig
6469
* @param RequiredDocument[] $requiredDocuments
70+
* @param bool|null $blockBiometricConsent
6571
*/
6672
public function __construct(
6773
?int $clientSessionTokenTtl,
@@ -71,7 +77,8 @@ public function __construct(
7177
array $requestedChecks,
7278
array $requestedTasks,
7379
?SdkConfig $sdkConfig,
74-
array $requiredDocuments = []
80+
array $requiredDocuments = [],
81+
?bool $blockBiometricConsent = null
7582
) {
7683
$this->clientSessionTokenTtl = $clientSessionTokenTtl;
7784
$this->resourcesTtl = $resourcesTtl;
@@ -81,14 +88,15 @@ public function __construct(
8188
$this->requestedTasks = $requestedTasks;
8289
$this->sdkConfig = $sdkConfig;
8390
$this->requiredDocuments = $requiredDocuments;
91+
$this->blockBiometricConsent = $blockBiometricConsent;
8492
}
8593

8694
/**
8795
* @return array<string, mixed>
8896
*/
8997
public function jsonSerialize(): array
9098
{
91-
return [
99+
return Json::withoutNullValues([
92100
'client_session_token_ttl' => $this->getClientSessionTokenTtl(),
93101
'resources_ttl' => $this->getResourcesTtl(),
94102
'user_tracking_id' => $this->getUserTrackingId(),
@@ -97,7 +105,8 @@ public function jsonSerialize(): array
97105
'requested_tasks' => $this->getRequestedTasks(),
98106
'sdk_config' => $this->getSdkConfig(),
99107
'required_documents' => $this->getRequiredDocuments(),
100-
];
108+
'block_biometric_consent' => $this->getBlockBiometricConsent(),
109+
]);
101110
}
102111

103112
/**
@@ -163,4 +172,14 @@ public function getRequiredDocuments(): array
163172
{
164173
return $this->requiredDocuments;
165174
}
175+
176+
/**
177+
* Whether or not to block the collection of biometric consent
178+
*
179+
* @return bool|null
180+
*/
181+
public function getBlockBiometricConsent(): ?bool
182+
{
183+
return $this->blockBiometricConsent;
184+
}
166185
}

src/DocScan/Session/Create/SessionSpecificationBuilder.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class SessionSpecificationBuilder
5151
*/
5252
private $requiredDocuments = [];
5353

54+
/**
55+
* @var bool|null
56+
*/
57+
private $blockBiometricConsent;
58+
5459
/**
5560
* @param int $clientSessionTokenTtl
5661
* @return $this
@@ -154,6 +159,19 @@ public function withRequiredDocument(RequiredDocument $requiredDocument): self
154159
return $this;
155160
}
156161

162+
/**
163+
* Sets whether or not to block the collection of biometric consent
164+
*
165+
* @param bool $blockBiometricConsent
166+
*
167+
* @return $this
168+
*/
169+
public function withBlockBiometricConsent(bool $blockBiometricConsent): self
170+
{
171+
$this->blockBiometricConsent = $blockBiometricConsent;
172+
return $this;
173+
}
174+
157175
/**
158176
* @return SessionSpecification
159177
*/
@@ -167,7 +185,8 @@ public function build(): SessionSpecification
167185
$this->requestedChecks,
168186
$this->requestedTasks,
169187
$this->sdkConfig,
170-
$this->requiredDocuments
188+
$this->requiredDocuments,
189+
$this->blockBiometricConsent
171190
);
172191
}
173192
}

src/DocScan/Session/Retrieve/GetSessionResult.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Yoti\DocScan\Session\Retrieve;
66

77
use Yoti\DocScan\Constants;
8+
use Yoti\Util\DateTime;
89

910
class GetSessionResult
1011
{
@@ -44,6 +45,11 @@ class GetSessionResult
4445
*/
4546
private $clientSessionTokenTtl;
4647

48+
/**
49+
* @var \DateTime
50+
*/
51+
private $biometricConsent;
52+
4753
/**
4854
* DocScanSession constructor.
4955
* @param array<string, mixed> $sessionData
@@ -56,6 +62,10 @@ public function __construct(array $sessionData)
5662
$this->clientSessionToken = $sessionData['client_session_token'] ?? null;
5763
$this->clientSessionTokenTtl = $sessionData['client_session_token_ttl'] ?? null;
5864

65+
if (isset($sessionData['biometric_consent'])) {
66+
$this->biometricConsent = DateTime::stringToDateTime($sessionData['biometric_consent']);
67+
}
68+
5969
if (isset($sessionData['checks'])) {
6070
foreach ($sessionData['checks'] as $check) {
6171
$this->checks[] = $this->createCheckFromArray($check);
@@ -123,6 +133,14 @@ public function getClientSessionTokenTtl(): ?int
123133
return $this->clientSessionTokenTtl;
124134
}
125135

136+
/**
137+
* @return \DateTime|null
138+
*/
139+
public function getBiometricConsentTimestamp(): ?\DateTime
140+
{
141+
return $this->biometricConsent;
142+
}
143+
126144
/**
127145
* @return AuthenticityCheckResponse[]
128146
*/

0 commit comments

Comments
 (0)