Skip to content

Commit bbf7163

Browse files
authored
Dx 947 (#57)
* Removed duplicate class definition * Added POST /csrs function * Added csrs/orderid endpoints * Added csr notes endpoint * Added csr order note update * Added tests * Updated version * Updated readme examples * updated readme and notes stuff * Fixed readme and update note url * Fixed models for response * Added state to service address * Fixed error list
1 parent c4984fb commit bbf7163

File tree

11 files changed

+325
-19
lines changed

11 files changed

+325
-19
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PHP Client library for Bandwidth's Phone Number Dashboard (AKA: Dashboard, Iris)
1616
| 2.0.7 | Fixed error handling for Errors fields |
1717
| 2.0.8 | Fixed rate center check |
1818
| 2.1.0 | Added `importTnOrders`, `removeImportedTnOrders`, `inserviceNumbers`, and `importTnChecker` endpoints |
19+
| 2.2.0 | Added `csrs` endpoints |
1920

2021
## Supported PHP Versions
2122

@@ -695,3 +696,65 @@ print_r($account->getRemoveImportedTnOrder("some_id_value")->ProcessingStatus);
695696
```PHP
696697
print_r($account->getRemoveImportedTnOrderHistory("some_id_value")->OrderHistory[0]->Status);
697698
```
699+
700+
## CSR
701+
702+
### Create CSR Order
703+
704+
```PHP
705+
$csrOrder = new \Iris\Csr(array(
706+
"CustomerOrderId" => "order id",
707+
"WorkingOrBillingTelephoneNumber" => "5554443333"
708+
));
709+
710+
$response = $account->createCsrOrder($csrOrder);
711+
print_r($response->OrderId);
712+
```
713+
714+
### Replace CSR Order
715+
716+
```PHP
717+
$csrOrder = new \Iris\Csr(array(
718+
"CustomerOrderId" => "order id",
719+
"WorkingOrBillingTelephoneNumber" => "5554443333"
720+
));
721+
722+
$response = $account->replaceCsrOrder("order_id", $csrOrder);
723+
print_r($response->OrderId);
724+
```
725+
726+
### Get CSR Order
727+
728+
```PHP
729+
$response = $account->getCsrOrder("order_id");
730+
print_r($response->OrderId);
731+
```
732+
733+
### Get CSR Order Notes
734+
735+
```PHP
736+
$response = $account->getCsrOrderNotes("order_id");
737+
print_r($response->Note[0]->Description);
738+
```
739+
740+
### Add CSR Order Note
741+
742+
```PHP
743+
$note = new \Iris\CsrNote(array(
744+
"UserId" => "id",
745+
"Description" => "description"
746+
));
747+
748+
$account->addNoteToCsr("order_id", $note);
749+
```
750+
751+
### Update CSR Order Note
752+
753+
```PHP
754+
$note = new \Iris\CsrNote(array(
755+
"UserId" => "id",
756+
"Description" => "description"
757+
));
758+
759+
$account->updateCsrOrderNote("order_id", "note_id", $note);
760+
```

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.1.0",
7+
"reference": "v2.2.0",
88
"license": "MIT",
99
"authors": [
1010
],

src/Account.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,40 @@ public function getRemoveImportedTnOrderHistory($id) {
320320
$response = parent::_get($url);
321321
return new OrderHistoryResponse($response);
322322
}
323+
324+
public function createCsrOrder(Csr $order) {
325+
$url = sprintf('%s/%s', $this->account_id, 'csrs');
326+
$data = parent::post($url, 'Csr', $order->to_array());
327+
return new CsrResponse($data);
328+
}
329+
330+
public function getCsrOrder($id) {
331+
$url = sprintf('%s/%s/%s', $this->account_id, 'csrs', $id);
332+
$response = parent::_get($url);
333+
return new CsrResponse($response);
334+
}
335+
336+
public function replaceCsrOrder($id, Csr $order) {
337+
$url = sprintf('%s/%s/%s', $this->account_id, 'csrs', $id);
338+
$response = parent::put($url, 'Csr', $order->to_array());
339+
return new CsrResponse($response);
340+
}
341+
342+
public function getCsrOrderNotes($id) {
343+
$url = sprintf('%s/%s/%s/%s', $this->account_id, 'csrs', $id, 'notes');
344+
$response = parent::_get($url);
345+
return new CsrNotesList($response);
346+
}
347+
348+
public function addNoteToCsr($id, CsrNote $note) {
349+
$url = sprintf('%s/%s/%s/%s', $this->account_id, 'csrs', $id, 'notes');
350+
$data = parent::post($url, 'Note', $note->to_array());
351+
return $data;
352+
}
353+
354+
public function updateCsrOrderNote($orderId, $noteId, CsrNote $note) {
355+
$url = sprintf('%s/%s/%s/%s/%s', $this->account_id, 'csrs', $orderId, 'notes', $noteId);
356+
$data = parent::put($url, 'Note', $note->to_array());
357+
return $data;
358+
}
323359
}

src/simpleModels/Csr.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class Csr {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"CustomerOrderId" => array("type" => "string"),
10+
"WorkingOrBillingTelephoneNumber" => array("type" => "string"),
11+
"AccountNumber" => array("type" => "string"),
12+
"AccountTelephoneNumber" => array("type" => "string"),
13+
"EndUserName" => array("type" => "string"),
14+
"AuthorizingUserName" => array("type" => "string"),
15+
"CustomerCode" => array("type" => "string"),
16+
"EndUserPIN" => array("type" => "string"),
17+
"EndUserPassword" => array("type" => "string"),
18+
"AddressLine1" => array("type" => "string"),
19+
"City" => array("type" => "string"),
20+
"State" => array("type" => "string"),
21+
"ZIPCode" => array("type" => "string"),
22+
"TypeOfService" => array("type" => "string"),
23+
"Status" => array("type" => "string")
24+
);
25+
26+
public function __construct($data) {
27+
$this->set_data($data);
28+
}
29+
}

src/simpleModels/CsrData.php

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

src/simpleModels/CsrNote.php

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 CsrNote {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"Id" => array("type" => "string"),
10+
"UserId" => array("type" => "string"),
11+
"Description" => array("type" => "string"),
12+
"LastDateModifier" => array("type" => "string")
13+
);
14+
15+
public function __construct($data) {
16+
$this->set_data($data);
17+
}
18+
}

src/simpleModels/CsrNotesList.php

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

src/simpleModels/CsrResponse.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class CsrResponse {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"OrderId" => array("type" => "string"),
10+
"Status" => array("type" => "string"),
11+
"AccountNumber" => array("type" => "string"),
12+
"AccountTelephoneNumber" => array("type" => "string"),
13+
"EndUserName" => array("type" => "string"),
14+
"AuthorizingUserName" => array("type" => "string"),
15+
"CustomerCode" => array("type" => "string"),
16+
"EndUserPIN" => array("type" => "string"),
17+
"EndUserPassword" => array("type" => "string"),
18+
"AddressLine1" => array("type" => "string"),
19+
"City" => array("type" => "string"),
20+
"State" => array("type" => "string"),
21+
"ZIPCode" => array("type" => "string"),
22+
"TypeOfService" => array("type" => "string"),
23+
"Errors" => array("type" => "\Iris\ErrorList"),
24+
"CustomerOrderId" => array("type" => "string"),
25+
"LastModifiedBy" => array("type" => "string"),
26+
"OrderCreateDate" => array("type" => "string"),
27+
"AccountId" => array("type" => "string"),
28+
"LastModifiedDate" => array("type" => "string"),
29+
"AccountNumber" => array("type" => "string"),
30+
"AccountTelephoneNumber" => array("type" => "string"),
31+
"EndUserName" => array("type" => "string"),
32+
"AuthorizingUserName" => array("type" => "string"),
33+
"CustomerCode" => array("type" => "string"),
34+
"EndUserPIN" => array("type" => "string"),
35+
"EndUserPassword" => array("type" => "string"),
36+
"AddressLine1" => array("type" => "string"),
37+
"City" => array("type" => "string"),
38+
"State" => array("type" => "string"),
39+
"ZIPCode" => array("type" => "string"),
40+
"TypeOfService" => array("type" => "string"),
41+
"CsrData" => array("type" => "\Iris\CsrData")
42+
);
43+
44+
public function __construct($data) {
45+
$this->set_data($data);
46+
}
47+
}

src/simpleModels/OrderHistory.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/simpleModels/ServiceAddress.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ServiceAddress {
1010
"HouseNumber" => array("type" => "string", "required" => true),
1111
"StreetName" => array("type" => "string", "required" => true),
1212
"StateCode" => array("type" => "string", "required" => true),
13+
"State" => array("type" => "string"),
1314
"Zip" => array("type" => "string"),
1415
"Country" => array("type" => "string"),
1516
"County" => array("type" => "string"),
@@ -21,6 +22,7 @@ class ServiceAddress {
2122
"AddressLine2" => array("type" => "string"),
2223
"PlusFour" => array("type" => "string"),
2324
"AddressType" => array("type" => "string"),
25+
"UnparsedAddress" => array("type" => "string")
2426
);
2527

2628
public function __construct($data) {

0 commit comments

Comments
 (0)