forked from bryglen/yii2-twillio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTwillio.php
52 lines (41 loc) · 1.08 KB
/
Twillio.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* @author Bryan Tan <[email protected]>
*/
namespace SteveSimpson\twillio;
use yii\base\Component;
use yii\base\InvalidConfigException;
class Twillio extends Component
{
public $sid;
public $token;
public $from;
public $area;
private $_client = null;
private $_clientCapability = null;
public function init()
{
if (!$this->sid) {
throw new InvalidConfigException('SID is required');
}
if (!$this->token) {
throw new InvalidConfigException('Token is required');
}
}
public function getClient()
{
if ($this->_client === null) {
$client = new \Services_Twilio($this->sid, $this->token);
$this->_client = $client;
}
return $this->_client;
}
public function getClientCapability()
{
if ($this->_clientCapability === null) {
$client = new \Services_Twilio_Capability($this->sid, $this->token);
$this->_clientCapability = $client;
}
return $this->_clientCapability;
}
}