Skip to content

Commit 393dae9

Browse files
authored
Merge pull request #262 from getyoti/release-3.9.0
Release 3.9.0
2 parents 9b96576 + 79facee commit 393dae9

31 files changed

+1520
-13
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "yoti/yoti-php-sdk",
33
"description": "Yoti SDK for quickly integrating your PHP backend with Yoti",
4-
"version": "3.8.0",
4+
"version": "3.9.0",
55
"keywords": [
66
"yoti",
77
"sdk"
@@ -12,7 +12,7 @@
1212
"php": "^7.1 || ^8.0",
1313
"ext-json": "*",
1414
"google/protobuf": "^3.10",
15-
"phpseclib/phpseclib": "^2.0",
15+
"phpseclib/phpseclib": "^3.0",
1616
"guzzlehttp/guzzle": "^6.4 || ^7.0",
1717
"psr/http-client": "^1.0",
1818
"psr/http-message": "^1.0",

src/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Constants
2525
public const SDK_IDENTIFIER = 'PHP';
2626

2727
/** Default SDK version */
28-
public const SDK_VERSION = '3.8.0';
28+
public const SDK_VERSION = '3.9.0';
2929

3030
/** Base url for connect page (user will be redirected to this page eg. baseurl/app-id) */
3131
public const CONNECT_BASE_URL = 'https://www.yoti.com/connect';

src/DocScan/DocScanClient.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Yoti\DocScan\Session\Instructions\Instructions;
1313
use Yoti\DocScan\Session\Retrieve\Configuration\SessionConfigurationResponse;
1414
use Yoti\DocScan\Session\Retrieve\GetSessionResult;
15+
use Yoti\DocScan\Session\Retrieve\Instructions\ContactProfileResponse;
16+
use Yoti\DocScan\Session\Retrieve\Instructions\InstructionsResponse;
1517
use Yoti\DocScan\Support\SupportedDocumentsResponse;
1618
use Yoti\Media\Media;
1719
use Yoti\Util\Config;
@@ -193,4 +195,53 @@ public function putIbvInstructions(string $sessionId, Instructions $instructions
193195
{
194196
$this->docScanService->putIbvInstructions($sessionId, $instructions);
195197
}
198+
199+
/**
200+
* Fetches any currently set instructions for an IBV session.
201+
*
202+
* @param string $sessionId
203+
* @return InstructionsResponse
204+
* @throws Exception\DocScanException
205+
*/
206+
public function getIbvInstructions(string $sessionId): InstructionsResponse
207+
{
208+
return $this->docScanService->getIbvInstructions($sessionId);
209+
}
210+
211+
/**
212+
* Fetches the instructions PDF associated with an In-Branch Verification session.
213+
*
214+
* @param string $sessionId
215+
* @return Media
216+
* @throws Exception\DocScanException
217+
*/
218+
public function getIbvInstructionsPdf(string $sessionId): Media
219+
{
220+
return $this->docScanService->getIbvInstructionsPdf($sessionId);
221+
}
222+
223+
/**
224+
* Fetches the associated instructions contact profile for the given In-Branch Verification session
225+
*
226+
* @param string $sessionId
227+
* @return ContactProfileResponse
228+
* @throws Exception\DocScanException
229+
*/
230+
public function fetchInstructionsContactProfile(string $sessionId): ContactProfileResponse
231+
{
232+
return $this->docScanService->fetchInstructionsContactProfile($sessionId);
233+
}
234+
235+
/**
236+
* Triggers an email notification for the IBV instructions at-home flow.
237+
* This will be one of:
238+
* - an email sent directly to the end user, using the email provided in the ContactProfile
239+
* - if requested, a backend notification using the configured notification endpoint
240+
*
241+
* @throws Exception\DocScanException
242+
*/
243+
public function triggerIbvEmailNotification(string $sessionId): void
244+
{
245+
$this->docScanService->triggerIbvEmailNotification($sessionId);
246+
}
196247
}

src/DocScan/Service.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Yoti\DocScan\Session\Retrieve\Configuration\SessionConfigurationResponse;
1616
use Yoti\DocScan\Session\Retrieve\CreateFaceCaptureResourceResponse;
1717
use Yoti\DocScan\Session\Retrieve\GetSessionResult;
18+
use Yoti\DocScan\Session\Retrieve\Instructions\ContactProfileResponse;
19+
use Yoti\DocScan\Session\Retrieve\Instructions\InstructionsResponse;
1820
use Yoti\DocScan\Support\SupportedDocumentsResponse;
1921
use Yoti\Http\Payload;
2022
use Yoti\Http\Request;
@@ -309,6 +311,90 @@ public function putIbvInstructions(string $sessionId, Instructions $instructions
309311
self::assertResponseIsSuccess($response);
310312
}
311313

314+
/**
315+
* @param string $sessionId
316+
* @return InstructionsResponse
317+
* @throws DocScanException
318+
*/
319+
public function getIbvInstructions(string $sessionId): InstructionsResponse
320+
{
321+
$response = (new RequestBuilder($this->config))
322+
->withBaseUrl($this->apiUrl)
323+
->withPemFile($this->pemFile)
324+
->withEndpoint(sprintf('/sessions/%s/instructions', $sessionId))
325+
->withGet()
326+
->build()
327+
->execute();
328+
329+
self::assertResponseIsSuccess($response);
330+
331+
$result = Json::decode((string)$response->getBody());
332+
333+
return new InstructionsResponse($result);
334+
}
335+
336+
/**
337+
* @param string $sessionId
338+
* @return Media
339+
* @throws DocScanException
340+
*/
341+
public function getIbvInstructionsPdf(string $sessionId): Media
342+
{
343+
$response = (new RequestBuilder($this->config))
344+
->withBaseUrl($this->apiUrl)
345+
->withPemFile($this->pemFile)
346+
->withEndpoint(sprintf('/sessions/%s/instructions/pdf', $sessionId))
347+
->withGet()
348+
->build()
349+
->execute();
350+
351+
self::assertResponseIsSuccess($response);
352+
353+
$content = (string)$response->getBody();
354+
$mimeType = $response->getHeader("Content-Type")[0] ?? '';
355+
356+
return new Media($mimeType, $content);
357+
}
358+
359+
/**
360+
* @param string $sessionId
361+
* @return ContactProfileResponse
362+
* @throws DocScanException
363+
*/
364+
public function fetchInstructionsContactProfile(string $sessionId): ContactProfileResponse
365+
{
366+
$response = (new RequestBuilder($this->config))
367+
->withBaseUrl($this->apiUrl)
368+
->withPemFile($this->pemFile)
369+
->withEndpoint(sprintf('/sessions/%s/instructions/contact-profile', $sessionId))
370+
->withGet()
371+
->build()
372+
->execute();
373+
374+
self::assertResponseIsSuccess($response);
375+
376+
$result = Json::decode((string)$response->getBody());
377+
378+
return new ContactProfileResponse($result);
379+
}
380+
381+
/**
382+
* @param string $sessionId
383+
* @throws DocScanException
384+
*/
385+
public function triggerIbvEmailNotification(string $sessionId): void
386+
{
387+
$response = (new RequestBuilder($this->config))
388+
->withBaseUrl($this->apiUrl)
389+
->withPemFile($this->pemFile)
390+
->withEndpoint(sprintf('/sessions/%s/instructions/email', $sessionId))
391+
->withPost()
392+
->build()
393+
->execute();
394+
395+
self::assertResponseIsSuccess($response);
396+
}
397+
312398
/**
313399
* @param ResponseInterface $response
314400
*

src/DocScan/Session/Create/Filters/Document/DocumentRestrictionsFilter.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ class DocumentRestrictionsFilter extends DocumentFilter implements \JsonSerializ
2020
*/
2121
private $documents;
2222

23+
/**
24+
* @var bool|null
25+
*/
26+
private $allowNonLatinDocuments;
27+
2328
/**
2429
* @param string $inclusion
2530
* @param DocumentRestriction[] $documents
31+
* @param bool|null $allowNonLatinDocuments
2632
*/
27-
public function __construct(string $inclusion, array $documents)
33+
public function __construct(string $inclusion, array $documents, ?bool $allowNonLatinDocuments)
2834
{
2935
parent::__construct(Constants::DOCUMENT_RESTRICTIONS);
3036

@@ -34,6 +40,7 @@ public function __construct(string $inclusion, array $documents)
3440
Validation::notEmptyArray($documents, 'documents');
3541
Validation::isArrayOfType($documents, [DocumentRestriction::class], 'documents');
3642
$this->documents = $documents;
43+
$this->allowNonLatinDocuments = $allowNonLatinDocuments;
3744
}
3845

3946
/**
@@ -44,6 +51,19 @@ public function jsonSerialize(): \stdClass
4451
$jsonData = parent::jsonSerialize();
4552
$jsonData->inclusion = $this->inclusion;
4653
$jsonData->documents = $this->documents;
54+
55+
if (isset($this->allowNonLatinDocuments)) {
56+
$jsonData->allow_non_latin_documents = $this->allowNonLatinDocuments;
57+
}
58+
4759
return $jsonData;
4860
}
61+
62+
/**
63+
* @return bool|null
64+
*/
65+
public function isAllowNonLatinDocuments(): ?bool
66+
{
67+
return $this->allowNonLatinDocuments;
68+
}
4969
}

src/DocScan/Session/Create/Filters/Document/DocumentRestrictionsFilterBuilder.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class DocumentRestrictionsFilterBuilder
2020
*/
2121
private $documents = [];
2222

23+
/**
24+
* @var bool|null
25+
*/
26+
private $allowNonLatinDocuments;
27+
2328
/**
2429
* @return $this
2530
*/
@@ -49,12 +54,25 @@ public function withDocumentRestriction(DocumentRestriction $documentRestriction
4954
return $this;
5055
}
5156

57+
/**
58+
* @return $this
59+
*/
60+
public function withAllowNonLatinDocuments(): self
61+
{
62+
$this->allowNonLatinDocuments = true;
63+
return $this;
64+
}
65+
5266
/**
5367
* @return DocumentRestrictionsFilter
5468
*/
5569
public function build(): DocumentFilter
5670
{
5771
Validation::notEmptyString($this->inclusion, 'inclusion');
58-
return new DocumentRestrictionsFilter($this->inclusion, $this->documents);
72+
return new DocumentRestrictionsFilter(
73+
$this->inclusion,
74+
$this->documents,
75+
$this->allowNonLatinDocuments
76+
);
5977
}
6078
}

src/DocScan/Session/Create/IbvOptions.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Yoti\DocScan\Session\Create;
44

5-
class IbvOptions
5+
use JsonSerializable;
6+
use Yoti\Util\Json;
7+
8+
class IbvOptions implements JsonSerializable
69
{
710
/**
811
* @var string
@@ -39,4 +42,16 @@ public function getGuidanceUrl(): ?string
3942
{
4043
return $this->guidanceUrl;
4144
}
45+
46+
47+
/**
48+
* @return \stdClass
49+
*/
50+
public function jsonSerialize(): \stdClass
51+
{
52+
return (object)Json::withoutNullValues([
53+
'support' => $this->getSupport(),
54+
'guidance_url' => $this->getGuidanceUrl(),
55+
]);
56+
}
4257
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Retrieve\Instructions\Branch;
4+
5+
class BranchResponse
6+
{
7+
/**
8+
* @var string
9+
*/
10+
protected $type;
11+
12+
/**
13+
* @return string
14+
*/
15+
public function getType(): string
16+
{
17+
return $this->type;
18+
}
19+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Retrieve\Instructions\Branch;
4+
5+
class LocationResponse
6+
{
7+
/**
8+
* @var float
9+
*/
10+
private $latitude;
11+
12+
/**
13+
* @var float
14+
*/
15+
private $longitude;
16+
17+
/**
18+
* @param array<string, float> $locationData
19+
*/
20+
public function __construct(array $locationData)
21+
{
22+
$this->latitude = $locationData['latitude'];
23+
$this->longitude = $locationData['longitude'];
24+
}
25+
26+
/**
27+
* @return float
28+
*/
29+
public function getLatitude(): float
30+
{
31+
return $this->latitude;
32+
}
33+
34+
/**
35+
* @return float
36+
*/
37+
public function getLongitude(): float
38+
{
39+
return $this->longitude;
40+
}
41+
}

0 commit comments

Comments
 (0)