Skip to content

Commit 9b5d549

Browse files
LuborRodRodion Liuborets
andauthored
Sdk 1956 Allow Relying Business to fetch IBV Instructions (#251)
* SDK-1956 Add main logic * SDK-1956 Add several tests * SDK-1956 Add more tests * SDK-1956 Add last tests Co-authored-by: Rodion Liuborets <[email protected]>
1 parent 8e468be commit 9b5d549

17 files changed

+756
-1
lines changed

src/DocScan/DocScanClient.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
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\InstructionsResponse;
1516
use Yoti\DocScan\Support\SupportedDocumentsResponse;
1617
use Yoti\Media\Media;
1718
use Yoti\Util\Config;
@@ -193,4 +194,14 @@ public function putIbvInstructions(string $sessionId, Instructions $instructions
193194
{
194195
$this->docScanService->putIbvInstructions($sessionId, $instructions);
195196
}
197+
198+
/**
199+
* @param string $sessionId
200+
* @return InstructionsResponse
201+
* @throws Exception\DocScanException
202+
*/
203+
public function getIbvInstructions(string $sessionId): InstructionsResponse
204+
{
205+
return $this->docScanService->getIbvInstructions($sessionId);
206+
}
196207
}

src/DocScan/Service.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
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\InstructionsResponse;
1819
use Yoti\DocScan\Support\SupportedDocumentsResponse;
1920
use Yoti\Http\Payload;
2021
use Yoti\Http\Request;
@@ -309,6 +310,28 @@ public function putIbvInstructions(string $sessionId, Instructions $instructions
309310
self::assertResponseIsSuccess($response);
310311
}
311312

313+
/**
314+
* @param string $sessionId
315+
* @return InstructionsResponse
316+
* @throws DocScanException
317+
*/
318+
public function getIbvInstructions(string $sessionId): InstructionsResponse
319+
{
320+
$response = (new RequestBuilder($this->config))
321+
->withBaseUrl($this->apiUrl)
322+
->withPemFile($this->pemFile)
323+
->withEndpoint(sprintf('/sessions/%s/instructions', $sessionId))
324+
->withGet()
325+
->build()
326+
->execute();
327+
328+
self::assertResponseIsSuccess($response);
329+
330+
$result = Json::decode((string)$response->getBody());
331+
332+
return new InstructionsResponse($result);
333+
}
334+
312335
/**
313336
* @param ResponseInterface $response
314337
*
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+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Retrieve\Instructions\Branch;
4+
5+
class UkPostOfficeBranchResponse extends BranchResponse
6+
{
7+
/**
8+
* @var string|null
9+
*/
10+
private $name;
11+
12+
/**
13+
* @var string|null
14+
*/
15+
private $address;
16+
17+
/**
18+
* @var string|null
19+
*/
20+
private $postCode;
21+
22+
/**
23+
* @var string|null
24+
*/
25+
private $fadCode;
26+
27+
/**
28+
* @var LocationResponse|null
29+
*/
30+
private $location;
31+
32+
/**
33+
* @param array<string, mixed> $branchData
34+
*/
35+
public function __construct(array $branchData)
36+
{
37+
$this->type = $branchData['type'];
38+
$this->fadCode = $branchData['fad_code'];
39+
$this->name = $branchData['name'];
40+
$this->address = $branchData['address'];
41+
$this->postCode = $branchData['post_code'];
42+
$this->location = new LocationResponse($branchData['location']);
43+
}
44+
45+
/**
46+
* @return string|null
47+
*/
48+
public function getName(): ?string
49+
{
50+
return $this->name;
51+
}
52+
53+
/**
54+
* @return string|null
55+
*/
56+
public function getAddress(): ?string
57+
{
58+
return $this->address;
59+
}
60+
61+
/**
62+
* @return string|null
63+
*/
64+
public function getPostCode(): ?string
65+
{
66+
return $this->postCode;
67+
}
68+
69+
/**
70+
* @return string|null
71+
*/
72+
public function getFadCode(): ?string
73+
{
74+
return $this->fadCode;
75+
}
76+
77+
/**
78+
* @return LocationResponse
79+
*/
80+
public function getLocation(): ?LocationResponse
81+
{
82+
return $this->location;
83+
}
84+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Retrieve\Instructions\Document;
4+
5+
use Yoti\DocScan\Constants;
6+
7+
class DocumentProposalResponse
8+
{
9+
/**
10+
* @var string|null
11+
*/
12+
private $requirementId;
13+
14+
/**
15+
* @var SelectedDocumentResponse|null
16+
*/
17+
private $document;
18+
19+
/**
20+
* @param array<string, mixed> $documentData
21+
*/
22+
public function __construct(array $documentData)
23+
{
24+
$this->requirementId = $documentData['requirement_id'];
25+
switch ($documentData['document']['type']) {
26+
case Constants::ID_DOCUMENT:
27+
$this->document = new SelectedIdDocumentResponse($documentData['document']);
28+
break;
29+
case Constants::SUPPLEMENTARY_DOCUMENT:
30+
$this->document = new SelectedSupplementaryDocumentResponse($documentData['document']);
31+
break;
32+
}
33+
}
34+
35+
/**
36+
* @return string|null
37+
*/
38+
public function getRequirementId(): ?string
39+
{
40+
return $this->requirementId;
41+
}
42+
43+
/**
44+
* @return SelectedDocumentResponse|null
45+
*/
46+
public function getDocument(): ?SelectedDocumentResponse
47+
{
48+
return $this->document;
49+
}
50+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Retrieve\Instructions\Document;
4+
5+
abstract class SelectedDocumentResponse
6+
{
7+
/**
8+
* @var string
9+
*/
10+
private $type;
11+
12+
/**
13+
* @var string|null
14+
*/
15+
private $countryCode;
16+
17+
/**
18+
* @var string|null
19+
*/
20+
private $documentType;
21+
22+
/**
23+
* @param array<string, string> $document
24+
*/
25+
public function __construct(array $document)
26+
{
27+
$this->type = $document['type'];
28+
$this->countryCode = $document['country_code'];
29+
$this->documentType = $document['document_type'];
30+
}
31+
32+
/**
33+
* @return string
34+
*/
35+
public function getType(): string
36+
{
37+
return $this->type;
38+
}
39+
40+
/**
41+
* @return string|null
42+
*/
43+
public function getCountryCode(): ?string
44+
{
45+
return $this->countryCode;
46+
}
47+
48+
/**
49+
* @return string|null
50+
*/
51+
public function getDocumentType(): ?string
52+
{
53+
return $this->documentType;
54+
}
55+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Retrieve\Instructions\Document;
4+
5+
class SelectedIdDocumentResponse extends SelectedDocumentResponse
6+
{
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Retrieve\Instructions\Document;
4+
5+
class SelectedSupplementaryDocumentResponse extends SelectedDocumentResponse
6+
{
7+
}

0 commit comments

Comments
 (0)