1
|
|
|
<?php |
2
|
|
|
namespace Kerox\Messenger\Model\Message\Attachment\Template\Element; |
3
|
|
|
|
4
|
|
|
use Kerox\Messenger\Model\Common\Buttons\WebUrl; |
5
|
|
|
|
6
|
|
|
class ListeElement extends AbstractElement |
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @var \Kerox\Messenger\Model\Common\Buttons\WebUrl |
11
|
|
|
*/ |
12
|
|
|
protected $defaultAction; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var \Kerox\Messenger\Model\Common\Buttons\AbstractButtons[] |
16
|
|
|
*/ |
17
|
|
|
protected $buttons = []; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* ListeElement constructor. |
21
|
|
|
* |
22
|
|
|
* @param string $title |
23
|
|
|
*/ |
24
|
|
|
public function __construct(string $title) |
25
|
|
|
{ |
26
|
|
|
parent::__construct($title); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param string $subtitle |
31
|
|
|
* @return \Kerox\Messenger\Model\Message\Attachment\Template\Element\ListeElement |
32
|
|
|
*/ |
33
|
|
|
public function setSubtitle(string $subtitle): ListeElement |
34
|
|
|
{ |
35
|
|
|
parent::setSubtitle($subtitle); |
36
|
|
|
|
37
|
|
|
return $this; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $imageUrl |
42
|
|
|
* @return \Kerox\Messenger\Model\Message\Attachment\Template\Element\ListeElement |
43
|
|
|
*/ |
44
|
|
|
public function setImageUrl(string $imageUrl): ListeElement |
45
|
|
|
{ |
46
|
|
|
parent::setImageUrl($imageUrl); |
47
|
|
|
|
48
|
|
|
return $this; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param \Kerox\Messenger\Model\Common\Buttons\WebUrl $defaultAction |
53
|
|
|
* @return \Kerox\Messenger\Model\Message\Attachment\Template\Element\ListeElement |
54
|
|
|
*/ |
55
|
|
|
public function setDefaultAction(WebUrl $defaultAction): ListeElement |
56
|
|
|
{ |
57
|
|
|
$this->defaultAction = $defaultAction; |
58
|
|
|
|
59
|
|
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param \Kerox\Messenger\Model\Common\Buttons\AbstractButtons[] $buttons |
64
|
|
|
* @return ListeElement |
65
|
|
|
*/ |
66
|
|
|
public function setButtons(array $buttons): ListeElement |
67
|
|
|
{ |
68
|
|
|
$this->isValidArray($buttons, 1); |
69
|
|
|
$this->buttons = $buttons; |
70
|
|
|
|
71
|
|
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return array |
76
|
|
|
*/ |
77
|
|
|
public function jsonSerialize(): array |
78
|
|
|
{ |
79
|
|
|
$json = parent::jsonSerialize(); |
80
|
|
|
$json += [ |
81
|
|
|
'subtitle' => $this->subtitle, |
82
|
|
|
'image_url' => $this->imageUrl, |
83
|
|
|
'default_action' => $this->defaultAction, |
84
|
|
|
'buttons' => $this->buttons, |
85
|
|
|
]; |
86
|
|
|
|
87
|
|
|
return array_filter($json); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|