Skip to content

Commit 1697186

Browse files
authored
Hosted messaging release (#54)
* Dx 920 (#52) * First stab at importTnOrders endpoints * Broke up models into 2 classes * Fixed syntax, updated readme with code example * Added tests * Added POST /importTnChecker (#53) * DX-930 added inservice numbers endpoints * DX-935 Removed Imported TN Orders endpoints * Updated release notes * Added RemoveImportedTnOrder test * Added testGetInserviceNumbers and fixed bugs * Added testCheckTnsPortability and fixed bugs * Updated responses * Removed good tag * Updated tests to reflect new structure * Made responses for some endpoints objects * Fixed tests * Fixed remaining instances * Fixed test
1 parent 3c5ac6b commit 1697186

21 files changed

+540
-6
lines changed

README.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PHP Client library for Bandwidth's Phone Number Dashboard (AKA: Dashboard, Iris)
1515
| 2.0.6 | Build `ReportsModel` functionality |
1616
| 2.0.7 | Fixed error handling for Errors fields |
1717
| 2.0.8 | Fixed rate center check |
18+
| 2.1.0 | Added `importTnOrders`, `removeImportedTnOrders`, `inserviceNumbers`, and `importTnChecker` endpoints |
1819

1920
## Supported PHP Versions
2021

@@ -45,8 +46,8 @@ $client = new \Iris\Client($login, $password, ['url' => 'https://dashboard.bandw
4546
## Run tests
4647

4748
```bash
48-
$ composer install
49-
$ php ./bin/phpunit --bootstrap ./vendor/autoload.php tests/
49+
composer install
50+
php ./bin/phpunit --bootstrap ./vendor/autoload.php tests/
5051
```
5152
=======
5253
## Examples
@@ -600,3 +601,97 @@ $data = array(
600601
);
601602
$tnoptions->create($data);
602603
```
604+
605+
## Hosted Messaging Functions
606+
607+
### Get Import TN Orders
608+
```PHP
609+
$resp = $account->getImportTnOrders(array(
610+
"createdDateFrom" => "2013-10-22T00:00:00.000Z",
611+
"createdDateTo" => "2013-10-25T00:00:00.000Z"
612+
));
613+
614+
print_r($resp->ImportTnOrderSummary[0]->OrderId);
615+
```
616+
617+
### Create Import TN Order
618+
```PHP
619+
$importTnOrder = new \Iris\ImportTnOrder(array(
620+
"CustomerOrderId" => "id",
621+
"TelephoneNumbers" => array(
622+
"TelephoneNumber" => array("5554443333")
623+
),
624+
"SiteId" => "12345",
625+
"Subscriber" => array(
626+
"Name" => "Company INC",
627+
"ServiceAddress" => array(
628+
"HouseNumber" => "1",
629+
"StreetName" => "Street",
630+
"City" => "City",
631+
"StateCode" => "XY",
632+
"Zip" => "54345",
633+
"County" => "County"
634+
)
635+
),
636+
"LoaAuthorizingPerson" => "Test Person"
637+
));
638+
639+
print_r($account->createImportTnOrder($importTnOrder)->ImportTnOrder->OrderId);
640+
```
641+
642+
### Get Import TN Order By ID
643+
```PHP
644+
print_r($account->getImportTnOrder("some_id_value")->ProcessingStatus);
645+
```
646+
647+
### Get Import TN Order History
648+
```PHP
649+
print_r($account->getImportTnOrderHistory("some_id_value")->OrderHistory[0]->Status);
650+
```
651+
652+
### Check TNs Portability
653+
```PHP
654+
print_r($account->checkTnsPortability(array("5554443333", "5553334444"))->ImportTnCheckerPayload);
655+
```
656+
657+
### Get In Service Numbers
658+
```PHP
659+
print_r($account->getInserviceNumbers(array("areacode" => "919"))->TelephoneNumbers->Count);
660+
```
661+
662+
### Check In Service Number
663+
```PHP
664+
print_r($account->checkInserviceNumber("5554443333"));
665+
```
666+
667+
### Get Remove Imported TN Orders
668+
```PHP
669+
$resp = $account->getRemoveImportedTnOrders(array(
670+
"createdDateFrom" => "2013-10-22T00:00:00.000Z",
671+
"createdDateTo" => "2013-10-25T00:00:00.000Z"
672+
));
673+
674+
print_r($resp->RemoveImportedTnOrderSummary[0]->OrderStatus);
675+
```
676+
677+
### Create A Remove Imported TN Order
678+
```PHP
679+
$removeImportedTnOrder = new \Iris\RemoveImportedTnOrder(array(
680+
"CustomerOrderId" => "custom string",
681+
"TelephoneNumbers" => array(
682+
"TelephoneNumber" => array("5554443333", "5553332222")
683+
)
684+
));
685+
686+
print_r($account->createRemoveImportedTnOrder($removeImportedTnOrder)->Location);
687+
```
688+
689+
### Get Removed Imported TN Order
690+
```PHP
691+
print_r($account->getRemoveImportedTnOrder("some_id_value")->ProcessingStatus);
692+
```
693+
694+
### Get Removed Imported TN Order History
695+
```PHP
696+
print_r($account->getRemoveImportedTnOrderHistory("some_id_value")->OrderHistory[0]->Status);
697+
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Bandwidth's Iris SDK for PHP",
55
"keywords": ["iris","sdk","php"],
66
"homepage": "http://dev.bandwidth.com",
7-
"reference": "v2.0.6",
7+
"reference": "v2.1.0",
88
"license": "MIT",
99
"authors": [
1010
],

src/Account.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,74 @@ public function get_relative_namespace() {
250250
public function get_rest_client() {
251251
return $this->client;
252252
}
253+
254+
public function getImportTnOrders($filters = array()) {
255+
$url = sprintf('%s/%s', $this->account_id, 'importTnOrders');
256+
$response = parent::_get($url, $filters);
257+
return new ImportTnOrderResponse($response);
258+
}
259+
260+
public function createImportTnOrder(ImportTnOrder $order) {
261+
$url = sprintf('%s/%s', $this->account_id, 'importTnOrders');
262+
$data = parent::post($url, 'ImportTnOrder', $order->to_array());
263+
return new ImportTnOrderResponse($data);
264+
}
265+
266+
public function getImportTnOrder($id) {
267+
$url = sprintf('%s/%s/%s', $this->account_id, 'importTnOrders', $id);
268+
$response = parent::_get($url);
269+
return new ImportTnOrder($response);
270+
}
271+
272+
public function getImportTnOrderHistory($id) {
273+
$url = sprintf('%s/%s/%s/%s', $this->account_id, 'importTnOrders', $id, 'history');
274+
$response = parent::_get($url);
275+
return new OrderHistoryResponse($response);
276+
}
277+
278+
public function checkTnsPortability($tns) {
279+
$url = sprintf('%s/%s', $this->account_id, 'importTnChecker');
280+
$payload = new ImportTnCheckerPayload(array(
281+
"TelephoneNumbers" => array(
282+
"TelephoneNumber" => $tns
283+
)));
284+
$data = parent::post($url, 'ImportTnCheckerPayload', $payload->to_array());
285+
return new ImportTnCheckerResponse($data);
286+
}
287+
288+
public function getInserviceNumbers($filters = array()) {
289+
$url = sprintf('%s/%s', $this->account_id, 'inserviceNumbers');
290+
$response = parent::_get($url, $filters);
291+
return new InserviceTns($response);
292+
}
293+
294+
public function checkInserviceNumber($tn) {
295+
$url = sprintf('%s/%s/%s', $this->account_id, 'inserviceNumbers', $tn);
296+
$response = parent::_get($url);
297+
return $response;
298+
}
299+
300+
public function getRemoveImportedTnOrders($filters = array()) {
301+
$url = sprintf('%s/%s', $this->account_id, 'removeImportedTnOrders');
302+
$response = parent::_get($url, $filters);
303+
return new RemoveImportedTnOrderSummaryResponse($response);
304+
}
305+
306+
public function createRemoveImportedTnOrder(RemoveImportedTnOrder $order) {
307+
$url = sprintf('%s/%s', $this->account_id, 'removeImportedTnOrders');
308+
$data = parent::post($url, 'RemoveImportedTnOrder', $order->to_array());
309+
return new RemoveImportedTnOrderResponse($data);
310+
}
311+
312+
public function getRemoveImportedTnOrder($id) {
313+
$url = sprintf('%s/%s/%s', $this->account_id, 'removeImportedTnOrders', $id);
314+
$response = parent::_get($url);
315+
return new RemoveImportedTnOrder($response);
316+
}
317+
318+
public function getRemoveImportedTnOrderHistory($id) {
319+
$url = sprintf('%s/%s/%s/%s', $this->account_id, 'removeImportedTnOrders', $id, 'history');
320+
$response = parent::_get($url);
321+
return new OrderHistoryResponse($response);
322+
}
253323
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class ImportTnCheckerPayload {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"TelephoneNumbers" => array("type" => "\Iris\Phones"),
10+
"ImportTnErrors" => array("type" => "\Iris\ImportTnErrors")
11+
);
12+
13+
public function __construct($data) {
14+
$this->set_data($data, true);
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class ImportTnCheckerResponse {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"ImportTnCheckerPayload" => array("type" => "\Iris\ImportTnCheckerPayload"),
10+
"Errors" => array("type" => "\Iris\Error")
11+
);
12+
13+
public function __construct($data) {
14+
$this->set_data($data);
15+
}
16+
}

src/simpleModels/ImportTnError.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class ImportTnError {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"TelephoneNumbers" => array("type" => "\Iris\Phones"),
10+
"Code" => array("type" => "string"),
11+
"Description" => array("type" => "string")
12+
);
13+
14+
public function __construct($data) {
15+
$this->set_data($data, true);
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class ImportTnErrors {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"ImportTnError" => array("type" => "\Iris\ImportTnError")
10+
);
11+
12+
public function __construct($data) {
13+
$this->set_data($data, true);
14+
}
15+
}

src/simpleModels/ImportTnOrder.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class ImportTnOrder {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"CustomerOrderId" => array("type" => "string"),
10+
"OrderCreateDate" => array("type" => "string"),
11+
"AccountId" => array("type" => "string"),
12+
"CreatedByUser" => array("type" => "string"),
13+
"OrderId" => array("type" => "string"),
14+
"LastModifiedDate" => array("type" => "string"),
15+
"SiteId" => array("type" => "string"),
16+
"SipPeerId" => array("type" => "string"),
17+
"Subscriber" => array("type" => "\Iris\Subscriber"),
18+
"LoaAuthorizingPerson" => array("type" => "string"),
19+
"ProcessingStatus" => array("type" => "string"),
20+
"Errors" => array("type" => "\Iris\Error"),
21+
"TelephoneNumbers" => array("type" => "\Iris\Phones")
22+
);
23+
24+
public function __construct($data) {
25+
$this->set_data($data);
26+
}
27+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class ImportTnOrderResponse {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"TotalCount" => array("type" => "integer"),
10+
"ImportTnOrder" => array("type" => "\Iris\ImportTnOrder"),
11+
"ImportTnOrderSummary" => array("type" => "\Iris\ImportTnOrder"),
12+
"Location" => array("type" => "string")
13+
);
14+
15+
public function __construct($data) {
16+
$this->set_data($data);
17+
}
18+
}

src/simpleModels/InserviceTns.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class InserviceTns {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"TotalCount" => array("type" => "string"),
10+
"TelephoneNumbers" => array("type" => "\Iris\Phones"),
11+
"Links" => array("type" => "\Iris\Links")
12+
);
13+
14+
public function __construct($data) {
15+
$this->set_data($data, true);
16+
}
17+
}

0 commit comments

Comments
 (0)