1 | <?php |
||
10 | abstract class SMSHandler extends SocketHandler |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $authToken; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $authId; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $fromNumber; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $toNumber; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $host; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $version; |
||
42 | |||
43 | /** |
||
44 | * @var integer |
||
45 | */ |
||
46 | protected $limit; |
||
47 | |||
48 | /** |
||
49 | * @param string $authToken Plivo API Auth Token |
||
50 | * @param string $authId Plivo API Auth ID |
||
51 | * @param string $fromNumber The phone number that will be shown as the sender ID |
||
52 | * @param string $toNumber The phone number to which the message will be sent |
||
53 | * @param int $level The minimum logging level at which this handler will be triggered |
||
54 | * @param bool $bubble Whether the messages that are handled can bubble up the stack or not |
||
55 | * @param bool $useSSL Whether to connect via SSL. |
||
56 | * @param string $host The Plivo server hostname. |
||
57 | * @param string $version The Plivo API version (default PlivoHandler::API_V1) |
||
58 | * @param int $limit The character limit |
||
59 | */ |
||
60 | 45 | public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = null, $limit = 160) |
|
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | * |
||
81 | * @param array $record |
||
82 | * @return string |
||
83 | */ |
||
84 | 36 | protected function generateDataStream($record) |
|
89 | |||
90 | /** |
||
91 | * Builds the body of API call |
||
92 | * |
||
93 | * @param array $record |
||
94 | * @return string |
||
95 | */ |
||
96 | abstract protected function buildContent($record); |
||
97 | |||
98 | /** |
||
99 | * Builds the URL for the API call |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | abstract protected function buildRequestUrl(); |
||
104 | |||
105 | /** |
||
106 | * Builds the header of the API call |
||
107 | * |
||
108 | * @param string $content |
||
109 | * @return string |
||
110 | */ |
||
111 | 36 | private function buildHeader($content) |
|
128 | |||
129 | |||
130 | |||
131 | /** |
||
132 | * {@inheritdoc} |
||
133 | * |
||
134 | * @param array $record |
||
135 | */ |
||
136 | 36 | protected function write(array $record) |
|
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | 9 | protected function getDefaultFormatter() |
|
149 | } |
||
150 |