Skip to content

Commit

Permalink
SDK-2357 Update error reason to match api model
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed Jun 21, 2024
1 parent 1033647 commit 067f855
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ coverage
.scannerwork

.DS_Store
.php-cs-fixer.cache
2 changes: 1 addition & 1 deletion .php-cs-fixer.cache

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/Identity/ErrorReason.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Yoti\Identity;

class ErrorReason
{
/**
* @var RequirementNotMetDetails
*/
private $requirementNotMetDetails;


/**
* @param RequirementNotMetDetails $data
*/
public function __construct(RequirementNotMetDetails $data)
{
$this->requirementNotMetDetails = $data;
}

/**
* @return RequirementNotMetDetails
*/
public function getRequirementNotMetDetails(): RequirementNotMetDetails
{
return $this->requirementNotMetDetails;
}
}
6 changes: 3 additions & 3 deletions src/Identity/Receipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Receipt
private ?string $rememberMeId;
private ?string $parentRememberMeId;
private ?string $error;
private ?string $errorReason;
private ?ErrorReason $errorReason;

public function __construct(
string $id,
Expand All @@ -28,7 +28,7 @@ public function __construct(
?string $rememberMeId,
?string $parentRememberMeId,
?string $error,
?string $errorReason
?ErrorReason $errorReason
) {
$this->id = $id;
$this->sessionId = $sessionId;
Expand Down Expand Up @@ -91,7 +91,7 @@ public function getError(): ?string
return $this->error;
}

public function getErrorReason(): ?string
public function getErrorReason(): ?ErrorReason
{
return $this->errorReason;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Identity/ReceiptBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ReceiptBuilder
private ?string $parentRememberMeId = null;

private ?string $error = null;
private ?string $errorReason = null;
private ?ErrorReason $errorReason = null;


public function withId(string $id): self
Expand Down Expand Up @@ -84,7 +84,7 @@ public function withError(string $error = null): self
return $this;
}

public function withErrorReason(string $errorReason = null): self
public function withErrorReason(ErrorReason $errorReason = null): self
{
$this->errorReason = $errorReason;

Expand Down
75 changes: 75 additions & 0 deletions src/Identity/RequirementNotMetDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace Yoti\Identity;

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

/**
* @param array<int, array<string, string>> $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;
}
}
4 changes: 2 additions & 2 deletions src/Identity/WrappedReceipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class WrappedReceipt
private ?string $parentRememberMeId = null;

private ?string $error = null;
private ?string $errorReason = null;
private ?ErrorReason $errorReason = null;

/**
* @param array<string, mixed> $sessionData
Expand Down Expand Up @@ -136,7 +136,7 @@ public function getError(): ?string
return $this->error;
}

public function getErrorReason(): ?string
public function getErrorReason(): ?ErrorReason
{
return $this->errorReason;
}
Expand Down
5 changes: 3 additions & 2 deletions tests/Identity/ReceiptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Yoti\Identity\Content\ApplicationContent;
use Yoti\Identity\Content\UserContent;
use Yoti\Identity\ErrorReason;
use Yoti\Identity\Receipt;
use Yoti\Identity\ReceiptBuilder;
use Yoti\Profile\ApplicationProfile;
Expand Down Expand Up @@ -39,7 +40,7 @@ public function testShouldBuildCorrectly()
$rememberId = 'SOME_REMEMBER_ID';
$parentRememberId = 'SOME_PARENT_REMEMBER_ID';
$someError = 'SOME_ERROR';
$someErrorReason = 'SOME_ERROR_REASON';
$someErrorReason = $this->createMock(ErrorReason::class);

$receipt = new Receipt(
$someId,
Expand Down Expand Up @@ -86,7 +87,7 @@ public function testShouldBuildCorrectlyThroughBuilder()
$rememberId = 'SOME_REMEMBER_ID';
$parentRememberId = 'SOME_PARENT_REMEMBER_ID';
$someError = 'SOME_ERROR';
$someErrorReason = 'SOME_ERROR_REASON';
$someErrorReason = $this->createMock(ErrorReason::class);

$receipt = (new ReceiptBuilder())
->withId($someId)
Expand Down

0 comments on commit 067f855

Please sign in to comment.