Skip to content

Commit

Permalink
SDK-2377 added failure reasons to idv
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed Jun 20, 2024
1 parent 5ad4d8b commit 6748e2d
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.cache

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,30 @@ class FailureReasonResponse
/**
* @var string
*/
private $stringCode;

private $reasonCode;
/**
* @param string $stringCode
* @var RequirementNotMetDetails
*/
public function __construct(string $stringCode)
private $requirementsNotMetDetails;
public function __construct(array $data)
{
$this->stringCode = $stringCode;
$this->reasonCode = $data["reason_code"];
$this->requirementsNotMetDetails = new RequirementNotMetDetails($data["requirements_not_met_details"]);
}

/**
* @return string
*/
public function getStringCode(): string
public function getReasonCode(): string
{
return $this->reasonCode;
}
/**
* @return RequirementNotMetDetails
*/
public function getRequirementNotMetDetails(): RequirementNotMetDetails
{
return $this->stringCode;
return $this->requirementsNotMetDetails;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace Yoti\DocScan\Session\Retrieve\IdentityProfile;

class RequirementNotMetDetails
{
/**
* @var string
*/
private $failureType;
/**
* @var string
*/
private $documentType;
/**
* @var string
*/
private $documentCountryIsoCode;
/**
* @var string
*/
private $auditId;
/**
* @var string
*/
private $details;

/**
* @param array $data
*/
public function __construct(array $data)
{
$this->failureType = $data[0]["failure_type"];
$this->details = $data[0]["details"];
$this->auditId = $data[0]["audit_id"];
$this->documentCountryIsoCode = $data[0]["document_country_iso_code"];
$this->documentType = $data[0]["document_type"];
}

/**
* @return string
*/
public function getFailureType(): string
{
return $this->failureType;
}
/**
* @return string
*/
public function getDetails(): string
{
return $this->details;
}
/**
* @return string
*/
public function getAuditId(): string
{
return $this->auditId;
}
/**
* @return string
*/
public function getDocumentCountryIsoCode(): string
{
return $this->documentCountryIsoCode;
}
/**
* @return string
*/
public function getDocumentType(): string
{
return $this->documentType;
}

}
2 changes: 1 addition & 1 deletion src/DocScan/Session/Retrieve/IdentityProfileResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(array $sessionData)
$this->result = $sessionData['result'];

if (isset($sessionData['failure_reason'])) {
$this->failureReason = new FailureReasonResponse($sessionData['failure_reason']['reason_code']);
$this->failureReason = new FailureReasonResponse($sessionData['failure_reason']);
}

if (isset($sessionData['identity_profile_report'])) {
Expand Down
2 changes: 1 addition & 1 deletion tests/DocScan/DocScanClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public function testParseIdentityProfileResponse()
$this->assertEquals('someStringHere', $sessionResult->getIdentityProfile()->getSubjectId());
$this->assertEquals(
'MANDATORY_DOCUMENT_COULD_NOT_BE_PROVIDED',
$sessionResult->getIdentityProfile()->getFailureReason()->getStringCode()
$sessionResult->getIdentityProfile()->getFailureReason()->getReasonCode()
);

$this->assertEquals(
Expand Down
10 changes: 10 additions & 0 deletions tests/DocScan/Session/Retrieve/GetSessionResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ class GetSessionResultTest extends TestCase
'result' => 'SOME_ANOTHER_STRING',
'failure_reason' => [
'reason_code' => 'ANOTHER_STRING',
'requirements_not_met_details' => [
0 => [
'failure_type' => 'ANOTHER_STRING',
'document_type' => 'ANOTHER_STRING',
'document_country_iso_code' => 'ANOTHER_STRING',
'audit_id' => 'ANOTHER_STRING',
'details' => 'ANOTHER_STRING'
]

]
],
'identity_profile_report' => [],
];
Expand Down
22 changes: 19 additions & 3 deletions tests/DocScan/Session/Retrieve/IdentityProfileResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class IdentityProfileResponseTest extends TestCase
{
private const RESULT = 'DONE';
private const SUBJECT_ID = 'someStringHere';
private const FAILURE_TYPE = 'someStringHere';
private const DOCUMENT_TYPE = 'someStringHere';
private const DOCUMENT_COUNTRY_ISO_CODE = 'someStringHere';
private const AUDIT_ID = 'someStringHere';
private const DETAILS = 'someStringHere';
private const REASON_CODE = 'MANDATORY_DOCUMENT_COULD_NOT_BE_PROVIDED';
private const IDENTITY_PROFILE_REPORT = [
'trust_framework' => 'UK_TFIDA',
Expand Down Expand Up @@ -47,17 +52,28 @@ public function shouldCreatedCorrectly(): void
'result' => self::RESULT,
'failure_reason' => [
'reason_code' => self::REASON_CODE,
'requirements_not_met_details' => [
0 => [
'failure_type' => self::FAILURE_TYPE,
'document_type' => self::DOCUMENT_TYPE,
'document_country_iso_code' => self::DOCUMENT_COUNTRY_ISO_CODE,
'audit_id' => self::AUDIT_ID,
'details' => self::DETAILS
]
]
],
'identity_profile_report' => self::IDENTITY_PROFILE_REPORT,
];

$result = new IdentityProfileResponse($testData);

$this->assertEquals(self::RESULT, $result->getResult());
$this->assertEquals(self::SUBJECT_ID, $result->getSubjectId());
$this->assertEquals((object)self::IDENTITY_PROFILE_REPORT, $result->getIdentityProfileReport());

$this->assertInstanceOf(FailureReasonResponse::class, $result->getFailureReason());
$this->assertEquals(self::REASON_CODE, $result->getFailureReason()->getStringCode());
$this->assertEquals(self::REASON_CODE, $result->getFailureReason()->getReasonCode());
$this->assertEquals(self::FAILURE_TYPE, $result->getFailureReason()->getRequirementNotMetDetails()->getFailureType());
//$this->assertEquals(self::DOCUMENT_TYPE, $result->getFailureReason()->getRequirementNotMetDetails()->getDocumentType());
//$this->assertEquals(self::AUDIT_ID, $result->getFailureReason()->getRequirementNotMetDetails()->getAuditId());
//$this->assertEquals(self::DETAILS, $result->getFailureReason()->getRequirementNotMetDetails()->getDetails());
}
}
13 changes: 11 additions & 2 deletions tests/sample-data/sessionResultIdentityProfileResult.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
"subject_id": "someStringHere",
"result": "DONE",
"failure_reason": {
"reason_code": "MANDATORY_DOCUMENT_COULD_NOT_BE_PROVIDED"
"reason_code": "MANDATORY_DOCUMENT_COULD_NOT_BE_PROVIDED",
"requirements_not_met_details": [
{
"failure_type": "someStringHere",
"document_type": "someStringHere",
"document_country_iso_code": "someStringHere",
"audit_id": "someStringHere",
"details": "someStringHere"
}
]
},
"identity_profile_report": {
"trust_framework": "UK_TFIDA",
Expand All @@ -31,4 +40,4 @@
}
}
}
}
}

0 comments on commit 6748e2d

Please sign in to comment.