|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Request\Request\APL; |
|
6
|
|
|
|
|
7
|
|
|
use MaxBeckers\AmazonAlexa\Helper\PropertyHelper; |
|
8
|
|
|
|
|
9
|
|
|
class RuntimeError |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @param RuntimeErrorType|null $type Error type |
|
13
|
|
|
* @param string|null $reason Error reason |
|
14
|
|
|
* @param string|null $listId List identifier where error occurred |
|
15
|
|
|
* @param int|null $listVersion List version when error occurred |
|
16
|
|
|
* @param int|null $operationIndex Index of the operation that caused the error |
|
17
|
|
|
* @param string|null $message Error message |
|
18
|
|
|
*/ |
|
19
|
2 |
|
public function __construct( |
|
20
|
|
|
public ?RuntimeErrorType $type = null, |
|
21
|
|
|
public ?string $reason = null, |
|
22
|
|
|
public ?string $listId = null, |
|
23
|
|
|
public ?int $listVersion = null, |
|
24
|
|
|
public ?int $operationIndex = null, |
|
25
|
|
|
public ?string $message = null, |
|
26
|
|
|
) { |
|
27
|
2 |
|
} |
|
28
|
|
|
|
|
29
|
2 |
|
public static function fromAmazonRequest(array $amazonRequest): self |
|
30
|
|
|
{ |
|
31
|
2 |
|
return new self( |
|
32
|
2 |
|
type: isset($amazonRequest['type']) ? RuntimeErrorType::tryFrom($amazonRequest['type']) : null, |
|
33
|
2 |
|
reason: PropertyHelper::checkNullValueString($amazonRequest, 'reason'), |
|
34
|
2 |
|
listId: PropertyHelper::checkNullValueString($amazonRequest, 'listId'), |
|
35
|
2 |
|
listVersion: PropertyHelper::checkNullValueInt($amazonRequest, 'listVersion'), |
|
36
|
2 |
|
operationIndex: PropertyHelper::checkNullValueInt($amazonRequest, 'operationIndex'), |
|
37
|
2 |
|
message: PropertyHelper::checkNullValueString($amazonRequest, 'message'), |
|
38
|
2 |
|
); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
|