Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit bb380fa

Browse files
authored
Merge pull request #3 from sankarsuda/master
Dial Callbacks added
2 parents eab678f + 8afae12 commit bb380fa

4 files changed

Lines changed: 99 additions & 22 deletions

File tree

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
Copyright (c) Sankar Suda <sankar.suda@gmail.com>
4+
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in
13+
> all copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
> THE SOFTWARE.

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,65 @@ Following tags allow nested tags
168168
}
169169
]
170170
```
171+
172+
### Example of filter tag with nested tags
173+
174+
```php
175+
$response = new Mobtexting\Voice();
176+
$response->answer();
177+
$response->say('Hello');
178+
179+
$dial = $response->dial('700xxx', '80300xxxxx');
180+
$dial->setAttribute('retries', 1);
181+
182+
$play = $dial->onAnswer('play', ['custom/14d81c2e3c3f8110a7e8f36331e1b9b3']);
183+
$play->setAttribute('duration', 30);
184+
185+
$play = $dial->onNoAnswer('play', ['custom/14d81c2e3c3f8110a7e8f36331e1b9b3']);
186+
187+
echo $response;
188+
```
189+
190+
### Response
191+
192+
```json
193+
[
194+
{
195+
"Answer": {
196+
"delay": 0
197+
}
198+
},
199+
{
200+
"SayText": {
201+
"language": "EN",
202+
"engine": "polly",
203+
"message": "Hello"
204+
}
205+
},
206+
{
207+
"Dial": {
208+
"to": "7008409026",
209+
"callerid": "+918030072306",
210+
"retries": 0,
211+
"onanswer": [
212+
{
213+
"Play": {
214+
"path": "custom/14d81c2e3c3f8110a7e8f36331e1b9b3",
215+
"type": "gsm",
216+
"duration": 30
217+
}
218+
}
219+
],
220+
"onnoanswer": [
221+
{
222+
"Play": {
223+
"path": "custom/d2a3030926b57807e0067244f040f70e",
224+
"type": "gsm",
225+
"duration": 30
226+
}
227+
}
228+
]
229+
}
230+
}
231+
]
232+
```

src/Voice/Tag/Dial.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ public function __construct($to, $from = null)
1717
parent::__construct("Dial", $attrib);
1818
}
1919

20+
public function onAnswer($tag, $attribs = [])
21+
{
22+
return $this->setAttribute('onanswer', $this->append($tag, $attribs), true);
23+
}
24+
25+
public function onNoAnswer($tag, $attribs = [])
26+
{
27+
return $this->setAttribute('onnoanswer', $this->append($tag, $attribs), true);
28+
}
29+
30+
public function noAnswer($tag, $attribs = [])
31+
{
32+
return $this->setAttribute('onnoanswer', $this->append($tag, $attribs), true);
33+
}
34+
2035
public function getDefaultAttributes()
2136
{
2237
return [
@@ -25,7 +40,7 @@ public function getDefaultAttributes()
2540
"timeout" => 30,
2641
"stickyagent" => false,
2742
"smartagent" => false,
28-
"retries" => 2
43+
"retries" => 2,
2944
];
3045
}
3146
}

0 commit comments

Comments
 (0)