1 | <?php |
||
5 | class RocketChatMessage |
||
6 | { |
||
7 | /** |
||
8 | * RocketChat channel id. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | public $channel = ''; |
||
13 | |||
14 | /** |
||
15 | * A user or app access token. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | public $from = ''; |
||
20 | |||
21 | /** |
||
22 | * The text content of the message. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | public $content = ''; |
||
27 | |||
28 | /** |
||
29 | * The alias name of the message. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | public $alias = ''; |
||
34 | |||
35 | /** |
||
36 | * The avatar emoji of the message. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | public $emoji = ''; |
||
41 | |||
42 | /** |
||
43 | * The avatar image of the message. |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | public $avatar = ''; |
||
48 | |||
49 | /** |
||
50 | * Attachments of the message. |
||
51 | * |
||
52 | * @var RocketChatAttachment[] |
||
53 | */ |
||
54 | public $attachments = []; |
||
55 | |||
56 | /** |
||
57 | * Create a new instance of RocketChatMessage. |
||
58 | * |
||
59 | * @param string $content |
||
60 | * @return static |
||
61 | */ |
||
62 | 5 | public static function create($content = ''): self |
|
66 | |||
67 | /** |
||
68 | * Create a new instance of RocketChatMessage. |
||
69 | * |
||
70 | * @param string $content |
||
71 | */ |
||
72 | 16 | public function __construct($content = '') |
|
76 | |||
77 | /** |
||
78 | * Set the sender's access token. |
||
79 | * |
||
80 | * @param string $accessToken |
||
81 | * @return $this |
||
82 | */ |
||
83 | 4 | public function from($accessToken): self |
|
89 | |||
90 | /** |
||
91 | * Set the RocketChat channel the message should be sent to. |
||
92 | * |
||
93 | * @param string $channel |
||
94 | * @return $this |
||
95 | */ |
||
96 | 4 | public function to($channel): self |
|
102 | |||
103 | /** |
||
104 | * Set the sender's alias. |
||
105 | * |
||
106 | * @param string $alias |
||
107 | * @return $this |
||
108 | */ |
||
109 | 1 | public function alias(string $alias): self |
|
115 | |||
116 | /** |
||
117 | * Set the sender's emoji. |
||
118 | * |
||
119 | * @param string $emoji |
||
120 | * @return $this |
||
121 | */ |
||
122 | 1 | public function emoji(string $emoji): self |
|
128 | |||
129 | /** |
||
130 | * Set the sender's avatar. |
||
131 | * |
||
132 | * @param string $avatar |
||
133 | * @return $this |
||
134 | */ |
||
135 | 1 | public function avatar(string $avatar): self |
|
141 | |||
142 | /** |
||
143 | * Set the content of the RocketChat message. Supports GitHub flavoured markdown. |
||
144 | * |
||
145 | * @param string $content |
||
146 | * @return $this |
||
147 | */ |
||
148 | 16 | public function content($content): self |
|
154 | |||
155 | /** |
||
156 | * Add an attachment to the message. |
||
157 | * |
||
158 | * @param array|RocketChatAttachment $attachment |
||
159 | * |
||
160 | * @return $this |
||
161 | */ |
||
162 | 4 | public function attachment($attachment): self |
|
172 | |||
173 | /** |
||
174 | * Add multiple attachments to the message. |
||
175 | * |
||
176 | * @param array $attachments |
||
177 | * @return $this |
||
178 | */ |
||
179 | 2 | public function attachments(array $attachments): self |
|
187 | |||
188 | /** |
||
189 | * clear all attachments. |
||
190 | * |
||
191 | * @return $this |
||
192 | */ |
||
193 | 1 | public function clearAttachments(): self |
|
199 | |||
200 | /** |
||
201 | * Get an array representation of the RocketChatMessage. |
||
202 | * |
||
203 | * @return array |
||
204 | */ |
||
205 | 2 | public function toArray(): array |
|
223 | } |
||
224 |