5
5
use Calchen \LaravelDingtalkRobot \Exception \InvalidConfigurationException ;
6
6
7
7
/**
8
- * ActionCard类型,包含整体跳转和独立跳转
8
+ * ActionCard类型,包含整体跳转和独立跳转.
9
9
*
10
10
* Class DingtalkActionCardMessage
11
- * @package Calchen\LaravelDingtalkRobot
12
11
*/
13
12
class ActionCardMessage extends Message
14
13
{
@@ -32,19 +31,19 @@ public function __construct(string $title, string $text, int $hideAvatar = 0, in
32
31
*/
33
32
const HIDE_AVATAR_VALUES = [
34
33
0 , // 按钮竖直排列
35
- 1 // 按钮横向排列
34
+ 1 , // 按钮横向排列
36
35
];
37
36
38
37
/**
39
38
* btnOrientation 的值
40
39
*/
41
40
const BTN_ORIENTATION_VALUES = [
42
41
0 , // 正常发消息者头像
43
- 1 // 隐藏发消息者头像
42
+ 1 , // 隐藏发消息者头像
44
43
];
45
44
46
45
/**
47
- * ActionCard 的整体跳转和独立跳转两种类型中 title text hideAvatar btnOrientation 都是共同拥有的
46
+ * ActionCard 的整体跳转和独立跳转两种类型中 title text hideAvatar btnOrientation 都是共同拥有的.
48
47
*
49
48
* @param string $title 首屏会话透出的展示内容
50
49
* @param string $text markdown 格式的消息
@@ -56,25 +55,25 @@ public function __construct(string $title, string $text, int $hideAvatar = 0, in
56
55
public function setMessage (string $ title , string $ text , int $ hideAvatar = 0 , int $ btnOrientation = 0 ): void
57
56
{
58
57
if (array_search ($ hideAvatar , self ::HIDE_AVATAR_VALUES ) === false ) {
59
- throw new InvalidConfigurationException (" hideAvatar value can only be 0 or 1 " );
58
+ throw new InvalidConfigurationException (' hideAvatar value can only be 0 or 1 ' );
60
59
}
61
60
if (array_search ($ btnOrientation , self ::BTN_ORIENTATION_VALUES ) === false ) {
62
- throw new InvalidConfigurationException (" btnOrientation value can only be 0 or 1 " );
61
+ throw new InvalidConfigurationException (' btnOrientation value can only be 0 or 1 ' );
63
62
}
64
63
65
64
$ this ->message = [
66
- 'msgtype ' => 'actionCard ' ,
65
+ 'msgtype ' => 'actionCard ' ,
67
66
'actionCard ' => [
68
- 'title ' => $ title ,
69
- 'text ' => $ text ,
70
- 'hideAvatar ' => $ hideAvatar ,
71
- 'btnOrientation ' => $ btnOrientation
72
- ]
67
+ 'title ' => $ title ,
68
+ 'text ' => $ text ,
69
+ 'hideAvatar ' => $ hideAvatar ,
70
+ 'btnOrientation ' => $ btnOrientation,
71
+ ],
73
72
];
74
73
}
75
74
76
75
/**
77
- * 设置整体跳转类型参数
76
+ * 设置整体跳转类型参数.
78
77
*
79
78
* @param string $singleTitle 单个按钮的方案。(设置此项和singleURL后btns无效。)
80
79
* @param string $singleUrl 点击singleTitle按钮触发的URL
@@ -85,11 +84,12 @@ public function setSingle(string $singleTitle, string $singleUrl): self
85
84
{
86
85
$ this ->message ['actionCard ' ]['singleTitle ' ] = $ singleTitle ;
87
86
$ this ->message ['actionCard ' ]['singleURL ' ] = $ singleUrl ;
87
+
88
88
return $ this ;
89
89
}
90
90
91
91
/**
92
- * 设置独立跳转类型按钮参数
92
+ * 设置独立跳转类型按钮参数.
93
93
*
94
94
* @param string $title 按钮方案
95
95
* @param string $actionUrl 点击按钮触发的URL
@@ -99,9 +99,10 @@ public function setSingle(string $singleTitle, string $singleUrl): self
99
99
public function addButton (string $ title , string $ actionUrl ): self
100
100
{
101
101
$ this ->message ['actionCard ' ]['btns ' ][] = [
102
- 'title ' => $ title ,
103
- 'actionURL ' => $ actionUrl
102
+ 'title ' => $ title ,
103
+ 'actionURL ' => $ actionUrl,
104
104
];
105
+
105
106
return $ this ;
106
107
}
107
- }
108
+ }
0 commit comments