|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MaxBeckers\AmazonAlexa\Request\Request\APL; |
|
6
|
|
|
|
|
7
|
|
|
use MaxBeckers\AmazonAlexa\Helper\PropertyHelper; |
|
8
|
|
|
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest; |
|
9
|
|
|
|
|
10
|
|
|
class UserEventRequest extends AbstractRequest |
|
11
|
|
|
{ |
|
12
|
|
|
public const TYPE = 'Alexa.Presentation.APL.UserEvent'; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @param string|null $token Token provided with the RenderDocument or ExecuteCommands directive |
|
16
|
|
|
* @param array $arguments Array of values specified in the arguments property of the SendEvent command |
|
17
|
|
|
* @param array|null $source Information about the APL component and event handler that was the source of this event |
|
18
|
|
|
* @param array|null $components Value of each component identified in the components property of the SendEvent command |
|
19
|
|
|
* @param string|null $presentationUri Generated token that identifies the widget (applies to widgets) |
|
20
|
|
|
*/ |
|
21
|
2 |
|
public function __construct( |
|
22
|
|
|
public ?string $token = null, |
|
23
|
|
|
public array $arguments = [], |
|
24
|
|
|
public ?array $source = null, |
|
25
|
|
|
public ?array $components = null, |
|
26
|
|
|
public ?string $presentationUri = null, |
|
27
|
|
|
) { |
|
28
|
2 |
|
parent::__construct(type: self::TYPE); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
2 |
|
public static function fromAmazonRequest(array $amazonRequest): AbstractRequest |
|
32
|
|
|
{ |
|
33
|
2 |
|
return new self( |
|
34
|
2 |
|
token: PropertyHelper::checkNullValueString($amazonRequest, 'token'), |
|
35
|
2 |
|
arguments: $amazonRequest['arguments'] ?? [], |
|
36
|
2 |
|
source: $amazonRequest['source'] ?? null, |
|
37
|
2 |
|
components: $amazonRequest['components'] ?? null, |
|
38
|
2 |
|
presentationUri: PropertyHelper::checkNullValueString($amazonRequest, 'presentationUri'), |
|
39
|
2 |
|
); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function validateTimestamp(): bool |
|
43
|
|
|
{ |
|
44
|
1 |
|
return false; |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|