Skip to content
Merged
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
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
],
Expand Down
25 changes: 25 additions & 0 deletions src/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
27 changes: 27 additions & 0 deletions src/simpleModels/ImportTnOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Iris;

class ImportTnOrder {
use BaseModel;

protected $fields = array(
"CustomerOrderId" => 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);
}
}
15 changes: 15 additions & 0 deletions src/simpleModels/ImportTnOrderResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Iris;

class ImportTnOrderResponse {
use BaseModel;

protected $fields = array(
"ImportTnOrder" => array("type" => "\Iris\ImportTnOrder")
);

public function __construct($data) {
$this->set_data($data);
}
}
40 changes: 40 additions & 0 deletions tests/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'], '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><BillingReportCreationResponse><ReportStatus>RECEIVED</ReportStatus><Description>The report archive is currently being constructed.</Description></BillingReportCreationResponse>'),
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>'),
new Response(200, ['Content-Type' => 'application/zip'], 'zipcontent'),
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<ImportTnOrderResponse>
<ImportTnOrder>
<CustomerOrderId>SJM000001</CustomerOrderId>
<OrderCreateDate>2018-01-20T02:59:54.000Z</OrderCreateDate>
<AccountId>9900012</AccountId>
<CreatedByUser>smckinnon</CreatedByUser>
<OrderId>b05de7e6-0cab-4c83-81bb-9379cba8efd0</OrderId>
<LastModifiedDate>2018-01-20T02:59:54.000Z</LastModifiedDate>
<SiteId>202</SiteId>
<SipPeerId>520565</SipPeerId>
<Subscriber>
<Name>ABC Inc.</Name>
<ServiceAddress>
<HouseNumber>11235</HouseNumber>
<StreetName>Back</StreetName>
<City>Denver</City>
<StateCode>CO</StateCode>
<Zip>27541</Zip>
<County>Canyon</County>
</ServiceAddress>
</Subscriber>
<LoaAuthorizingPerson>The Authguy</LoaAuthorizingPerson>
<TelephoneNumbers>
<TelephoneNumber>9199918388</TelephoneNumber>
<TelephoneNumber>4158714245</TelephoneNumber>
<TelephoneNumber>4352154439</TelephoneNumber>
<TelephoneNumber>4352154466</TelephoneNumber>
</TelephoneNumbers>
<ProcessingStatus>PROCESSING</ProcessingStatus>
<Errors/>
</ImportTnOrder>
</ImportTnOrderResponse>"),
]);

self::$container = [];
Expand Down Expand Up @@ -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++;
}
}