From 42699c5640c38c1597575c6800fe9a940c779202 Mon Sep 17 00:00:00 2001 From: Ben Perove Date: Sun, 17 Jul 2016 11:48:16 -0500 Subject: [PATCH 1/4] added callback_id --- src/Attachment.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/Attachment.php b/src/Attachment.php index 3ff4424..d0c3960 100644 --- a/src/Attachment.php +++ b/src/Attachment.php @@ -13,6 +13,13 @@ class Attachment */ protected $fallback; + /** + * The callback_id for the button group. + * + * @var string + */ + protected $callback_id; + /** * Optional text that should appear within the attachment. * @@ -139,6 +146,10 @@ public function __construct(array $attributes) $this->setFallback($attributes['fallback']); } + if (isset($attributes['callback_id'])) { + $this->setCallback($attributes['callback_id']); + } + if (isset($attributes['text'])) { $this->setText($attributes['text']); } @@ -227,6 +238,29 @@ public function setFallback($fallback) return $this; } + /** + * Get the callback_id text. + * + * @return string + */ + public function getCallback() + { + return $this->callback_id; + } + + /** + * Set the callback_id. + * + * @param string $callback_id + * @return $this + */ + public function setCallback($callback_id) + { + $this->callback_id = $callback_id; + + return $this; + } + /** * Get the optional text to appear within the attachment. * @@ -680,6 +714,7 @@ public function toArray() { $data = [ 'fallback' => $this->getFallback(), + 'callback_id' => $this->getCallback(), 'text' => $this->getText(), 'pretext' => $this->getPretext(), 'color' => $this->getColor(), From 106cc911747f262243fb5561844adb24bf6ebd76 Mon Sep 17 00:00:00 2001 From: Ben Perove Date: Sun, 17 Jul 2016 11:48:46 -0500 Subject: [PATCH 2/4] allow confirm array to be optional --- src/AttachmentAction.php | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/AttachmentAction.php b/src/AttachmentAction.php index fe38073..407efe8 100644 --- a/src/AttachmentAction.php +++ b/src/AttachmentAction.php @@ -203,6 +203,9 @@ public function setConfirm($confirm) } elseif (is_array($confirm)) { $this->confirm = new ActionConfirmation($confirm); + return $this; + } elseif (!isset($confirm)) { + $this->confirm = null; return $this; } @@ -216,13 +219,26 @@ public function setConfirm($confirm) */ public function toArray() { - return [ - 'name' => $this->getName(), - 'text' => $this->getText(), - 'style' => $this->getStyle(), - 'type' => $this->getType(), - 'value' => $this->getValue(), - 'confirm' => $this->getConfirm()->toArray(), - ]; + if ($this->getConfirm() != null) + { + return [ + 'name' => $this->getName(), + 'text' => $this->getText(), + 'style' => $this->getStyle(), + 'type' => $this->getType(), + 'value' => $this->getValue(), + 'confirm' => $this->getConfirm()->toArray(), + ]; + } + else + { + return [ + 'name' => $this->getName(), + 'text' => $this->getText(), + 'style' => $this->getStyle(), + 'type' => $this->getType(), + 'value' => $this->getValue(), + ]; + } } } From b28c9ad7228353ef05535d17cd5c54b5564d4bf4 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sun, 17 Jul 2016 12:40:25 -0500 Subject: [PATCH 3/4] Update AttachmentAction.php --- src/AttachmentAction.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/AttachmentAction.php b/src/AttachmentAction.php index 407efe8..6ba7b46 100644 --- a/src/AttachmentAction.php +++ b/src/AttachmentAction.php @@ -204,7 +204,7 @@ public function setConfirm($confirm) $this->confirm = new ActionConfirmation($confirm); return $this; - } elseif (!isset($confirm)) { + } elseif (! isset($confirm)) { $this->confirm = null; return $this; } @@ -219,8 +219,7 @@ public function setConfirm($confirm) */ public function toArray() { - if ($this->getConfirm() != null) - { + if ($this->getConfirm() != null) { return [ 'name' => $this->getName(), 'text' => $this->getText(), @@ -229,9 +228,7 @@ public function toArray() 'value' => $this->getValue(), 'confirm' => $this->getConfirm()->toArray(), ]; - } - else - { + } else { return [ 'name' => $this->getName(), 'text' => $this->getText(), From 3c414fc7a11b01f50c20b9d1949b445d0b807cd2 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sun, 17 Jul 2016 12:43:58 -0500 Subject: [PATCH 4/4] Update AttachmentAction.php --- src/AttachmentAction.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AttachmentAction.php b/src/AttachmentAction.php index 6ba7b46..77aa647 100644 --- a/src/AttachmentAction.php +++ b/src/AttachmentAction.php @@ -206,6 +206,7 @@ public function setConfirm($confirm) return $this; } elseif (! isset($confirm)) { $this->confirm = null; + return $this; }