Skip to content

Commit 9af307a

Browse files
authored
Sdk 1955 Add support for setting instructions for In-Branch Verification (#247)
* SDK-1955 Add main logic * SDK-1955 Add tests
1 parent 091ed0f commit 9af307a

29 files changed

+1401
-8
lines changed

.github/workflows/tests.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ jobs:
5757

5858
- run: composer test
5959

60-
- run: composer lint
61-
6260
guzzle:
6361
name: Unit Tests With Guzzle 6 (php ${{ matrix.php-version }})
6462
runs-on: ubuntu-latest
@@ -87,8 +85,6 @@ jobs:
8785

8886
- run: composer test
8987

90-
- run: composer lint
91-
9288
protobuf:
9389
name: Unit Tests With Protobuf C Extension 3.13 (php ${{ matrix.php-version }})
9490
runs-on: ubuntu-latest
@@ -116,5 +112,3 @@ jobs:
116112

117113
- run: composer test
118114

119-
- run: composer lint
120-

src/DocScan/Constants.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class Constants
4343
public const FALLBACK = 'FALLBACK';
4444
public const NEVER = 'NEVER';
4545

46+
public const UK_POST_OFFICE = "UK_POST_OFFICE";
47+
4648
public const BASIC = 'BASIC';
4749
public const BEARER = 'BEARER';
4850

src/DocScan/DocScanClient.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Yoti\DocScan\Session\Create\FaceCapture\CreateFaceCaptureResourcePayload;
1010
use Yoti\DocScan\Session\Create\FaceCapture\UploadFaceCaptureImagePayload;
1111
use Yoti\DocScan\Session\Create\SessionSpecification;
12+
use Yoti\DocScan\Session\Instructions\Instructions;
1213
use Yoti\DocScan\Session\Retrieve\Configuration\SessionConfigurationResponse;
1314
use Yoti\DocScan\Session\Retrieve\GetSessionResult;
1415
use Yoti\DocScan\Support\SupportedDocumentsResponse;
@@ -176,4 +177,12 @@ public function getSessionConfiguration(string $sessionId): SessionConfiguration
176177
{
177178
return $this->docScanService->fetchSessionConfiguration($sessionId);
178179
}
180+
181+
/**
182+
* @throws Exception\DocScanException
183+
*/
184+
public function putIbvInstructions(string $sessionId, Instructions $instructions): void
185+
{
186+
$this->docScanService->putIbvInstructions($sessionId, $instructions);
187+
}
179188
}

src/DocScan/Service.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Yoti\DocScan\Session\Create\FaceCapture\CreateFaceCaptureResourcePayload;
1212
use Yoti\DocScan\Session\Create\FaceCapture\UploadFaceCaptureImagePayload;
1313
use Yoti\DocScan\Session\Create\SessionSpecification;
14+
use Yoti\DocScan\Session\Instructions\Instructions;
1415
use Yoti\DocScan\Session\Retrieve\Configuration\SessionConfigurationResponse;
1516
use Yoti\DocScan\Session\Retrieve\CreateFaceCaptureResourceResponse;
1617
use Yoti\DocScan\Session\Retrieve\GetSessionResult;
@@ -284,6 +285,25 @@ public function fetchSessionConfiguration(string $sessionId): SessionConfigurati
284285
return new SessionConfigurationResponse($result);
285286
}
286287

288+
/**
289+
* @param string $sessionId
290+
* @param Instructions $instructions
291+
* @throws DocScanException
292+
*/
293+
public function putIbvInstructions(string $sessionId, Instructions $instructions): void
294+
{
295+
$response = (new RequestBuilder($this->config))
296+
->withBaseUrl($this->apiUrl)
297+
->withPemFile($this->pemFile)
298+
->withEndpoint(sprintf('/sessions/%s/instructions', $sessionId))
299+
->withPut()
300+
->withPayload(Payload::fromJsonData($instructions))
301+
->build()
302+
->execute();
303+
304+
self::assertResponseIsSuccess($response);
305+
}
306+
287307
/**
288308
* @param ResponseInterface $response
289309
*
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Instructions\Branch;
4+
5+
abstract class Branch
6+
{
7+
/**
8+
* @var string
9+
*/
10+
private $type;
11+
12+
/**
13+
* @param string $type
14+
*/
15+
public function __construct(string $type)
16+
{
17+
$this->type = $type;
18+
}
19+
20+
/**
21+
* @return string
22+
*/
23+
public function getType(): string
24+
{
25+
return $this->type;
26+
}
27+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Instructions\Branch;
4+
5+
class Location
6+
{
7+
/**
8+
* @var float
9+
*/
10+
private $latitude;
11+
12+
/**
13+
* @var float
14+
*/
15+
private $longitude;
16+
17+
/**
18+
* @param float $longitude
19+
* @param float $latitude
20+
*/
21+
public function __construct(float $latitude, float $longitude)
22+
{
23+
$this->latitude = $latitude;
24+
$this->longitude = $longitude;
25+
}
26+
27+
/**
28+
* @return float
29+
*/
30+
public function getLatitude(): float
31+
{
32+
return $this->latitude;
33+
}
34+
35+
/**
36+
* @return float
37+
*/
38+
public function getLongitude(): float
39+
{
40+
return $this->longitude;
41+
}
42+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Instructions\Branch;
4+
5+
class LocationBuilder
6+
{
7+
/**
8+
* @var float
9+
*/
10+
private $latitude;
11+
12+
/**
13+
* @var float
14+
*/
15+
private $longitude;
16+
17+
/**
18+
* Sets the latitude of the location, in decimal degrees (e.g. -40.3992)
19+
*
20+
* @param float $latitude
21+
* @return $this
22+
*/
23+
public function withLatitude(float $latitude): LocationBuilder
24+
{
25+
$this->latitude = $latitude;
26+
return $this;
27+
}
28+
29+
/**
30+
* Sets the longitude of the location, in decimal degrees (e.g. 20.4821)
31+
*
32+
* @param float $longitude
33+
* @return $this
34+
*/
35+
public function withLongitude(float $longitude): LocationBuilder
36+
{
37+
$this->longitude = $longitude;
38+
return $this;
39+
}
40+
41+
/**
42+
* @return Location
43+
*/
44+
public function build(): Location
45+
{
46+
return new Location($this->latitude, $this->longitude);
47+
}
48+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Instructions\Branch;
4+
5+
use Yoti\DocScan\Constants;
6+
7+
class UkPostOfficeBranch extends Branch
8+
{
9+
/**
10+
* @var string|null
11+
*/
12+
private $name;
13+
14+
/**
15+
* @var string|null
16+
*/
17+
private $address;
18+
19+
/**
20+
* @var string|null
21+
*/
22+
private $postCode;
23+
24+
/**
25+
* @var string|null
26+
*/
27+
private $fadCode;
28+
29+
/**
30+
* @var Location|null
31+
*/
32+
private $location;
33+
34+
public function __construct(
35+
?string $name,
36+
?string $address,
37+
?string $postCode,
38+
?string $fadCode = null,
39+
?Location $location = null
40+
) {
41+
parent::__construct(Constants::UK_POST_OFFICE);
42+
$this->name = $name;
43+
$this->address = $address;
44+
$this->postCode = $postCode;
45+
$this->fadCode = $fadCode;
46+
$this->location = $location;
47+
}
48+
49+
/**
50+
* Returns the FAD code that has been set for the {@link UkPostOfficeBranch}
51+
*
52+
* @return string|null
53+
*/
54+
public function getFadCode(): ?string
55+
{
56+
return $this->fadCode;
57+
}
58+
59+
/**
60+
* Returns the name that has been set for the {@link UkPostOfficeBranch}
61+
*
62+
* @return string|null
63+
*/
64+
public function getName(): ?string
65+
{
66+
return $this->name;
67+
}
68+
69+
/**
70+
* Returns the address that has been set for the {@link UkPostOfficeBranch}
71+
*
72+
* @return string|null
73+
*/
74+
public function getAddress(): ?string
75+
{
76+
return $this->address;
77+
}
78+
79+
/**
80+
* Returns the post code that has been set for the {@link UkPostOfficeBranch}
81+
*
82+
* @return string|null
83+
*/
84+
public function getPostCode(): ?string
85+
{
86+
return $this->postCode;
87+
}
88+
89+
/**
90+
* Returns the {@link Location} that has been set for the {@link UkPostOfficeBranch}
91+
*
92+
* @return Location|null
93+
*/
94+
public function getLocation(): ?Location
95+
{
96+
return $this->location;
97+
}
98+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
namespace Yoti\DocScan\Session\Instructions\Branch;
4+
5+
class UkPostOfficeBranchBuilder
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 Location|null
29+
*/
30+
private $location;
31+
32+
/**
33+
* @param string $name
34+
* @return $this
35+
*/
36+
public function withName(string $name): UkPostOfficeBranchBuilder
37+
{
38+
$this->name = $name;
39+
return $this;
40+
}
41+
42+
/**
43+
* @param string $address
44+
* @return $this
45+
*/
46+
public function withAddress(string $address): UkPostOfficeBranchBuilder
47+
{
48+
$this->address = $address;
49+
return $this;
50+
}
51+
52+
/**
53+
* @param string $postCode
54+
* @return $this
55+
*/
56+
public function withPostCode(string $postCode): UkPostOfficeBranchBuilder
57+
{
58+
$this->postCode = $postCode;
59+
return $this;
60+
}
61+
62+
/**
63+
* @param string $fadCode
64+
* @return $this
65+
*/
66+
public function withFadCode(string $fadCode): UkPostOfficeBranchBuilder
67+
{
68+
$this->fadCode = $fadCode;
69+
return $this;
70+
}
71+
72+
/**
73+
* @param Location $location
74+
* @return $this
75+
*/
76+
public function withLocation(Location $location): UkPostOfficeBranchBuilder
77+
{
78+
$this->location = $location;
79+
return $this;
80+
}
81+
82+
/**
83+
* @return UkPostOfficeBranch
84+
*/
85+
public function build(): UkPostOfficeBranch
86+
{
87+
return new UkPostOfficeBranch($this->name, $this->address, $this->postCode, $this->fadCode, $this->location);
88+
}
89+
}

0 commit comments

Comments
 (0)