Skip to content

Commit 331d663

Browse files
authored
Dx 920 (#52)
* First stab at importTnOrders endpoints * Broke up models into 2 classes * Fixed syntax, updated readme with code example * Added tests
1 parent 3c5ac6b commit 331d663

File tree

6 files changed

+143
-3
lines changed

6 files changed

+143
-3
lines changed

README.md

Lines changed: 35 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` 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,35 @@ $data = array(
600601
);
601602
$tnoptions->create($data);
602603
```
604+
605+
## Import TN Orders
606+
607+
### Get Import TN Orders
608+
```PHP
609+
$account->getImportTnOrders(array(
610+
"createdDateFrom" => "2013-10-22T00:00:00.000Z",
611+
"createdDateTo" => "2013-10-25T00:00:00.000Z"
612+
));
613+
```
614+
615+
### Create Import TN Order
616+
```PHP
617+
$importTnOrder = new \Iris\ImportTnOrder(array(
618+
"CustomerOrderId" => "custom string",
619+
"TelephoneNumbers" => array(
620+
"TelephoneNumber" => array("+15554443333", "+15553332222")
621+
)
622+
));
623+
624+
$account->createImportTnOrder($importTnOrder);
625+
```
626+
627+
### Get Import TN Order By ID
628+
```PHP
629+
$account->getImportTnOrder("some_id_value");
630+
```
631+
632+
### Get Import TN Order History
633+
```PHP
634+
$account->getImportTnOrderHistory("some_id_value");
635+
```

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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,29 @@ 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 ImportTnOrderResponse($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+
//TODO: Figure out the actual response object
276+
return $response;
277+
}
253278
}

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: 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 ImportTnOrderResponse {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"ImportTnOrder" => array("type" => "\Iris\ImportTnOrder")
10+
);
11+
12+
public function __construct($data) {
13+
$this->set_data($data);
14+
}
15+
}

tests/AccountTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,39 @@ public static function setUpBeforeClass() {
5959
new Response(201, ['Location' => 'https://api.test.inetwork.com:443/v1.0/accounts/9500249/billingreports/a12b456c8-abcd-1a3b-a1b2-0a2b4c6d8e0f2'], '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><BillingReportCreationResponse><ReportStatus>RECEIVED</ReportStatus><Description>The report archive is currently being constructed.</Description></BillingReportCreationResponse>'),
6060
new Response(200, ['Location' => 'https://api.test.inetwork.com:443/v1.0/accounts/9500249/billingreports/a12b456c8-abcd-1a3b-a1b2-0a2b4c6d8e0f2/file'], '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><BillingReportRetrievalResponse><ReportStatus>COMPLETED</ReportStatus><Description>The report archive is constructed.</Description></BillingReportRetrievalResponse>'),
6161
new Response(200, ['Content-Type' => 'application/zip'], 'zipcontent'),
62+
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
63+
<ImportTnOrderResponse>
64+
<ImportTnOrder>
65+
<CustomerOrderId>SJM000001</CustomerOrderId>
66+
<OrderCreateDate>2018-01-20T02:59:54.000Z</OrderCreateDate>
67+
<AccountId>9900012</AccountId>
68+
<CreatedByUser>smckinnon</CreatedByUser>
69+
<OrderId>b05de7e6-0cab-4c83-81bb-9379cba8efd0</OrderId>
70+
<LastModifiedDate>2018-01-20T02:59:54.000Z</LastModifiedDate>
71+
<SiteId>202</SiteId>
72+
<SipPeerId>520565</SipPeerId>
73+
<Subscriber>
74+
<Name>ABC Inc.</Name>
75+
<ServiceAddress>
76+
<HouseNumber>11235</HouseNumber>
77+
<StreetName>Back</StreetName>
78+
<City>Denver</City>
79+
<StateCode>CO</StateCode>
80+
<Zip>27541</Zip>
81+
<County>Canyon</County>
82+
</ServiceAddress>
83+
</Subscriber>
84+
<LoaAuthorizingPerson>The Authguy</LoaAuthorizingPerson>
85+
<TelephoneNumbers>
86+
<TelephoneNumber>9199918388</TelephoneNumber>
87+
<TelephoneNumber>4158714245</TelephoneNumber>
88+
<TelephoneNumber>4352154439</TelephoneNumber>
89+
<TelephoneNumber>4352154466</TelephoneNumber>
90+
</TelephoneNumbers>
91+
<ProcessingStatus>PROCESSING</ProcessingStatus>
92+
<Errors/>
93+
</ImportTnOrder>
94+
</ImportTnOrderResponse>"),
6295
]);
6396

6497
self::$container = [];
@@ -278,4 +311,11 @@ public function testBillingReportReadyAndDownload() {
278311
$this->assertEquals("https://api.test.inetwork.com/v1.0/accounts/9500249/billingreports/a12b456c8-abcd-1a3b-a1b2-0a2b4c6d8e0f2/file", self::$container[self::$index]['request']->getUri());
279312
self::$index++;
280313
}
314+
315+
public function testGetImportTnOrder() {
316+
$importTnOrderResponse = self::$account->getImportTnOrder("b05de7e6-0cab-4c83-81bb-9379cba8efd0");
317+
318+
$this->assertEquals("b05de7e6-0cab-4c83-81bb-9379cba8efd0", $importTnOrderResponse->ImportTnOrder->OrderId);
319+
self::$index++;
320+
}
281321
}

0 commit comments

Comments
 (0)