1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DingRobot\Message; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* ActionCard |
7
|
|
|
* |
8
|
|
|
* @method ActionCard title($title) |
9
|
|
|
* @method ActionCard text($markdownText) |
10
|
|
|
* @method ActionCard singleURL($singleUrl) |
11
|
|
|
* @method ActionCard singleTitle($singleTitle) |
12
|
|
|
* |
13
|
|
|
* @package DingRobot\Message |
14
|
|
|
*/ |
15
|
|
|
class ActionCard extends Base |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* 隐藏发消息者头像 |
19
|
|
|
* hide sender avatar |
20
|
|
|
*/ |
21
|
|
|
const AVATAR_HIDE = '1'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* 显示发消息者头像 |
25
|
|
|
* show sender avatar |
26
|
|
|
*/ |
27
|
|
|
const AVATAR_SHOW = '0'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* 按钮横向排列 |
31
|
|
|
*/ |
32
|
|
|
const BTN_ORIENTATION_HORIZONTAL = '1'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* 按钮竖直排列 |
36
|
|
|
*/ |
37
|
|
|
const BTN_ORIENTATION_VERTICAL = '0'; |
38
|
|
|
|
39
|
4 |
|
public function __construct($title = '') |
40
|
|
|
{ |
41
|
4 |
|
parent::__construct(); |
42
|
4 |
|
$this->title($title); |
43
|
4 |
|
$this->bodyName = 'actionCard'; |
44
|
4 |
|
} |
45
|
|
|
|
46
|
2 |
|
protected function getBody() |
47
|
|
|
{ |
48
|
2 |
|
return $this->body; |
49
|
|
|
} |
50
|
|
|
|
51
|
4 |
|
protected function bodyFields() |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
4 |
|
'title' => ['required' => true, 'type' => 'string'], |
55
|
|
|
'text' => ['required' => true, 'type' => 'string'], |
56
|
|
|
'singleURL' => ['required' => true, 'type' => 'string'], |
57
|
|
|
'singleTitle' => ['required' => true, 'type' => 'string'] |
58
|
|
|
]; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* hide sender avatar |
63
|
|
|
* 隐藏发送者头像 |
64
|
|
|
* |
65
|
|
|
* @return $this |
66
|
|
|
*/ |
67
|
2 |
|
public function hideAvatar() |
68
|
|
|
{ |
69
|
2 |
|
$this->body['hideAvatar'] = self::AVATAR_HIDE; |
70
|
|
|
|
71
|
2 |
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* show sender avatar |
76
|
|
|
* 显示发送者头像 |
77
|
|
|
* |
78
|
|
|
* @return $this |
79
|
|
|
*/ |
80
|
2 |
|
public function showAvatar() |
81
|
|
|
{ |
82
|
2 |
|
$this->body['hideAvatar'] = self::AVATAR_SHOW; |
83
|
|
|
|
84
|
2 |
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* 设置按钮横向排列 |
89
|
|
|
* set button as horizontal |
90
|
|
|
* |
91
|
|
|
* @return $this |
92
|
|
|
*/ |
93
|
2 |
|
public function btnOrientationHorizontal() |
94
|
|
|
{ |
95
|
2 |
|
$this->body['btnOrientation'] = self::BTN_ORIENTATION_HORIZONTAL; |
96
|
|
|
|
97
|
2 |
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* 设置按钮纵向排列 |
102
|
|
|
* set button as vertical |
103
|
|
|
* |
104
|
|
|
* @return $this |
105
|
|
|
*/ |
106
|
2 |
|
public function btnOrientationVertical() |
107
|
|
|
{ |
108
|
2 |
|
$this->body['btnOrientation'] = self::BTN_ORIENTATION_VERTICAL; |
109
|
|
|
|
110
|
2 |
|
return $this; |
111
|
|
|
} |
112
|
|
|
} |