Get attachments
public getAttachments ( ) : |
||
return | attachments |
public function testGetAttachments() { $message = new Message($this->client, ['attachments' => []]); $count = rand(1, 10); foreach (range(1, $count) as $i) { $message->data['attachments'][] = new Attachment($this->faker->title, $this->faker->sentence); } $this->assertCount($count, $message->getAttachments()); $this->assertEquals($message->data['attachments'], $message->getAttachments()); }
/** * Posts a message. * * @param \Slack\Message\Message $message The message to post. * * @return \React\Promise\PromiseInterface */ public function postMessage(Message $message) { $options = ['text' => $message->getText(), 'channel' => $message->data['channel'], 'as_user' => true]; if ($message->hasAttachments()) { $options['attachments'] = json_encode($message->getAttachments()); } return $this->apiCall('chat.postMessage', $options); }