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
99 changes: 97 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`, `removeImportedTnOrders`, `inserviceNumbers`, and `importTnChecker` 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,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);
```
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
70 changes: 70 additions & 0 deletions src/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
16 changes: 16 additions & 0 deletions src/simpleModels/ImportTnCheckerPayload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Iris;

class ImportTnCheckerPayload {
use BaseModel;

protected $fields = array(
"TelephoneNumbers" => array("type" => "\Iris\Phones"),
"ImportTnErrors" => array("type" => "\Iris\ImportTnErrors")
);

public function __construct($data) {
$this->set_data($data, true);
}
}
16 changes: 16 additions & 0 deletions src/simpleModels/ImportTnCheckerResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Iris;

class ImportTnCheckerResponse {
use BaseModel;

protected $fields = array(
"ImportTnCheckerPayload" => array("type" => "\Iris\ImportTnCheckerPayload"),
"Errors" => array("type" => "\Iris\Error")
);

public function __construct($data) {
$this->set_data($data);
}
}
17 changes: 17 additions & 0 deletions src/simpleModels/ImportTnError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Iris;

class ImportTnError {
use BaseModel;

protected $fields = array(
"TelephoneNumbers" => array("type" => "\Iris\Phones"),
"Code" => array("type" => "string"),
"Description" => array("type" => "string")
);

public function __construct($data) {
$this->set_data($data, true);
}
}
15 changes: 15 additions & 0 deletions src/simpleModels/ImportTnErrors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Iris;

class ImportTnErrors {
use BaseModel;

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

public function __construct($data) {
$this->set_data($data, true);
}
}
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);
}
}
18 changes: 18 additions & 0 deletions src/simpleModels/ImportTnOrderResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Iris;

class ImportTnOrderResponse {
use BaseModel;

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

namespace Iris;

class InserviceTns {
use BaseModel;

protected $fields = array(
"TotalCount" => array("type" => "string"),
"TelephoneNumbers" => array("type" => "\Iris\Phones"),
"Links" => array("type" => "\Iris\Links")
);

public function __construct($data) {
$this->set_data($data, true);
}
}
17 changes: 17 additions & 0 deletions src/simpleModels/Links.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Iris;

class Links {
use BaseModel;

protected $fields = array(
"first" => array("type" => "string"),
"next" => array("type" => "string"),
"last" => array("type" => "string")
);

public function __construct($data) {
$this->set_data($data, true);
}
}
18 changes: 18 additions & 0 deletions src/simpleModels/OrderHistory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Iris;

class OrderHistory {
use BaseModel;

protected $fields = array(
"OrderDate" => array("type" => "string"),
"Note" => array("type" => "string"),
"Author" => array("type" => "string"),
"Status" => array("type" => "string")
);

public function __construct($data) {
$this->set_data($data, true);
}
}
15 changes: 15 additions & 0 deletions src/simpleModels/OrderHistoryResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Iris;

class OrderHistoryResponse {
use BaseModel;

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

public function __construct($data) {
$this->set_data($data, true);
}
}
1 change: 0 additions & 1 deletion src/simpleModels/OrderRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading