Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/listATAs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

require_once('phaxio_config.php');
require_once('autoload.php');

$phaxio = new Phaxio($apiKeys[$apiMode], $apiSecrets[$apiMode], $apiHost);

$result = $phaxio->listATAs();
var_dump($result);
22 changes: 20 additions & 2 deletions lib/Phaxio.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand All @@ -50,14 +54,28 @@ 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);
}

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);
Expand Down
19 changes: 19 additions & 0 deletions lib/Phaxio/ATA.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Phaxio;

class ATA extends AbstractResource
{
public static function init($phaxio, $id) {
return new self($phaxio, array('id' => $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;
}
}
9 changes: 9 additions & 0 deletions lib/Phaxio/ATACollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Phaxio;

class ATACollection extends AbstractResourceCollection
{
protected $resource = 'atas';
protected $resource_class = 'ATA';
}
12 changes: 12 additions & 0 deletions lib/Phaxio/ATAs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Phaxio;

class ATAs extends AbstractResources
{
protected $collection_class = 'ATACollection';

public function init($id) {
return ATA::init($this->phaxio, $id);
}
}
6 changes: 3 additions & 3 deletions lib/Phaxio/AbstractResourceCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}