Skip to content

Commit

Permalink
Merge pull request #40 from getyoti/release/1.4.0
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
davidgrayston authored Oct 5, 2020
2 parents 3d5cf20 + efce33b commit dab51a6
Show file tree
Hide file tree
Showing 16 changed files with 527 additions and 84 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yoti/yoti-php-sdk-sandbox",
"description": "Yoti PHP SDK Sandbox",
"version": "1.3.0",
"version": "1.4.0",
"keywords": [
"yoti",
"sdk"
Expand All @@ -12,7 +12,7 @@
"yoti/yoti-php-sdk": "^3.1"
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.2",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
"squizlabs/php_codesniffer": "^3.4",
"friendsofphp/php-cs-fixer": "^2.15",
"brainmaestro/composer-git-hooks": "^2.8",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sonar.organization = getyoti

sonar.projectKey = getyoti:php-sandbox
sonar.projectName = PHP SDK Sandbox
sonar.projectVersion = 1.3.0
sonar.projectVersion = 1.4.0

sonar.language = php
sonar.sources=src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class SandboxDocumentTextDataCheckBuilder extends SandboxDocumentCheckBuilder
{

/**
* @var array<string, mixed>
* @var array<string, mixed>|null
*/
private $documentFields = [];
private $documentFields;

/**
* @param string $key
Expand Down
12 changes: 8 additions & 4 deletions src/DocScan/Request/Check/SandboxDocumentTextDataCheckResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ class SandboxDocumentTextDataCheckResult extends SandboxCheckResult
{

/**
* @var array<string, mixed>
* @var array<string, mixed>|null
*/
private $documentFields;

/**
* @param SandboxCheckReport $report
* @param array<string, mixed> $documentFields
* @param array<string, mixed>|null $documentFields
*/
public function __construct(
SandboxCheckReport $report,
array $documentFields
?array $documentFields
) {
parent::__construct($report);
$this->documentFields = $documentFields;
Expand All @@ -32,7 +32,11 @@ public function __construct(
public function jsonSerialize(): \stdClass
{
$jsonData = parent::jsonSerialize();
$jsonData->document_fields = (object) $this->documentFields;

if ($this->documentFields !== null) {
$jsonData->document_fields = (object) $this->documentFields;
}

return $jsonData;
}
}
40 changes: 40 additions & 0 deletions src/DocScan/Request/Check/SandboxIdDocumentComparisonCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace Yoti\Sandbox\DocScan\Request\Check;

use Yoti\Sandbox\DocScan\Request\SandboxDocumentFilter;

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

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

$this->secondaryDocumentFilter = $secondaryDocumentFilter;
}

/**
* @return \stdClass
*/
public function jsonSerialize(): \stdClass
{
$jsonData = parent::jsonSerialize();

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

return $jsonData;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

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
{
$result = new SandboxCheckResult($this->buildReport());
return new SandboxIdDocumentComparisonCheck($result, $this->secondaryDocumentFilter);
}
}
21 changes: 15 additions & 6 deletions src/DocScan/Request/SandboxCheckReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Yoti\Sandbox\DocScan\Request;

use Yoti\DocScan\Constants;
use Yoti\Sandbox\DocScan\Request\Check\SandboxDocumentAuthenticityCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxDocumentFaceMatchCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxDocumentTextDataCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxIdDocumentComparisonCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxLivenessCheck;
use Yoti\Util\Json;

Expand All @@ -24,6 +24,11 @@ class SandboxCheckReports implements \JsonSerializable
*/
private $documentAuthenticityChecks;

/**
* @var SandboxIdDocumentComparisonCheck[]|null
*/
private $idDocumentComparisonChecks;

/**
* @var SandboxDocumentFaceMatchCheck[]
*/
Expand All @@ -47,19 +52,22 @@ class SandboxCheckReports implements \JsonSerializable
* @param SandboxDocumentFaceMatchCheck[] $documentFaceMatchChecks
* @param SandboxLivenessCheck[] $livenessChecks
* @param int|null $asyncReportDelay
* @param SandboxIdDocumentComparisonCheck[]|null $idDocumentComparisonChecks
*/
public function __construct(
array $documentTextDataChecks,
array $documentAuthenticityChecks,
array $documentFaceMatchChecks,
array $livenessChecks,
?int $asyncReportDelay
?int $asyncReportDelay,
?array $idDocumentComparisonChecks = null
) {
$this->documentTextDataChecks = $documentTextDataChecks;
$this->documentAuthenticityChecks = $documentAuthenticityChecks;
$this->documentFaceMatchChecks = $documentFaceMatchChecks;
$this->livenessChecks = $livenessChecks;
$this->asyncReportDelay = $asyncReportDelay;
$this->idDocumentComparisonChecks = $idDocumentComparisonChecks;
}

/**
Expand All @@ -68,10 +76,11 @@ public function __construct(
public function jsonSerialize(): \stdClass
{
return (object) Json::withoutNullValues([
Constants::ID_DOCUMENT_TEXT_DATA_CHECK => $this->documentTextDataChecks,
Constants::ID_DOCUMENT_AUTHENTICITY => $this->documentAuthenticityChecks,
Constants::ID_DOCUMENT_FACE_MATCH => $this->documentFaceMatchChecks,
Constants::LIVENESS => $this->livenessChecks,
'ID_DOCUMENT_TEXT_DATA_CHECK' => $this->documentTextDataChecks,
'ID_DOCUMENT_AUTHENTICITY' => $this->documentAuthenticityChecks,
'ID_DOCUMENT_FACE_MATCH' => $this->documentFaceMatchChecks,
'ID_DOCUMENT_COMPARISON' => $this->idDocumentComparisonChecks,
'LIVENESS' => $this->livenessChecks,
'async_report_delay' => $this->asyncReportDelay,
]);
}
Expand Down
19 changes: 18 additions & 1 deletion src/DocScan/Request/SandboxCheckReportsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Yoti\Sandbox\DocScan\Request\Check\SandboxDocumentAuthenticityCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxDocumentFaceMatchCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxDocumentTextDataCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxIdDocumentComparisonCheck;
use Yoti\Sandbox\DocScan\Request\Check\SandboxLivenessCheck;

class SandboxCheckReportsBuilder
Expand All @@ -22,6 +23,11 @@ class SandboxCheckReportsBuilder
*/
private $documentAuthenticityChecks = [];

/**
* @var SandboxIdDocumentComparisonCheck[]
*/
private $idDocumentComparisonChecks = [];

/**
* @var SandboxDocumentFaceMatchCheck[]
*/
Expand Down Expand Up @@ -77,6 +83,16 @@ public function withDocumentFaceMatchCheck(SandboxDocumentFaceMatchCheck $docume
return $this;
}

/**
* @param SandboxIdDocumentComparisonCheck $documentComparisonCheck
* @return $this
*/
public function withIdDocumentComparisonCheck(SandboxIdDocumentComparisonCheck $documentComparisonCheck): self
{
$this->idDocumentComparisonChecks[] = $documentComparisonCheck;
return $this;
}

/**
* @param int $asyncReportDelay
* @return $this
Expand All @@ -97,7 +113,8 @@ public function build(): SandboxCheckReports
$this->documentAuthenticityChecks,
$this->documentFaceMatchChecks,
$this->livenessChecks,
$this->asyncReportDelay
$this->asyncReportDelay,
$this->idDocumentComparisonChecks
);
}
}
39 changes: 39 additions & 0 deletions src/DocScan/Request/Task/SandboxDocumentIdPhoto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Yoti\Sandbox\DocScan\Request\Task;

class SandboxDocumentIdPhoto implements \JsonSerializable
{
/**
* @var string
*/
private $contentType;

/**
* @var string
*/
private $data;

/**
* @param string $contentType
* @param string $data
*/
public function __construct(string $contentType, string $data)
{
$this->contentType = $contentType;
$this->data = $data;
}

/**
* @return \stdClass
*/
public function jsonSerialize(): \stdClass
{
return (object) [
'content_type' => $this->contentType,
'data' => base64_encode($this->data),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@

class SandboxDocumentTextDataExtractionTaskBuilder
{

/**
* @var array<string, mixed>
* @var array<string, mixed>|null
*/
private $documentFields = [];
private $documentFields;

/**
* @var SandboxDocumentFilter
*/
private $documentFilter;

/**
* @var SandboxDocumentIdPhoto
*/
private $documentIdPhoto;

/**
* @param string $key
* @param mixed $value
Expand Down Expand Up @@ -51,12 +55,24 @@ public function withDocumentFilter(SandboxDocumentFilter $documentFilter): self
return $this;
}

/**
* @param string $contentType
* @param string $data
*
* @return $this
*/
public function withDocumentIdPhoto(string $contentType, string $data): self
{
$this->documentIdPhoto = new SandboxDocumentIdPhoto($contentType, $data);
return $this;
}

/**
* @return SandboxDocumentTextDataExtractionTask
*/
public function build(): SandboxDocumentTextDataExtractionTask
{
$result = new SandboxDocumentTextDataExtractionTaskResult($this->documentFields);
$result = new SandboxDocumentTextDataExtractionTaskResult($this->documentFields, $this->documentIdPhoto);
return new SandboxDocumentTextDataExtractionTask($result, $this->documentFilter);
}
}
Loading

0 comments on commit dab51a6

Please sign in to comment.