Skip to content

Commit

Permalink
SDK-2438 added watchlist screening and updated related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed Aug 20, 2024
1 parent 7de3e58 commit 14003c5
Show file tree
Hide file tree
Showing 27 changed files with 461 additions and 527 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0 || ^8.1",
"yoti/yoti-php-sdk": "^4.2"
"yoti/yoti-php-sdk": "^4.2",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
Expand Down
36 changes: 23 additions & 13 deletions src/DocScan/Request/Check/SandboxCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,38 @@

namespace Yoti\Sandbox\DocScan\Request\Check;

class SandboxCheck implements \JsonSerializable
use JsonSerializable;
use stdClass;
use Yoti\Util\Json;

abstract class SandboxCheck implements JsonSerializable
{
/**
* @var SandboxCheckResult
* @return stdClass
*/
private $result;
public function jsonSerialize(): stdClass
{
return (object) Json::withoutNullValues([
'type' => $this->getType(),
'config' => $this->getConfig()
]);
}

/**
* @param SandboxCheckResult $result
* @return string
*/
public function __construct(SandboxCheckResult $result)
{
$this->result = $result;
}
abstract protected function getType(): string;

/**
* @return SandboxCheckConfigInterface|null
*/
abstract protected function getConfig(): ?SandboxCheckConfigInterface;

/**
* @return \stdClass
* @return string
*/
public function jsonSerialize(): \stdClass
public function __toString(): string
{
return (object) [
'result' => $this->result,
];
return Json::encode($this);
}
}
29 changes: 28 additions & 1 deletion src/DocScan/Request/Check/SandboxDocumentAuthenticityCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@

namespace Yoti\Sandbox\DocScan\Request\Check;

class SandboxDocumentAuthenticityCheck extends SandboxDocumentCheck
use Yoti\Sandbox\DocScan\SandboxConstants;

class SandboxDocumentAuthenticityCheck extends SandboxCheck
{
/**
* @var SandboxDocumentAuthenticityCheckConfig|null
*/
private $config;

public function __construct(?SandboxDocumentAuthenticityCheckConfig $config = null)
{
$this->config = $config;
}

/**
* @inheritDoc
*/
public function getType(): string
{
return SandboxConstants::ID_DOCUMENT_AUTHENTICITY;
}

/**
* @inheritDoc
*/
public function getConfig(): ?SandboxCheckConfigInterface
{
return $this->config;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,51 @@

namespace Yoti\Sandbox\DocScan\Request\Check;

class SandboxDocumentAuthenticityCheckBuilder extends SandboxDocumentCheckBuilder
use Yoti\Sandbox\DocScan\Request\Filters\SandboxDocumentFilter;
use Yoti\Sandbox\DocScan\Request\Traits\Builder\SandboxManualCheckTrait;

class SandboxDocumentAuthenticityCheckBuilder
{
use SandboxManualCheckTrait;

/**
* @var SandboxIssuingAuthoritySubCheck|null
*/
private $issuingAuthoritySubCheck;

/**
* @return $this
*/
public function withIssuingAuthoritySubCheck(): SandboxDocumentAuthenticityCheckBuilder
{
$this->issuingAuthoritySubCheck = (new SandboxIssuingAuthoritySubCheckBuilder())
->withRequested(true)
->build();

return $this;
}

/**
* @param SandboxDocumentFilter $filter
* @return $this
*/
public function withIssuingAuthoritySubCheckAndDocumentFilter(
SandboxDocumentFilter $filter
): SandboxDocumentAuthenticityCheckBuilder {
$this->issuingAuthoritySubCheck = (new SandboxIssuingAuthoritySubCheckBuilder())
->withRequested(true)
->withDocumentFilter($filter)
->build();

return $this;
}

/**
* @return SandboxDocumentAuthenticityCheck
*/
public function build(): SandboxCheck
public function build(): SandboxDocumentAuthenticityCheck
{
$result = new SandboxCheckResult($this->buildReport());
return new SandboxDocumentAuthenticityCheck($result, $this->documentFilter);
$config = new SandboxDocumentAuthenticityCheckConfig($this->manualCheck, $this->issuingAuthoritySubCheck);
return new SandboxDocumentAuthenticityCheck($config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@

declare(strict_types=1);

namespace Yoti\DocScan\Session\Create\Check;
namespace Yoti\Sandbox\DocScan\Request\Check;

use stdClass;
use Yoti\Util\Json;

class RequestedDocumentAuthenticityCheckConfig implements RequestedCheckConfigInterface
class SandboxDocumentAuthenticityCheckConfig implements SandboxCheckConfigInterface
{
/**
* @var string|null
*/
private $manualCheck;

/**
* @var IssuingAuthoritySubCheck|null
* @var SandboxIssuingAuthoritySubCheck|null
*/
private $issuingAuthoritySubCheck;

/**
* @param string|null $manualCheck
* @param IssuingAuthoritySubCheck|null $issuingAuthoritySubCheck
* @param SandboxIssuingAuthoritySubCheck|null $issuingAuthoritySubCheck
*/
public function __construct(?string $manualCheck, ?IssuingAuthoritySubCheck $issuingAuthoritySubCheck = null)
public function __construct(?string $manualCheck, ?SandboxIssuingAuthoritySubCheck $issuingAuthoritySubCheck = null)
{
$this->manualCheck = $manualCheck;
$this->issuingAuthoritySubCheck = $issuingAuthoritySubCheck;
Expand All @@ -49,9 +49,9 @@ public function getManualCheck(): ?string
}

/**
* @return IssuingAuthoritySubCheck|null
* @return SandboxIssuingAuthoritySubCheck|null
*/
public function getIssuingAuthoritySubCheck(): ?IssuingAuthoritySubCheck
public function getIssuingAuthoritySubCheck(): ?SandboxIssuingAuthoritySubCheck
{
return $this->issuingAuthoritySubCheck;
}
Expand Down
29 changes: 28 additions & 1 deletion src/DocScan/Request/Check/SandboxDocumentFaceMatchCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@

namespace Yoti\Sandbox\DocScan\Request\Check;

class SandboxDocumentFaceMatchCheck extends SandboxDocumentCheck
use Yoti\Sandbox\DocScan\SandboxConstants;

class SandboxDocumentFaceMatchCheck extends SandboxCheck
{
/**
* @var SandboxDocumentFaceMatchCheckConfig
*/
private $config;

public function __construct(SandboxDocumentFaceMatchCheckConfig $config)
{
$this->config = $config;
}

/**
* @inheritDoc
*/
protected function getType(): string
{
return SandboxConstants::ID_DOCUMENT_FACE_MATCH;
}

/**
* @inheritDoc
*/
protected function getConfig(): ?SandboxCheckConfigInterface
{
return $this->config;
}
}
18 changes: 11 additions & 7 deletions src/DocScan/Request/Check/SandboxDocumentFaceMatchCheckBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

namespace Yoti\Sandbox\DocScan\Request\Check;

class SandboxDocumentFaceMatchCheckBuilder extends SandboxDocumentCheckBuilder
use Yoti\Sandbox\DocScan\Request\Traits\Builder\SandboxManualCheckTrait;
use Yoti\Util\Validation;

class SandboxDocumentFaceMatchCheckBuilder
{
/**
* @return SandboxDocumentFaceMatchCheck
*/
public function build(): SandboxCheck
use SandboxManualCheckTrait;

public function build(): SandboxDocumentFaceMatchCheck
{
$result = new SandboxCheckResult($this->buildReport());
return new SandboxDocumentFaceMatchCheck($result, $this->documentFilter);
Validation::notEmptyString($this->manualCheck, 'manualCheck');

$config = new SandboxDocumentFaceMatchCheckConfig($this->manualCheck);
return new SandboxDocumentFaceMatchCheck($config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
namespace Yoti\Sandbox\DocScan\Request\Check;

use stdClass;
use Yoti\DocScan\Session\Create\Check\RequestedCheckConfigInterface;

class SandboxFaceMatchCheckConfig implements RequestedCheckConfigInterface
class SandboxDocumentFaceMatchCheckConfig implements SandboxCheckConfigInterface
{
/**
* @var string
Expand Down
30 changes: 8 additions & 22 deletions src/DocScan/Request/Check/SandboxIdDocumentComparisonCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,23 @@

namespace Yoti\Sandbox\DocScan\Request\Check;

use Yoti\Sandbox\DocScan\Request\SandboxDocumentFilter;
use Yoti\Sandbox\DocScan\SandboxConstants;

class SandboxIdDocumentComparisonCheck extends SandboxCheck implements \JsonSerializable
class SandboxIdDocumentComparisonCheck extends SandboxCheck
{
/**
* @var SandboxDocumentFilter|null
* @inheritDoc
*/
private $secondaryDocumentFilter;

/**
* @param SandboxCheckResult $result
* @param SandboxDocumentFilter|null $secondaryDocumentFilter
*/
public function __construct(SandboxCheckResult $result, ?SandboxDocumentFilter $secondaryDocumentFilter)
protected function getType(): string
{
parent::__construct($result);

$this->secondaryDocumentFilter = $secondaryDocumentFilter;
return SandboxConstants::ID_DOCUMENT_COMPARISON;
}

/**
* @return \stdClass
* @inheritDoc
*/
public function jsonSerialize(): \stdClass
protected function getConfig(): ?SandboxCheckConfigInterface
{
$jsonData = parent::jsonSerialize();

if (isset($this->secondaryDocumentFilter)) {
$jsonData->secondary_document_filter = $this->secondaryDocumentFilter;
}

return $jsonData;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,10 @@

namespace Yoti\Sandbox\DocScan\Request\Check;

use Yoti\Sandbox\DocScan\Request\SandboxDocumentFilter;

class SandboxIdDocumentComparisonCheckBuilder extends SandboxCheckBuilder
{
/**
* @var SandboxDocumentFilter
*/
private $secondaryDocumentFilter;

/**
* @param SandboxDocumentFilter $secondaryDocumentFilter
*
* @return $this
*/
public function withSecondaryDocumentFilter(SandboxDocumentFilter $secondaryDocumentFilter): self
{
$this->secondaryDocumentFilter = $secondaryDocumentFilter;
return $this;
}

/**
* @return SandboxIdDocumentComparisonCheck
*/
public function build(): SandboxCheck
public function build(): SandboxIdDocumentComparisonCheck
{
$result = new SandboxCheckResult($this->buildReport());
return new SandboxIdDocumentComparisonCheck($result, $this->secondaryDocumentFilter);
return new SandboxIdDocumentComparisonCheck();
}
}
Loading

0 comments on commit 14003c5

Please sign in to comment.