diff --git a/README.md b/README.md index 45af7be..faeb404 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ PHP Client library for Bandwidth's Phone Number Dashboard (AKA: Dashboard, Iris) | 2.0.6 | Build `ReportsModel` functionality | | 2.0.7 | Fixed error handling for Errors fields | | 2.0.8 | Fixed rate center check | +| 2.1.0 | Added `importTnOrders` endpoints | ## Supported PHP Versions @@ -45,8 +46,8 @@ $client = new \Iris\Client($login, $password, ['url' => 'https://dashboard.bandw ## Run tests ```bash -$ composer install -$ php ./bin/phpunit --bootstrap ./vendor/autoload.php tests/ +composer install +php ./bin/phpunit --bootstrap ./vendor/autoload.php tests/ ``` ======= ## Examples @@ -600,3 +601,35 @@ $data = array( ); $tnoptions->create($data); ``` + +## Import TN Orders + +### Get Import TN Orders +```PHP +$account->getImportTnOrders(array( + "createdDateFrom" => "2013-10-22T00:00:00.000Z", + "createdDateTo" => "2013-10-25T00:00:00.000Z" +)); +``` + +### Create Import TN Order +```PHP +$importTnOrder = new \Iris\ImportTnOrder(array( + "CustomerOrderId" => "custom string", + "TelephoneNumbers" => array( + "TelephoneNumber" => array("+15554443333", "+15553332222") + ) +)); + +$account->createImportTnOrder($importTnOrder); +``` + +### Get Import TN Order By ID +```PHP +$account->getImportTnOrder("some_id_value"); +``` + +### Get Import TN Order History +```PHP +$account->getImportTnOrderHistory("some_id_value"); +``` diff --git a/composer.json b/composer.json index 0b0842f..2633d92 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description": "Bandwidth's Iris SDK for PHP", "keywords": ["iris","sdk","php"], "homepage": "http://dev.bandwidth.com", - "reference": "v2.0.6", + "reference": "v2.1.0", "license": "MIT", "authors": [ ], diff --git a/src/Account.php b/src/Account.php index 04a93f9..617ae37 100644 --- a/src/Account.php +++ b/src/Account.php @@ -250,4 +250,29 @@ public function get_relative_namespace() { public function get_rest_client() { return $this->client; } + + public function getImportTnOrders($filters = array()) { + $url = sprintf('%s/%s', $this->account_id, 'importTnOrders'); + $response = parent::_get($url, $filters); + return new ImportTnOrderResponse($response); + } + + public function createImportTnOrder(ImportTnOrder $order) { + $url = sprintf('%s/%s', $this->account_id, 'importTnOrders'); + $data = parent::post($url, 'ImportTnOrder', $order->to_array()); + return new ImportTnOrderResponse($data); + } + + public function getImportTnOrder($id) { + $url = sprintf('%s/%s/%s', $this->account_id, 'importTnOrders', $id); + $response = parent::_get($url); + return new ImportTnOrderResponse($response); + } + + public function getImportTnOrderHistory($id) { + $url = sprintf('%s/%s/%s/%s', $this->account_id, 'importTnOrders', $id, 'history'); + $response = parent::_get($url); + //TODO: Figure out the actual response object + return $response; + } } diff --git a/src/simpleModels/ImportTnOrder.php b/src/simpleModels/ImportTnOrder.php new file mode 100644 index 0000000..14eb756 --- /dev/null +++ b/src/simpleModels/ImportTnOrder.php @@ -0,0 +1,27 @@ + array("type" => "string"), + "OrderCreateDate" => array("type" => "string"), + "AccountId" => array("type" => "string"), + "CreatedByUser" => array("type" => "string"), + "OrderId" => array("type" => "string"), + "LastModifiedDate" => array("type" => "string"), + "SiteId" => array("type" => "string"), + "SipPeerId" => array("type" => "string"), + "Subscriber" => array("type" => "\Iris\Subscriber"), + "LoaAuthorizingPerson" => array("type" => "string"), + "ProcessingStatus" => array("type" => "string"), + "Errors" => array("type" => "\Iris\Error"), + "TelephoneNumbers" => array("type" => "\Iris\Phones") + ); + + public function __construct($data) { + $this->set_data($data); + } +} diff --git a/src/simpleModels/ImportTnOrderResponse.php b/src/simpleModels/ImportTnOrderResponse.php new file mode 100644 index 0000000..6b957a3 --- /dev/null +++ b/src/simpleModels/ImportTnOrderResponse.php @@ -0,0 +1,15 @@ + array("type" => "\Iris\ImportTnOrder") + ); + + public function __construct($data) { + $this->set_data($data); + } +} diff --git a/tests/AccountTest.php b/tests/AccountTest.php index 3099da7..859d6c0 100644 --- a/tests/AccountTest.php +++ b/tests/AccountTest.php @@ -59,6 +59,39 @@ public static function setUpBeforeClass() { new Response(201, ['Location' => 'https://api.test.inetwork.com:443/v1.0/accounts/9500249/billingreports/a12b456c8-abcd-1a3b-a1b2-0a2b4c6d8e0f2'], 'RECEIVEDThe report archive is currently being constructed.'), new Response(200, ['Location' => 'https://api.test.inetwork.com:443/v1.0/accounts/9500249/billingreports/a12b456c8-abcd-1a3b-a1b2-0a2b4c6d8e0f2/file'], 'COMPLETEDThe report archive is constructed.'), new Response(200, ['Content-Type' => 'application/zip'], 'zipcontent'), + new Response(200, [], " + + + SJM000001 + 2018-01-20T02:59:54.000Z + 9900012 + smckinnon + b05de7e6-0cab-4c83-81bb-9379cba8efd0 + 2018-01-20T02:59:54.000Z + 202 + 520565 + + ABC Inc. + + 11235 + Back + Denver + CO + 27541 + Canyon + + + The Authguy + + 9199918388 + 4158714245 + 4352154439 + 4352154466 + + PROCESSING + + + "), ]); self::$container = []; @@ -278,4 +311,11 @@ public function testBillingReportReadyAndDownload() { $this->assertEquals("https://api.test.inetwork.com/v1.0/accounts/9500249/billingreports/a12b456c8-abcd-1a3b-a1b2-0a2b4c6d8e0f2/file", self::$container[self::$index]['request']->getUri()); self::$index++; } + + public function testGetImportTnOrder() { + $importTnOrderResponse = self::$account->getImportTnOrder("b05de7e6-0cab-4c83-81bb-9379cba8efd0"); + + $this->assertEquals("b05de7e6-0cab-4c83-81bb-9379cba8efd0", $importTnOrderResponse->ImportTnOrder->OrderId); + self::$index++; + } }