1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,39 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+namespace Phaxio; |
|
4 |
+ |
|
5 |
+class PhoneNumber extends AbstractResource |
|
6 |
+{ |
|
7 |
+ public static function create($phaxio, $params) { |
|
8 |
+ $phone_number = new self($phaxio); |
|
9 |
+ return $phone_number->_create($params); |
|
10 |
+ } |
|
11 |
+ |
|
12 |
+ public static function init($phaxio, $phone_number) { |
|
13 |
+ return new self($phaxio, array('phone_number' => $phone_number)); |
|
14 |
+ } |
|
15 |
+ |
|
16 |
+ private function _create($params) { |
|
17 |
+ if (isset($this->phone_number)) throw new Exception("PhoneNumber #{$this->phone_number} already created"); |
|
18 |
+ |
|
19 |
+ $result = $this->phaxio->doRequest('POST', 'phone_numbers', $params); |
|
20 |
+ $this->phone_number = $result->getData()['phone_number']; |
|
21 |
+ |
|
22 |
+ return $this; |
|
23 |
+ } |
|
24 |
+ |
|
25 |
+ public function retrieve() { |
|
26 |
+ if (!isset($this->phone_number)) throw new Exception("Must set phone_number before getting PhoneNumber"); |
|
27 |
+ |
|
28 |
+ $result = $this->phaxio->doRequest("GET", 'phone_numbers/' . urlencode($this->phone_number)); |
|
29 |
+ $this->exchangeArray($result->getData()); |
|
30 |
+ |
|
31 |
+ return $this; |
|
32 |
+ } |
|
33 |
+ |
|
34 |
+ public function delete() { |
|
35 |
+ $result = $this->phaxio->doRequest("DELETE", 'phone_numbers/' . urlencode($this->phone_number)); |
|
36 |
+ |
|
37 |
+ return true; |
|
38 |
+ } |
|
39 |
+} |