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
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PHP Client library for Bandwidth's Phone Number Dashboard (AKA: Dashboard, Iris)
| 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 |
| 2.2.0 | Added `csrs` endpoints |

## Supported PHP Versions

Expand Down Expand Up @@ -695,3 +696,65 @@ print_r($account->getRemoveImportedTnOrder("some_id_value")->ProcessingStatus);
```PHP
print_r($account->getRemoveImportedTnOrderHistory("some_id_value")->OrderHistory[0]->Status);
```

## CSR

### Create CSR Order

```PHP
$csrOrder = new \Iris\Csr(array(
"CustomerOrderId" => "order id",
"WorkingOrBillingTelephoneNumber" => "5554443333"
));

$response = $account->createCsrOrder($csrOrder);
print_r($response->OrderId);
```

### Replace CSR Order

```PHP
$csrOrder = new \Iris\Csr(array(
"CustomerOrderId" => "order id",
"WorkingOrBillingTelephoneNumber" => "5554443333"
));

$response = $account->replaceCsrOrder("order_id", $csrOrder);
print_r($response->OrderId);
```

### Get CSR Order

```PHP
$response = $account->getCsrOrder("order_id");
print_r($response->OrderId);
```

### Get CSR Order Notes

```PHP
$response = $account->getCsrOrderNotes("order_id");
print_r($response->Note[0]->Description);
```

### Add CSR Order Note

```PHP
$note = new \Iris\CsrNote(array(
"UserId" => "id",
"Description" => "description"
));

$account->addNoteToCsr("order_id", $note);
```

### Update CSR Order Note

```PHP
$note = new \Iris\CsrNote(array(
"UserId" => "id",
"Description" => "description"
));

$account->updateCsrOrderNote("order_id", "note_id", $note);
```
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.1.0",
"reference": "v2.2.0",
"license": "MIT",
"authors": [
],
Expand Down
36 changes: 36 additions & 0 deletions src/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,40 @@ public function getRemoveImportedTnOrderHistory($id) {
$response = parent::_get($url);
return new OrderHistoryResponse($response);
}

public function createCsrOrder(Csr $order) {
$url = sprintf('%s/%s', $this->account_id, 'csrs');
$data = parent::post($url, 'Csr', $order->to_array());
return new CsrResponse($data);
}

public function getCsrOrder($id) {
$url = sprintf('%s/%s/%s', $this->account_id, 'csrs', $id);
$response = parent::_get($url);
return new CsrResponse($response);
}

public function replaceCsrOrder($id, Csr $order) {
$url = sprintf('%s/%s/%s', $this->account_id, 'csrs', $id);
$response = parent::put($url, 'Csr', $order->to_array());
return new CsrResponse($response);
}

public function getCsrOrderNotes($id) {
$url = sprintf('%s/%s/%s/%s', $this->account_id, 'csrs', $id, 'notes');
$response = parent::_get($url);
return new CsrNotesList($response);
}

public function addNoteToCsr($id, CsrNote $note) {
$url = sprintf('%s/%s/%s/%s', $this->account_id, 'csrs', $id, 'notes');
$data = parent::post($url, 'Note', $note->to_array());
return $data;
}

public function updateCsrOrderNote($orderId, $noteId, CsrNote $note) {
$url = sprintf('%s/%s/%s/%s/%s', $this->account_id, 'csrs', $orderId, 'notes', $noteId);
$data = parent::put($url, 'Note', $note->to_array());
return $data;
}
}
29 changes: 29 additions & 0 deletions src/simpleModels/Csr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Iris;

class Csr {
use BaseModel;

protected $fields = array(
"CustomerOrderId" => array("type" => "string"),
"WorkingOrBillingTelephoneNumber" => array("type" => "string"),
"AccountNumber" => array("type" => "string"),
"AccountTelephoneNumber" => array("type" => "string"),
"EndUserName" => array("type" => "string"),
"AuthorizingUserName" => array("type" => "string"),
"CustomerCode" => array("type" => "string"),
"EndUserPIN" => array("type" => "string"),
"EndUserPassword" => array("type" => "string"),
"AddressLine1" => array("type" => "string"),
"City" => array("type" => "string"),
"State" => array("type" => "string"),
"ZIPCode" => array("type" => "string"),
"TypeOfService" => array("type" => "string"),
"Status" => array("type" => "string")
);

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

namespace Iris;

class CsrData {
use BaseModel;

protected $fields = array(
"WorkingTelephoneNumber" => array("type" => "string"),
"AccountNumber" => array("type" => "string"),
"CustomerName" => array("type" => "string"),
"ServiceAddress" => array("type" => "\Iris\ServiceAddress"),
"WorkingTelephoneNumbersOnAccount" => array("type" => "\Iris\TelephoneNumbers")
);

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

namespace Iris;

class CsrNote {
use BaseModel;

protected $fields = array(
"Id" => array("type" => "string"),
"UserId" => array("type" => "string"),
"Description" => array("type" => "string"),
"LastDateModifier" => array("type" => "string")
);

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

namespace Iris;

class CsrNotesList {
use BaseModel;

protected $fields = array(
"Note" => array("type" => "\Iris\CsrNote")
);
public function __construct($data) {
$this->set_data($data);
}
}
47 changes: 47 additions & 0 deletions src/simpleModels/CsrResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Iris;

class CsrResponse {
use BaseModel;

protected $fields = array(
"OrderId" => array("type" => "string"),
"Status" => array("type" => "string"),
"AccountNumber" => array("type" => "string"),
"AccountTelephoneNumber" => array("type" => "string"),
"EndUserName" => array("type" => "string"),
"AuthorizingUserName" => array("type" => "string"),
"CustomerCode" => array("type" => "string"),
"EndUserPIN" => array("type" => "string"),
"EndUserPassword" => array("type" => "string"),
"AddressLine1" => array("type" => "string"),
"City" => array("type" => "string"),
"State" => array("type" => "string"),
"ZIPCode" => array("type" => "string"),
"TypeOfService" => array("type" => "string"),
"Errors" => array("type" => "\Iris\ErrorList"),
"CustomerOrderId" => array("type" => "string"),
"LastModifiedBy" => array("type" => "string"),
"OrderCreateDate" => array("type" => "string"),
"AccountId" => array("type" => "string"),
"LastModifiedDate" => array("type" => "string"),
"AccountNumber" => array("type" => "string"),
"AccountTelephoneNumber" => array("type" => "string"),
"EndUserName" => array("type" => "string"),
"AuthorizingUserName" => array("type" => "string"),
"CustomerCode" => array("type" => "string"),
"EndUserPIN" => array("type" => "string"),
"EndUserPassword" => array("type" => "string"),
"AddressLine1" => array("type" => "string"),
"City" => array("type" => "string"),
"State" => array("type" => "string"),
"ZIPCode" => array("type" => "string"),
"TypeOfService" => array("type" => "string"),
"CsrData" => array("type" => "\Iris\CsrData")
);

public function __construct($data) {
$this->set_data($data);
}
}
18 changes: 0 additions & 18 deletions src/simpleModels/OrderHistory.php

This file was deleted.

2 changes: 2 additions & 0 deletions src/simpleModels/ServiceAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ServiceAddress {
"HouseNumber" => array("type" => "string", "required" => true),
"StreetName" => array("type" => "string", "required" => true),
"StateCode" => array("type" => "string", "required" => true),
"State" => array("type" => "string"),
"Zip" => array("type" => "string"),
"Country" => array("type" => "string"),
"County" => array("type" => "string"),
Expand All @@ -21,6 +22,7 @@ class ServiceAddress {
"AddressLine2" => array("type" => "string"),
"PlusFour" => array("type" => "string"),
"AddressType" => array("type" => "string"),
"UnparsedAddress" => array("type" => "string")
);

public function __construct($data) {
Expand Down
96 changes: 96 additions & 0 deletions tests/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,72 @@ public static function setUpBeforeClass() {
</ImportTnErrors>
</ImportTnCheckerPayload>
</ImportTnCheckerResponse>"),
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<CsrResponse>
<OrderId>4f5b3804-3d0d-49de-a133-d4b67ad6fa11</OrderId>
<Status>RECEIVED</Status>
<AccountNumber>123456789ABC</AccountNumber>
<AccountTelephoneNumber>9196191234</AccountTelephoneNumber>
<EndUserName>Bandwidth User</EndUserName>
<AuthorizingUserName>Auth Bandwidth User</AuthorizingUserName>
<CustomerCode>123</CustomerCode>
<EndUserPIN>123ABC</EndUserPIN>
<EndUserPassword>supersecretpassword123</EndUserPassword>
<AddressLine1>900 Main Campus Drive</AddressLine1>
<City>Raleigh</City>
<State>NC</State>
<ZIPCode>27606</ZIPCode>
<TypeOfService>business</TypeOfService>
</CsrResponse>"),
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<CsrResponse>
<OrderId>4f5b3804-3d0d-49de-a133-d4b67ad6fa11</OrderId>
<Status>RECEIVED</Status>
<AccountNumber>123456789ABC</AccountNumber>
<AccountTelephoneNumber>9196191234</AccountTelephoneNumber>
<EndUserName>Bandwidth User</EndUserName>
<AuthorizingUserName>Auth Bandwidth User</AuthorizingUserName>
<CustomerCode>123</CustomerCode>
<EndUserPIN>123ABC</EndUserPIN>
<EndUserPassword>supersecretpassword123</EndUserPassword>
<AddressLine1>900 Main Campus Drive</AddressLine1>
<City>Raleigh</City>
<State>NC</State>
<ZIPCode>27606</ZIPCode>
<TypeOfService>business</TypeOfService>
</CsrResponse>"),
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<CsrResponse>
<OrderId>4f5b3804-3d0d-49de-a133-d4b67ad6fa11</OrderId>
<Status>RECEIVED</Status>
<AccountNumber>123456789ABC</AccountNumber>
<AccountTelephoneNumber>9196191234</AccountTelephoneNumber>
<EndUserName>Bandwidth User</EndUserName>
<AuthorizingUserName>Auth Bandwidth User</AuthorizingUserName>
<CustomerCode>123</CustomerCode>
<EndUserPIN>123ABC</EndUserPIN>
<EndUserPassword>supersecretpassword123</EndUserPassword>
<AddressLine1>900 Main Campus Drive</AddressLine1>
<City>Raleigh</City>
<State>NC</State>
<ZIPCode>27606</ZIPCode>
<TypeOfService>business</TypeOfService>
</CsrResponse>"),
new Response(200, [], "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<Notes>
<Note>
<Id>87037</Id>
<UserId>jbm</UserId>
<Description>This is a test note</Description>
<LastDateModifier>2014-11-16T04:01:10.000Z</LastDateModifier>
</Note>
<Note>
<Id>87039</Id>
<UserId>smckinnon</UserId>
<Description>This is a second test note</Description>
<LastDateModifier>2014-11-16T04:08:46.000Z</LastDateModifier>
</Note>
</Notes> "),
]);

self::$container = [];
Expand Down Expand Up @@ -392,4 +458,34 @@ public function testCheckTnsPortability() {

self::$index++;
}

public function testCreateCsrOrder() {
$request = new \Iris\Csr(array());
$response = self::$account->createCsrOrder($request);

$this->assertEquals("4f5b3804-3d0d-49de-a133-d4b67ad6fa11", $response->OrderId);
self::$index++;
}

public function testGetCsrOrder() {
$response = self::$account->getCsrOrder("id");
$this->assertEquals("4f5b3804-3d0d-49de-a133-d4b67ad6fa11", $response->OrderId);
self::$index++;
}

public function testReplaceCsrOrder() {
$request = new \Iris\Csr(array());
$response = self::$account->replaceCsrOrder("id", $request);

$this->assertEquals("4f5b3804-3d0d-49de-a133-d4b67ad6fa11", $response->OrderId);
self::$index++;
}

public function testGetCsrOrderNotes() {
$response = self::$account->getCsrOrderNotes("order_id", "note");

$this->assertEquals("This is a test note", $response->Note[0]->Description);
$this->assertEquals("This is a second test note", $response->Note[1]->Description);
self::$index++;
}
}