From 5940e221ca118c53bb6a4ae1cbff63b761df09f9 Mon Sep 17 00:00:00 2001 From: Dustin Cortez Date: Mon, 18 May 2020 21:09:07 +0000 Subject: [PATCH] add ata endpoint retrieve functions, add example for listATAs, rename var in AbstractResourceCollection to to make more sense, fix spelling error in Phaxio retrieveFax easy method). --- examples/listATAs.php | 9 +++++++++ lib/Phaxio.php | 22 ++++++++++++++++++++-- lib/Phaxio/ATA.php | 19 +++++++++++++++++++ lib/Phaxio/ATACollection.php | 9 +++++++++ lib/Phaxio/ATAs.php | 12 ++++++++++++ lib/Phaxio/AbstractResourceCollection.php | 6 +++--- 6 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 examples/listATAs.php create mode 100644 lib/Phaxio/ATA.php create mode 100644 lib/Phaxio/ATACollection.php create mode 100644 lib/Phaxio/ATAs.php diff --git a/examples/listATAs.php b/examples/listATAs.php new file mode 100644 index 0000000..a7f3ef0 --- /dev/null +++ b/examples/listATAs.php @@ -0,0 +1,9 @@ +listATAs(); +var_dump($result); diff --git a/lib/Phaxio.php b/lib/Phaxio.php index 4ebde15..435a063 100644 --- a/lib/Phaxio.php +++ b/lib/Phaxio.php @@ -5,7 +5,7 @@ class Phaxio private $debug = false; private $api_key = null; private $api_secret = null; - private $host = "https://api.phaxio.com/v2/"; + private $host = "https://api.phaxio.com/v2.1/"; public function __construct($api_key = null, $api_secret = null, $host = null) { @@ -40,6 +40,10 @@ public function account() { return new Phaxio\Account($this); } + public function atas() { + return new Phaxio\ATAs($this); + } + # Convenience methods public function sendFax($params) { @@ -50,7 +54,7 @@ public function initFax($id) { return $this->faxes()->init($id); } - public function retriveFaxFile($id, $params = array()) { + public function retrieveFaxFile($id, $params = array()) { return $this->initFax($id)->getFile()->retrieve($params); } @@ -58,6 +62,20 @@ public function listFaxes($params = array()) { return $this->faxes()->getList($params); } + public function listATAs() + { + return $this->atas()->getList(); + } + + public function initATA($id) { + return $this->atas()->init($id); + } + + public function retrieveATA($id) + { + return $this->initATA($id)->retrieve(); + } + public function retrieveDefaultPhaxCode($getMetadata = false) { return Phaxio\PhaxCode::init($this)->retrieve($getMetadata); diff --git a/lib/Phaxio/ATA.php b/lib/Phaxio/ATA.php new file mode 100644 index 0000000..8b79f12 --- /dev/null +++ b/lib/Phaxio/ATA.php @@ -0,0 +1,19 @@ + $id)); + } + + public function retrieve() { + if (!isset($this->id)) throw new Exception("Must set ID before getting fax"); + + $result = $this->phaxio->doRequest("GET", 'atas/' . urlencode($this->id)); + $this->exchangeArray($result->getData()); + + return $this; + } +} diff --git a/lib/Phaxio/ATACollection.php b/lib/Phaxio/ATACollection.php new file mode 100644 index 0000000..cada98a --- /dev/null +++ b/lib/Phaxio/ATACollection.php @@ -0,0 +1,9 @@ +phaxio, $id); + } +} diff --git a/lib/Phaxio/AbstractResourceCollection.php b/lib/Phaxio/AbstractResourceCollection.php index fbdf235..23347a7 100644 --- a/lib/Phaxio/AbstractResourceCollection.php +++ b/lib/Phaxio/AbstractResourceCollection.php @@ -40,9 +40,9 @@ private function retrievePage() { foreach ($results->getData() as $result) { $resource_class = "Phaxio\\{$this->resource_class}"; - $fax = new $resource_class($this->phaxio); - $fax->exchangeArray($result); - $this[] = $fax; + $arr = new $resource_class($this->phaxio); + $arr->exchangeArray($result); + $this[] = $arr; } } }