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