Skip to content

Commit 5fe44d7

Browse files
author
Rodion Liuborets
committed
Add JSON serialize methods
1 parent 79facee commit 5fe44d7

15 files changed

+248
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ composer.lock
66
phpcs.xml
77

88
.phpunit.result.cache
9+
phpunit.xml.bak
910

1011
.php_cs.cache
1112

composer.json

Lines changed: 1 addition & 1 deletion
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.9.0",
4+
"version": "3.9.1",
55
"keywords": [
66
"yoti",
77
"sdk"

examples/doc-scan/app/Http/Controllers/HomeController.php

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
use Illuminate\Http\Request;
66
use Illuminate\Routing\Controller as BaseController;
77
use Yoti\DocScan\DocScanClient;
8-
use Yoti\DocScan\Session\Create\Check\Advanced\RequestedFuzzyMatchingStrategy;
9-
use Yoti\DocScan\Session\Create\Check\Advanced\RequestedSearchProfileSources;
8+
use Yoti\DocScan\Session\Create\Check\Advanced\RequestedExactMatchingStrategyBuilder;
9+
use Yoti\DocScan\Session\Create\Check\Advanced\RequestedFuzzyMatchingStrategyBuilder;
10+
use Yoti\DocScan\Session\Create\Check\Advanced\RequestedSearchProfileSourcesBuilder;
11+
use Yoti\DocScan\Session\Create\Check\Advanced\RequestedTypeListSourcesBuilder;
12+
use Yoti\DocScan\Session\Create\Check\RequestedCustomAccountWatchlistAdvancedCaConfigBuilder;
1013
use Yoti\DocScan\Session\Create\Check\RequestedDocumentAuthenticityCheckBuilder;
1114
use Yoti\DocScan\Session\Create\Check\RequestedFaceMatchCheckBuilder;
1215
use Yoti\DocScan\Session\Create\Check\RequestedIdDocumentComparisonCheckBuilder;
@@ -15,7 +18,6 @@
1518
use Yoti\DocScan\Session\Create\Check\RequestedWatchlistAdvancedCaCheckBuilder;
1619
use Yoti\DocScan\Session\Create\Check\RequestedWatchlistScreeningCheckBuilder;
1720
use Yoti\DocScan\Session\Create\Check\RequestedWatchlistScreeningConfigBuilder;
18-
use Yoti\DocScan\Session\Create\Check\RequestedYotiAccountWatchlistAdvancedCaConfigBuilder;
1921
use Yoti\DocScan\Session\Create\Filters\Orthogonal\OrthogonalRestrictionsFilterBuilder;
2022
use Yoti\DocScan\Session\Create\Filters\RequiredIdDocumentBuilder;
2123
use Yoti\DocScan\Session\Create\Filters\RequiredSupplementaryDocumentBuilder;
@@ -29,11 +31,43 @@ class HomeController extends BaseController
2931
{
3032
public function show(Request $request, DocScanClient $client)
3133
{
34+
//WatchScreening Config
3235
$watchScreeningConfig = (new RequestedWatchlistScreeningConfigBuilder())
3336
->withSanctionsCategory()
3437
->withAdverseMediaCategory()
3538
->build();
3639

40+
//Search Profiles Sources
41+
$searchProfileSources = (new RequestedSearchProfileSourcesBuilder())
42+
->withSearchProfile("5c62a621-ed6a-4f07-89a1-a941c1733b7c")
43+
->build();
44+
45+
//TypeListSources
46+
$typeListSources = (new RequestedTypeListSourcesBuilder())
47+
->withTypes(['type1', 'type2'])
48+
->build();
49+
50+
//FuzzyMatchingStrategy
51+
$fuzzyMatchingStrategy = (new RequestedFuzzyMatchingStrategyBuilder())
52+
->withFuzziness(0.5)
53+
->build();
54+
55+
//ExactMatchingStrategy
56+
$exactMatchingStrategy = (new RequestedExactMatchingStrategyBuilder())
57+
->build();
58+
59+
$customConfig = (new RequestedCustomAccountWatchlistAdvancedCaConfigBuilder())
60+
->withMatchingStrategy($exactMatchingStrategy)
61+
->withSources($searchProfileSources)
62+
->withShareUrl(false)
63+
->withRemoveDeceased(true)
64+
->withApiKey('qiKTHG7Mgqj31mK2d21F7QPpaVBp9zKc')
65+
->withClientRef("string")
66+
->withMonitoring(true)
67+
->withTags(['tag1'])
68+
->build();
69+
70+
3771
$sessionSpec = (new SessionSpecificationBuilder())
3872
->withClientSessionTokenTtl(600)
3973
->withResourcesTtl(90000)
@@ -47,6 +81,11 @@ public function show(Request $request, DocScanClient $client)
4781
->forZoomLiveness()
4882
->build()
4983
)
84+
->withRequestedCheck(
85+
(new RequestedWatchlistAdvancedCaCheckBuilder())
86+
->withConfig($customConfig)
87+
->build()
88+
)
5089
->withRequestedCheck(
5190
(new RequestedFaceMatchCheckBuilder())
5291
->withManualCheckAlways()
@@ -78,17 +117,17 @@ public function show(Request $request, DocScanClient $client)
78117
)
79118
->withSdkConfig(
80119
(new SdkConfigBuilder())
81-
->withAllowsCameraAndUpload()
82-
->withPrimaryColour('#2d9fff')
83-
->withSecondaryColour('#FFFFFF')
84-
->withFontColour('#FFFFFF')
85-
->withLocale('en-GB')
86-
->withPresetIssuingCountry('GBR')
87-
->withSuccessUrl(config('app.url') . '/success')
88-
->withErrorUrl(config('app.url') . '/error')
89-
->withPrivacyPolicyUrl(config('app.url') . '/privacy-policy')
90-
->build()
91-
)
120+
->withAllowsCameraAndUpload()
121+
->withPrimaryColour('#2d9fff')
122+
->withSecondaryColour('#FFFFFF')
123+
->withFontColour('#FFFFFF')
124+
->withLocale('en-GB')
125+
->withPresetIssuingCountry('GBR')
126+
->withSuccessUrl(config('app.url') . '/success')
127+
->withErrorUrl(config('app.url') . '/error')
128+
->withPrivacyPolicyUrl(config('app.url') . '/privacy-policy')
129+
->build()
130+
)
92131
->withRequiredDocument(
93132
(new RequiredIdDocumentBuilder())
94133
->withFilter(
@@ -118,9 +157,9 @@ public function show(Request $request, DocScanClient $client)
118157

119158
return view('home', [
120159
'iframeUrl' => config('yoti')['doc.scan.iframe.url'] . '?' . http_build_query([
121-
'sessionID' => $session->getSessionId(),
122-
'sessionToken' => $session->getClientSessionToken(),
123-
])
160+
'sessionID' => $session->getSessionId(),
161+
'sessionToken' => $session->getClientSessionToken(),
162+
])
124163
]);
125164
}
126165
}

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.9.0';
28+
public const SDK_VERSION = '3.9.1';
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/Session/Create/Check/Advanced/RequestedExactMatchingStrategy.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Yoti\DocScan\Session\Create\Check\Advanced;
66

7+
use Yoti\DocScan\Constants;
78
use Yoti\DocScan\Session\Create\Check\Contracts\Advanced\RequestedCaMatchingStrategy;
89

910
class RequestedExactMatchingStrategy extends RequestedCaMatchingStrategy
@@ -15,4 +16,12 @@ public function isExactMatch(): bool
1516
{
1617
return true;
1718
}
19+
20+
/**
21+
* @return string
22+
*/
23+
public function getType(): string
24+
{
25+
return Constants::EXACT;
26+
}
1827
}

src/DocScan/Session/Create/Check/Advanced/RequestedFuzzyMatchingStrategy.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Yoti\DocScan\Session\Create\Check\Advanced;
66

7+
use stdClass;
8+
use Yoti\DocScan\Constants;
79
use Yoti\DocScan\Session\Create\Check\Contracts\Advanced\RequestedCaMatchingStrategy;
810

911
class RequestedFuzzyMatchingStrategy extends RequestedCaMatchingStrategy
@@ -13,6 +15,9 @@ class RequestedFuzzyMatchingStrategy extends RequestedCaMatchingStrategy
1315
*/
1416
private $fuzziness;
1517

18+
/**
19+
* @param float $fuzziness
20+
*/
1621
public function __construct(float $fuzziness)
1722
{
1823
$this->fuzziness = $fuzziness;
@@ -25,4 +30,23 @@ public function getFuzziness(): float
2530
{
2631
return $this->fuzziness;
2732
}
33+
34+
/**
35+
* @return stdClass
36+
*/
37+
public function jsonSerialize(): stdClass
38+
{
39+
$json = parent::jsonSerialize();
40+
$json->fuzziness = $this->getFuzziness();
41+
42+
return $json;
43+
}
44+
45+
/**
46+
* @return string
47+
*/
48+
public function getType(): string
49+
{
50+
return Constants::FUZZY;
51+
}
2852
}

src/DocScan/Session/Create/Check/Advanced/RequestedSearchProfileSources.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Yoti\DocScan\Session\Create\Check\Advanced;
66

7+
use stdClass;
8+
use Yoti\DocScan\Constants;
79
use Yoti\DocScan\Session\Create\Check\Contracts\Advanced\RequestedCaSources;
810

911
class RequestedSearchProfileSources extends RequestedCaSources
@@ -13,6 +15,9 @@ class RequestedSearchProfileSources extends RequestedCaSources
1315
*/
1416
private $searchProfile;
1517

18+
/**
19+
* @param string $searchProfile
20+
*/
1621
public function __construct(string $searchProfile)
1722
{
1823
$this->searchProfile = $searchProfile;
@@ -25,4 +30,23 @@ public function getSearchProfile(): string
2530
{
2631
return $this->searchProfile;
2732
}
33+
34+
/**
35+
* @return string
36+
*/
37+
public function getType(): string
38+
{
39+
return Constants::PROFILE;
40+
}
41+
42+
/**
43+
* @return stdClass
44+
*/
45+
public function jsonSerialize(): stdClass
46+
{
47+
$json = parent::jsonSerialize();
48+
$json->search_profile = $this->getSearchProfile();
49+
50+
return $json;
51+
}
2852
}

src/DocScan/Session/Create/Check/Advanced/RequestedTypeListSources.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Yoti\DocScan\Session\Create\Check\Advanced;
66

7+
use stdClass;
8+
use Yoti\DocScan\Constants;
79
use Yoti\DocScan\Session\Create\Check\Contracts\Advanced\RequestedCaSources;
810

911
class RequestedTypeListSources extends RequestedCaSources
@@ -29,4 +31,23 @@ public function getTypes(): array
2931
{
3032
return $this->types;
3133
}
34+
35+
/**
36+
* @return string
37+
*/
38+
public function getType(): string
39+
{
40+
return Constants::TYPE_LIST;
41+
}
42+
43+
/**
44+
* @return stdClass
45+
*/
46+
public function jsonSerialize(): stdClass
47+
{
48+
$json = parent::jsonSerialize();
49+
$json->types = $this->getTypes();
50+
51+
return $json;
52+
}
3253
}

src/DocScan/Session/Create/Check/Contracts/Advanced/RequestedCaMatchingStrategy.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44

55
namespace Yoti\DocScan\Session\Create\Check\Contracts\Advanced;
66

7-
abstract class RequestedCaMatchingStrategy
7+
use stdClass;
8+
use Yoti\Util\Json;
9+
10+
abstract class RequestedCaMatchingStrategy implements \JsonSerializable
811
{
12+
/**
13+
* @var string
14+
*/
15+
public $type;
16+
17+
/**
18+
* @return string
19+
*/
20+
abstract public function getType(): string;
21+
22+
/**
23+
* @return stdClass
24+
*/
25+
public function jsonSerialize(): stdClass
26+
{
27+
return (object)Json::withoutNullValues([
28+
'type' => $this->getType(),
29+
]);
30+
}
931
}

src/DocScan/Session/Create/Check/Contracts/Advanced/RequestedCaSources.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44

55
namespace Yoti\DocScan\Session\Create\Check\Contracts\Advanced;
66

7-
abstract class RequestedCaSources
7+
use stdClass;
8+
use Yoti\Util\Json;
9+
10+
abstract class RequestedCaSources implements \JsonSerializable
811
{
12+
/**
13+
* @var string
14+
*/
15+
public $type;
16+
17+
/**
18+
* @return string
19+
*/
20+
abstract public function getType(): string;
21+
22+
/**
23+
* @return stdClass
24+
*/
25+
public function jsonSerialize(): stdClass
26+
{
27+
return (object)Json::withoutNullValues([
28+
'type' => $this->getType(),
29+
]);
30+
}
931
}

0 commit comments

Comments
 (0)