Skip to content

Commit e4a4df8

Browse files
authored
Merge pull request #10 from rasmusdencker/1.0 . Closes #11
Added support for the 'url' action field
2 parents cf14bb4 + 4755950 commit e4a4df8

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/AttachmentAction.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class AttachmentAction
4747
*/
4848
protected $value;
4949

50+
/**
51+
* Optional URL.
52+
*
53+
* @var string
54+
*/
55+
protected $url;
56+
5057
/**
5158
* Confirmation field.
5259
*
@@ -79,6 +86,10 @@ public function __construct(array $attributes)
7986
$this->setType($attributes['type']);
8087
}
8188

89+
if (isset($attributes['url'])) {
90+
$this->setUrl($attributes['url']);
91+
}
92+
8293
if (isset($attributes['value'])) {
8394
$this->setValue($attributes['value']);
8495
}
@@ -126,6 +137,25 @@ public function setText($text)
126137
return $this;
127138
}
128139

140+
/**
141+
* @return string
142+
*/
143+
public function getUrl()
144+
{
145+
return $this->url;
146+
}
147+
148+
/**
149+
* @param string $url
150+
* @return AttachmentAction
151+
*/
152+
public function setUrl($url)
153+
{
154+
$this->url = $url;
155+
156+
return $this;
157+
}
158+
129159
/**
130160
* @return string
131161
*/
@@ -228,6 +258,7 @@ public function toArray()
228258
'style' => $this->getStyle(),
229259
'type' => $this->getType(),
230260
'value' => $this->getValue(),
261+
'url' => $this->getUrl(),
231262
'confirm' => $confirm ? $confirm->toArray() : null,
232263
];
233264
}

tests/AttachmentUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function testAttachmentToArray()
118118
'style' => 'default',
119119
'type' => 'button',
120120
'value' => 'Value 2',
121+
'url' => 'https://www.example.com/',
121122
'confirm' => [
122123
'title' => 'Title 2',
123124
'text' => 'Text 2',
@@ -164,6 +165,7 @@ public function testAttachmentToArray()
164165
'style' => 'default',
165166
'type' => 'button',
166167
'value' => 'Value 1',
168+
'url' => null,
167169
'confirm' => [
168170
'title' => 'Title 1',
169171
'text' => 'Text 1',
@@ -177,6 +179,7 @@ public function testAttachmentToArray()
177179
'style' => 'default',
178180
'type' => 'button',
179181
'value' => 'Value 2',
182+
'url' => 'https://www.example.com/',
180183
'confirm' => [
181184
'title' => 'Title 2',
182185
'text' => 'Text 2',

tests/ClientFunctionalTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ public function testMessageWithAttachmentsAndActions()
220220
'style' => 'default',
221221
'type' => 'button',
222222
'value' => 'Value 1',
223+
'url' => 'https://www.example.com/',
223224
'confirm' => [
224225
'title' => 'Title 1',
225226
'text' => 'Text 1',
@@ -233,6 +234,7 @@ public function testMessageWithAttachmentsAndActions()
233234
'style' => 'default',
234235
'type' => 'button',
235236
'value' => 'Value 2',
237+
'url' => null,
236238
'confirm' => [
237239
'title' => 'Title 2',
238240
'text' => 'Text 2',
@@ -267,6 +269,7 @@ public function testMessageWithAttachmentsAndActions()
267269
'style' => 'default',
268270
'type' => 'button',
269271
'value' => 'Value 1',
272+
'url' => 'https://www.example.com/',
270273
'confirm' => [
271274
'title' => 'Title 1',
272275
'text' => 'Text 1',
@@ -280,6 +283,7 @@ public function testMessageWithAttachmentsAndActions()
280283
'style' => 'default',
281284
'type' => 'button',
282285
'value' => 'Value 2',
286+
'url' => null,
283287
'confirm' => [
284288
'title' => 'Title 2',
285289
'text' => 'Text 2',

0 commit comments

Comments
 (0)