-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathActivityDetailsException.php
More file actions
50 lines (43 loc) · 1.33 KB
/
ActivityDetailsException.php
File metadata and controls
50 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types=1);
namespace Yoti\Exception;
use Psr\Http\Message\ResponseInterface;
use Yoti\Exception\base\YotiException;
use Yoti\Util\Json;
class ActivityDetailsException extends YotiException
{
/**
* @var array<string, mixed>|null
*/
private $responseBody;
/**
* @param string $message
* @param ResponseInterface|null $response
* @param array<string, mixed>|null $responseBody
* @param \Throwable|null $previous
*/
public function __construct(
$message = "",
?ResponseInterface $response = null,
?array $responseBody = null,
?\Throwable $previous = null
) {
parent::__construct($message, $response, $previous);
$this->responseBody = $responseBody;
}
/**
* @return string
*/
public function getReceiptErrorDetails(): string
{
$result = [];
if (!is_null($this->responseBody)) {
$result['receipt_id'] = $this->responseBody['receipt']['receipt_id'] ?? ' ';
if (isset($this->responseBody['error_details'])) {
$result['description'] = $this->responseBody['error_details']['description'] ?? ' ';
$result['error_code'] = $this->responseBody['error_details']['error_code'] ?? ' ';
}
}
return Json::encode($result);
}
}