1 | <?php |
||
7 | class RocketChatMessage |
||
8 | { |
||
9 | /** @var string|null RocketChat channel id. */ |
||
10 | protected $channel = null; |
||
11 | |||
12 | /** @var string|null A user or app access token. */ |
||
13 | protected $from = null; |
||
14 | |||
15 | /** @var string The text content of the message. */ |
||
16 | protected $content; |
||
17 | |||
18 | /** @var string The alias name of the message. */ |
||
19 | protected $alias; |
||
20 | |||
21 | /** @var string The avatar emoji of the message. */ |
||
22 | protected $emoji; |
||
23 | |||
24 | /** @var string The avatar image of the message. */ |
||
25 | protected $avatar; |
||
26 | |||
27 | /** @var \NotificationChannels\RocketChat\RocketChatAttachment[] Attachments of the message. */ |
||
28 | protected $attachments = []; |
||
29 | |||
30 | /** |
||
31 | * Create a new instance of RocketChatMessage. |
||
32 | * |
||
33 | * @param string $content |
||
34 | * @return static |
||
35 | */ |
||
36 | 5 | public static function create(string $content = ''): self |
|
40 | |||
41 | /** |
||
42 | * Create a new instance of RocketChatMessage. |
||
43 | * |
||
44 | * @param string $content |
||
45 | */ |
||
46 | 15 | public function __construct(string $content = '') |
|
50 | |||
51 | 5 | public function getChannel(): ?string |
|
55 | |||
56 | 5 | public function getFrom(): ?string |
|
60 | |||
61 | /** |
||
62 | * Set the sender's access token. |
||
63 | * |
||
64 | * @param string $accessToken |
||
65 | * @return $this |
||
66 | */ |
||
67 | 4 | public function from(string $accessToken): self |
|
73 | |||
74 | /** |
||
75 | * Set the RocketChat channel the message should be sent to. |
||
76 | * |
||
77 | * @param string $channel |
||
78 | * @return $this |
||
79 | */ |
||
80 | 4 | public function to(string $channel): self |
|
86 | |||
87 | /** |
||
88 | * Set the sender's alias. |
||
89 | * |
||
90 | * @param string $alias |
||
91 | * @return $this |
||
92 | */ |
||
93 | 1 | public function alias(string $alias): self |
|
99 | |||
100 | /** |
||
101 | * Set the sender's emoji. |
||
102 | * |
||
103 | * @param string $emoji |
||
104 | * @return $this |
||
105 | */ |
||
106 | 1 | public function emoji(string $emoji): self |
|
112 | |||
113 | /** |
||
114 | * Set the sender's avatar. |
||
115 | * |
||
116 | * @param string $avatar |
||
117 | * @return $this |
||
118 | */ |
||
119 | 1 | public function avatar(string $avatar): self |
|
125 | |||
126 | /** |
||
127 | * Set the content of the RocketChat message. |
||
128 | * Supports GitHub flavoured markdown. |
||
129 | * |
||
130 | * @param string $content |
||
131 | * @return $this |
||
132 | */ |
||
133 | 15 | public function content(string $content): self |
|
139 | |||
140 | /** |
||
141 | * Add an attachment to the message. |
||
142 | * |
||
143 | * @param array|\NotificationChannels\RocketChat\RocketChatAttachment $attachment |
||
144 | * @return $this |
||
145 | */ |
||
146 | 3 | public function attachment($attachment): self |
|
156 | |||
157 | /** |
||
158 | * Add multiple attachments to the message. |
||
159 | * |
||
160 | * @param array|\NotificationChannels\RocketChat\RocketChatAttachment[] $attachments |
||
161 | * @return $this |
||
162 | */ |
||
163 | 1 | public function attachments(array $attachments): self |
|
171 | |||
172 | /** |
||
173 | * Get an array representation of the RocketChatMessage. |
||
174 | * |
||
175 | * @return array |
||
176 | */ |
||
177 | 12 | public function toArray(): array |
|
194 | } |
||
195 |