1 | <?php |
||
7 | class RocketChatMessage |
||
8 | { |
||
9 | /** @var string RocketChat channel id. */ |
||
10 | public $channel = ''; |
||
11 | |||
12 | /** @var string A user or app access token. */ |
||
13 | public $from = ''; |
||
14 | |||
15 | /** @var string The text content of the message. */ |
||
16 | public $content = ''; |
||
17 | |||
18 | /** @var string The alias name of the message. */ |
||
19 | public $alias = ''; |
||
20 | |||
21 | /** @var string The avatar emoji of the message. */ |
||
22 | public $emoji = ''; |
||
23 | |||
24 | /** @var string The avatar image of the message. */ |
||
25 | public $avatar = ''; |
||
26 | |||
27 | /** @var \NotificationChannels\RocketChat\RocketChatAttachment[] Attachments of the message. */ |
||
28 | public $attachments = []; |
||
29 | |||
30 | /** |
||
31 | * Create a new instance of RocketChatMessage. |
||
32 | * |
||
33 | * @param string $content |
||
34 | * @return static |
||
35 | */ |
||
36 | 5 | public static function make(string $content = ''): self |
|
37 | { |
||
38 | 5 | return new static($content); |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * Create a new instance of RocketChatMessage. |
||
43 | * |
||
44 | * @param string $content |
||
45 | */ |
||
46 | 16 | public function __construct(string $content = '') |
|
50 | |||
51 | /** |
||
52 | * Set the sender's access token. |
||
53 | * |
||
54 | * @param string $accessToken |
||
55 | * @return $this |
||
56 | */ |
||
57 | 4 | public function from(string $accessToken): self |
|
63 | |||
64 | /** |
||
65 | * Set the RocketChat channel the message should be sent to. |
||
66 | * |
||
67 | * @param string $channel |
||
68 | * @return $this |
||
69 | */ |
||
70 | 4 | public function to(string $channel): self |
|
76 | |||
77 | /** |
||
78 | * Set the sender's alias. |
||
79 | * |
||
80 | * @param string $alias |
||
81 | * @return $this |
||
82 | */ |
||
83 | 1 | public function alias(string $alias): self |
|
89 | |||
90 | /** |
||
91 | * Set the sender's emoji. |
||
92 | * |
||
93 | * @param string $emoji |
||
94 | * @return $this |
||
95 | */ |
||
96 | 1 | public function emoji(string $emoji): self |
|
102 | |||
103 | /** |
||
104 | * Set the sender's avatar. |
||
105 | * |
||
106 | * @param string $avatar |
||
107 | * @return $this |
||
108 | */ |
||
109 | 1 | public function avatar(string $avatar): self |
|
115 | |||
116 | /** |
||
117 | * Set the content of the RocketChat message. |
||
118 | * Supports GitHub flavoured markdown. |
||
119 | * |
||
120 | * @param string $content |
||
121 | * @return $this |
||
122 | */ |
||
123 | 16 | public function content(string $content): self |
|
129 | |||
130 | /** |
||
131 | * Add an attachment to the message. |
||
132 | * |
||
133 | * @param array|\NotificationChannels\RocketChat\RocketChatAttachment $attachment |
||
134 | * @return $this |
||
135 | */ |
||
136 | 4 | public function attachment($attachment): self |
|
146 | |||
147 | /** |
||
148 | * Add multiple attachments to the message. |
||
149 | * |
||
150 | * @param array|\NotificationChannels\RocketChat\RocketChatAttachment[] $attachments |
||
151 | * @return $this |
||
152 | */ |
||
153 | 2 | public function attachments(array $attachments): self |
|
161 | |||
162 | /** |
||
163 | * Clear all attachments. |
||
164 | * |
||
165 | * @return $this |
||
166 | */ |
||
167 | 1 | public function clearAttachments(): self |
|
173 | |||
174 | /** |
||
175 | * Get an array representation of the RocketChatMessage. |
||
176 | * |
||
177 | * @return array |
||
178 | */ |
||
179 | 2 | public function toArray(): array |
|
196 | } |
||
197 |