diff --git a/README.md b/README.md index 45af7be..759e2b5 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`, `removeImportedTnOrders`, `inserviceNumbers`, and `importTnChecker` 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,97 @@ $data = array( ); $tnoptions->create($data); ``` + +## Hosted Messaging Functions + +### Get Import TN Orders +```PHP +$resp = $account->getImportTnOrders(array( + "createdDateFrom" => "2013-10-22T00:00:00.000Z", + "createdDateTo" => "2013-10-25T00:00:00.000Z" +)); + +print_r($resp->ImportTnOrderSummary[0]->OrderId); +``` + +### Create Import TN Order +```PHP +$importTnOrder = new \Iris\ImportTnOrder(array( + "CustomerOrderId" => "id", + "TelephoneNumbers" => array( + "TelephoneNumber" => array("5554443333") + ), + "SiteId" => "12345", + "Subscriber" => array( + "Name" => "Company INC", + "ServiceAddress" => array( + "HouseNumber" => "1", + "StreetName" => "Street", + "City" => "City", + "StateCode" => "XY", + "Zip" => "54345", + "County" => "County" + ) + ), + "LoaAuthorizingPerson" => "Test Person" +)); + +print_r($account->createImportTnOrder($importTnOrder)->ImportTnOrder->OrderId); +``` + +### Get Import TN Order By ID +```PHP +print_r($account->getImportTnOrder("some_id_value")->ProcessingStatus); +``` + +### Get Import TN Order History +```PHP +print_r($account->getImportTnOrderHistory("some_id_value")->OrderHistory[0]->Status); +``` + +### Check TNs Portability +```PHP +print_r($account->checkTnsPortability(array("5554443333", "5553334444"))->ImportTnCheckerPayload); +``` + +### Get In Service Numbers +```PHP +print_r($account->getInserviceNumbers(array("areacode" => "919"))->TelephoneNumbers->Count); +``` + +### Check In Service Number +```PHP +print_r($account->checkInserviceNumber("5554443333")); +``` + +### Get Remove Imported TN Orders +```PHP +$resp = $account->getRemoveImportedTnOrders(array( + "createdDateFrom" => "2013-10-22T00:00:00.000Z", + "createdDateTo" => "2013-10-25T00:00:00.000Z" +)); + +print_r($resp->RemoveImportedTnOrderSummary[0]->OrderStatus); +``` + +### Create A Remove Imported TN Order +```PHP +$removeImportedTnOrder = new \Iris\RemoveImportedTnOrder(array( + "CustomerOrderId" => "custom string", + "TelephoneNumbers" => array( + "TelephoneNumber" => array("5554443333", "5553332222") + ) +)); + +print_r($account->createRemoveImportedTnOrder($removeImportedTnOrder)->Location); +``` + +### Get Removed Imported TN Order +```PHP +print_r($account->getRemoveImportedTnOrder("some_id_value")->ProcessingStatus); +``` + +### Get Removed Imported TN Order History +```PHP +print_r($account->getRemoveImportedTnOrderHistory("some_id_value")->OrderHistory[0]->Status); +``` 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..763b296 100644 --- a/src/Account.php +++ b/src/Account.php @@ -250,4 +250,74 @@ 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 ImportTnOrder($response); + } + + public function getImportTnOrderHistory($id) { + $url = sprintf('%s/%s/%s/%s', $this->account_id, 'importTnOrders', $id, 'history'); + $response = parent::_get($url); + return new OrderHistoryResponse($response); + } + + public function checkTnsPortability($tns) { + $url = sprintf('%s/%s', $this->account_id, 'importTnChecker'); + $payload = new ImportTnCheckerPayload(array( + "TelephoneNumbers" => array( + "TelephoneNumber" => $tns + ))); + $data = parent::post($url, 'ImportTnCheckerPayload', $payload->to_array()); + return new ImportTnCheckerResponse($data); + } + + public function getInserviceNumbers($filters = array()) { + $url = sprintf('%s/%s', $this->account_id, 'inserviceNumbers'); + $response = parent::_get($url, $filters); + return new InserviceTns($response); + } + + public function checkInserviceNumber($tn) { + $url = sprintf('%s/%s/%s', $this->account_id, 'inserviceNumbers', $tn); + $response = parent::_get($url); + return $response; + } + + public function getRemoveImportedTnOrders($filters = array()) { + $url = sprintf('%s/%s', $this->account_id, 'removeImportedTnOrders'); + $response = parent::_get($url, $filters); + return new RemoveImportedTnOrderSummaryResponse($response); + } + + public function createRemoveImportedTnOrder(RemoveImportedTnOrder $order) { + $url = sprintf('%s/%s', $this->account_id, 'removeImportedTnOrders'); + $data = parent::post($url, 'RemoveImportedTnOrder', $order->to_array()); + return new RemoveImportedTnOrderResponse($data); + } + + public function getRemoveImportedTnOrder($id) { + $url = sprintf('%s/%s/%s', $this->account_id, 'removeImportedTnOrders', $id); + $response = parent::_get($url); + return new RemoveImportedTnOrder($response); + } + + public function getRemoveImportedTnOrderHistory($id) { + $url = sprintf('%s/%s/%s/%s', $this->account_id, 'removeImportedTnOrders', $id, 'history'); + $response = parent::_get($url); + return new OrderHistoryResponse($response); + } } diff --git a/src/simpleModels/ImportTnCheckerPayload.php b/src/simpleModels/ImportTnCheckerPayload.php new file mode 100644 index 0000000..08eee87 --- /dev/null +++ b/src/simpleModels/ImportTnCheckerPayload.php @@ -0,0 +1,16 @@ + array("type" => "\Iris\Phones"), + "ImportTnErrors" => array("type" => "\Iris\ImportTnErrors") + ); + + public function __construct($data) { + $this->set_data($data, true); + } +} diff --git a/src/simpleModels/ImportTnCheckerResponse.php b/src/simpleModels/ImportTnCheckerResponse.php new file mode 100644 index 0000000..bc24d49 --- /dev/null +++ b/src/simpleModels/ImportTnCheckerResponse.php @@ -0,0 +1,16 @@ + array("type" => "\Iris\ImportTnCheckerPayload"), + "Errors" => array("type" => "\Iris\Error") + ); + + public function __construct($data) { + $this->set_data($data); + } +} diff --git a/src/simpleModels/ImportTnError.php b/src/simpleModels/ImportTnError.php new file mode 100644 index 0000000..a758c79 --- /dev/null +++ b/src/simpleModels/ImportTnError.php @@ -0,0 +1,17 @@ + array("type" => "\Iris\Phones"), + "Code" => array("type" => "string"), + "Description" => array("type" => "string") + ); + + public function __construct($data) { + $this->set_data($data, true); + } +} diff --git a/src/simpleModels/ImportTnErrors.php b/src/simpleModels/ImportTnErrors.php new file mode 100644 index 0000000..7f67eb9 --- /dev/null +++ b/src/simpleModels/ImportTnErrors.php @@ -0,0 +1,15 @@ + array("type" => "\Iris\ImportTnError") + ); + + public function __construct($data) { + $this->set_data($data, true); + } +} 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..d545777 --- /dev/null +++ b/src/simpleModels/ImportTnOrderResponse.php @@ -0,0 +1,18 @@ + array("type" => "integer"), + "ImportTnOrder" => array("type" => "\Iris\ImportTnOrder"), + "ImportTnOrderSummary" => array("type" => "\Iris\ImportTnOrder"), + "Location" => array("type" => "string") + ); + + public function __construct($data) { + $this->set_data($data); + } +} diff --git a/src/simpleModels/InserviceTns.php b/src/simpleModels/InserviceTns.php new file mode 100644 index 0000000..1caaf3f --- /dev/null +++ b/src/simpleModels/InserviceTns.php @@ -0,0 +1,17 @@ + array("type" => "string"), + "TelephoneNumbers" => array("type" => "\Iris\Phones"), + "Links" => array("type" => "\Iris\Links") + ); + + public function __construct($data) { + $this->set_data($data, true); + } +} diff --git a/src/simpleModels/Links.php b/src/simpleModels/Links.php new file mode 100644 index 0000000..8780415 --- /dev/null +++ b/src/simpleModels/Links.php @@ -0,0 +1,17 @@ + array("type" => "string"), + "next" => array("type" => "string"), + "last" => array("type" => "string") + ); + + public function __construct($data) { + $this->set_data($data, true); + } +} diff --git a/src/simpleModels/OrderHistory.php b/src/simpleModels/OrderHistory.php new file mode 100644 index 0000000..4e82d40 --- /dev/null +++ b/src/simpleModels/OrderHistory.php @@ -0,0 +1,18 @@ + array("type" => "string"), + "Note" => array("type" => "string"), + "Author" => array("type" => "string"), + "Status" => array("type" => "string") + ); + + public function __construct($data) { + $this->set_data($data, true); + } +} diff --git a/src/simpleModels/OrderHistoryResponse.php b/src/simpleModels/OrderHistoryResponse.php new file mode 100644 index 0000000..97d8277 --- /dev/null +++ b/src/simpleModels/OrderHistoryResponse.php @@ -0,0 +1,15 @@ + array("type" => "\Iris\OrderHistory"), + ); + + public function __construct($data) { + $this->set_data($data, true); + } +} diff --git a/src/simpleModels/OrderRequest.php b/src/simpleModels/OrderRequest.php index e05ebad..8ef2b97 100644 --- a/src/simpleModels/OrderRequest.php +++ b/src/simpleModels/OrderRequest.php @@ -23,7 +23,6 @@ class OrderRequest { "OrderCreateDate" => array("type" => "string"), "id" => array("type" => "string"), "DisconnectTelephoneNumberOrderType" => array("type" => "string"), - "OrderCreateDate" => array("type" => "string"), ); public function __construct($data) { diff --git a/src/simpleModels/Phones.php b/src/simpleModels/Phones.php index ddcae82..f771b87 100644 --- a/src/simpleModels/Phones.php +++ b/src/simpleModels/Phones.php @@ -8,7 +8,8 @@ class Phones { protected $fields = array( "PhoneNumber" => array("type" => "string"), "TelephoneNumber" => array("type" => "string"), - "FullNumber" => array("type" => "string") + "FullNumber" => array("type" => "string"), + "Count" => array("type" => "string") ); public function __construct($data) { diff --git a/src/simpleModels/RemoveImportedTnOrder.php b/src/simpleModels/RemoveImportedTnOrder.php new file mode 100644 index 0000000..21995f8 --- /dev/null +++ b/src/simpleModels/RemoveImportedTnOrder.php @@ -0,0 +1,23 @@ + array("type" => "string"), + "OrderCreateDate" => array("type" => "string"), + "AccountId" => array("type" => "string"), + "CreatedByUser" => array("type" => "string"), + "OrderId" => array("type" => "string"), + "LastModifiedDate" => 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/RemoveImportedTnOrderResponse.php b/src/simpleModels/RemoveImportedTnOrderResponse.php new file mode 100644 index 0000000..b80c538 --- /dev/null +++ b/src/simpleModels/RemoveImportedTnOrderResponse.php @@ -0,0 +1,16 @@ + array("type" => "\Iris\RemoveImportedTnOrder"), + "Location" => array("type" => "string") + ); + + public function __construct($data) { + $this->set_data($data); + } +} diff --git a/src/simpleModels/RemoveImportedTnOrderSummary.php b/src/simpleModels/RemoveImportedTnOrderSummary.php new file mode 100644 index 0000000..2bb6935 --- /dev/null +++ b/src/simpleModels/RemoveImportedTnOrderSummary.php @@ -0,0 +1,23 @@ + array("type" => "string"), + "CountOfTNs" => array("type" => "integer"), + "CustomerOrderId" => array("type" => "string"), + "userId" => array("type" => "string"), + "lastModifiedDate" => array("type" => "string"), + "OrderDate" => array("type" => "string"), + "OrderType" => array("type" => "string"), + "OrderStatus" => array("type" => "string"), + "OrderId" => array("type" => "string") + ); + + public function __construct($data) { + $this->set_data($data); + } +} diff --git a/src/simpleModels/RemoveImportedTnOrderSummaryResponse.php b/src/simpleModels/RemoveImportedTnOrderSummaryResponse.php new file mode 100644 index 0000000..dea6daa --- /dev/null +++ b/src/simpleModels/RemoveImportedTnOrderSummaryResponse.php @@ -0,0 +1,16 @@ + array("type" => "integer"), + "RemoveImportedTnOrderSummary" => array("type" => "\Iris\RemoveImportedTnOrderSummary") + ); + + public function __construct($data) { + $this->set_data($data); + } +} diff --git a/src/simpleModels/Subscriber.php b/src/simpleModels/Subscriber.php index d776845..b247c64 100644 --- a/src/simpleModels/Subscriber.php +++ b/src/simpleModels/Subscriber.php @@ -11,7 +11,8 @@ class Subscriber { "ServiceAddress" => array("type" => "\Iris\ServiceAddress"), "FirstName" => array("type" => "string"), "LastName" => array("type" => "string"), - "MiddleInitial" => array("type" => "string") + "MiddleInitial" => array("type" => "string"), + "Name" => array("type" => "string") ); public function __construct($data) { diff --git a/tests/AccountTest.php b/tests/AccountTest.php index 3099da7..2522d8c 100644 --- a/tests/AccountTest.php +++ b/tests/AccountTest.php @@ -59,6 +59,84 @@ 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 + + "), + new Response(200, [], " + + SJM000001 + 2018-01-20T02:59:54.000Z + 9900012 + smckinnon + b05de7e6-0cab-4c83-81bb-9379cba8efd0 + 2018-01-20T02:59:54.000Z + + 9199918388 + 4158714245 + 4352154439 + 4352154466 + + PROCESSING + + "), + new Response(200, [], " + + 2 + + link + + + 2 + 8043024183 + 8042121778 + + "), + new Response(200, [], " + + + + 3032281000 + + + + 19006 + Bandwidth numbers cannot be imported by this account at this time. + + 4109235436 + 4104685864 + + + + + "), ]); self::$container = []; @@ -278,4 +356,40 @@ 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->OrderId); + self::$index++; + } + + public function testRemoveImportedTnOrder() { + $removeImportedTnOrderResponse = self::$account->getRemoveImportedTnOrder("b05de7e6-0cab-4c83-81bb-9379cba8efd0"); + + $this->assertEquals("b05de7e6-0cab-4c83-81bb-9379cba8efd0", $removeImportedTnOrderResponse->OrderId); + self::$index++; + } + + public function testGetInserviceNumbers() { + $tns = self::$account->getInserviceNumbers(); + + $this->assertEquals("2", $tns->TotalCount); + $this->assertEquals("link", $tns->Links->first); + $this->assertEquals("2", $tns->TelephoneNumbers->Count); + $this->assertEquals("8043024183", $tns->TelephoneNumbers->TelephoneNumber[0]); + $this->assertEquals("8042121778", $tns->TelephoneNumbers->TelephoneNumber[1]); + + self::$index++; + } + + public function testCheckTnsPortability() { + $importTnCheckerResponse = self::$account->checkTnsPortability(array("5554443333")); + + $this->assertEquals("3032281000", $importTnCheckerResponse->ImportTnCheckerPayload->TelephoneNumbers->TelephoneNumber); + $this->assertEquals("19006", $importTnCheckerResponse->ImportTnCheckerPayload->ImportTnErrors->ImportTnError->Code); + + + self::$index++; + } }