Skip to content

Commit

Permalink
Merge 2a82fdb into 576e3b0
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermacbeth committed Jan 15, 2017
2 parents 576e3b0 + 2a82fdb commit 4770aa2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ class Attachment
*/
protected $markdown_fields = [];

/**
* The callback_id used by the API receiving
* the POST request to respond to interactive buttons
*
* @var string
*/
protected $callback_id;

/**
* A collection of actions (buttons) to include in the attachment.
* A maximum of 5 actions may be provided.
Expand Down Expand Up @@ -199,6 +207,10 @@ public function __construct(array $attributes)
$this->setAuthorIcon($attributes['author_icon']);
}

if (isset($attributes['callback_id'])) {
$this->setCallbackId($attributes['callback_id']);
}

if (isset($attributes['actions'])) {
$this->setActions($attributes['actions']);
}
Expand Down Expand Up @@ -623,6 +635,28 @@ public function setMarkdownFields(array $fields)
return $this;
}

/**
* Get the callback_id specified for the attachment
*
* @return string
*/
public function getCallbackId()
{
return $this->callback_id;
}

/**
* Set the callback_id for the attachment
*
* @param string
* @return $this
*/ public function setCallbackId($callback_id)
{
$this->callback_id = $callback_id;

return $this;
}

/**
* Get the collection of actions (buttons) to include in the attachment.
*
Expand Down Expand Up @@ -694,6 +728,7 @@ public function toArray()
'author_name' => $this->getAuthorName(),
'author_link' => $this->getAuthorLink(),
'author_icon' => $this->getAuthorIcon(),
'callback_id' => $this->getCallbackId(),
];

$data['fields'] = $this->getFieldsAsArrays();
Expand Down
1 change: 1 addition & 0 deletions tests/AttachmentUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function testAttachmentToArray()
'author_name' => 'Joe Bloggs',
'author_link' => 'http://fake.host/',
'author_icon' => 'http://fake.host/image.png',
'callback_id' => 'comic_1234_xyz',
'fields' => [
[
'title' => 'Title 1',
Expand Down

0 comments on commit 4770aa2

Please sign in to comment.