forked from Bandwidth/php-bandwidth-iris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPortoutModel.php
157 lines (135 loc) · 4.53 KB
/
PortoutModel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* @model Portout
* https://api.test.inetwork.com/v1.0/accounts/portouts
*
*
*
* provides:
* get/0
*
*/
namespace Iris;
final class Portouts extends RestEntry{
public function __construct($parent) {
$this->parent = $parent;
parent::_init($this->parent->get_rest_client(), $this->parent->get_relative_namespace());
}
public function getList($filters = Array()) {
$out = [];
$portouts = parent::_get('portouts', $filters, Array("page"=> 1, "size" => 30), Array("page", "size"));
if($portouts['lnpPortInfoForGivenStatus']) {
$items = $portouts['lnpPortInfoForGivenStatus'];
if($this->is_assoc($items)) {
$items = [ $items ];
}
foreach($items as $portout) {
$out[] = new Portin($this, $portout);
}
}
return $out;
}
/**
* Create new Portin
* @params array $data
* @return \Iris\Portin
*/
public function create($data, $save = true) {
$portout = new Portout($this, $data);
if($save)
$portout->save();
return $portout;
}
public function portout($id)
{
$portouts = new Portout($this, ["OrderId" => $id]);
$portouts->get();
return $portouts;
}
public function get_appendix() {
return '/portouts';
}
}
class Portout extends RestEntry {
use BaseModel;
protected $fields = array(
"CountOfTNs" => [ "type" => "string"],
"lastModifiedDate" => [ "type" => "string"],
"OrderDate" => [ "type" => "string"],
"OrderType" => [ "type" => "string"],
"LNPLosingCarrierId" => [ "type" => "string"],
"LNPLosingCarrierName" => [ "type" => "string"],
"RequestedFOCDate" => [ "type" => "string"],
"VendorId" => [ "type" => "string"],
"VendorName" => [ "type" => "string"],
"PON" => [ "type" => "string"],
"AccountId" => [ "type" => "string"],
"PeerId" => [ "type" => "string"],
"OrderCreateDate" => [ "type" => "string"],
"LastModifiedBy" => [ "type" => "string"],
"PartialPort" => [ "type" => "string"],
"Immediately" => [ "type" => "string"],
"OrderId" => array("type" => "string"),
"Status" => array("type" => "\Iris\Status"),
"Errors" => array("type" => "string"),
"ProcessingStatus" => array("type" => "string"),
"CustomerOrderId" => array("type" => "string"),
"RequestedFocDate" => array("type" => "string"),
"AlternateSpid" => array("type" => "string"),
"WirelessInfo" => array("type" => "\Iris\WirelessInfo"),
"LosingCarrierName" => array("type" => "string"),
"LastModifiedDate" => array("type" => "string"),
"userId" => array("type" => "string"),
"BillingTelephoneNumber" => array("type" => "string"),
"Subscriber" => array("type" => "\Iris\Subscriber"),
"LoaAuthorizingPerson" => array("type" => "string"),
"ListOfPhoneNumbers" => array("type" => "\Iris\Phones"),
"SiteId" => array("type" => "string"),
"Triggered" => array("type" => "string"),
"BillingType" => array("type" => "string"),
"PortOutStatus" => array("type" => "string"),
"ActualFocDate" => array("type" => "string"),
"SPID" => array("type" => "string")
);
public function __construct($parent, $data) {
$this->set_data($data);
$this->parent = $parent;
parent::_init($parent->get_rest_client(), $parent->get_relative_namespace());
$this->notes = null;
}
public function get() {
$data = parent::_get($this->get_id());
$this->set_data($data);
}
public function totals($filters = array()) {
$url = sprintf('%s/%s', $this->get_id(), 'totals');
$response = parent::_get($url, $filters);
return $response['Count'];
}
/**
* Get Notes of Entity
* @return \Iris\Notes
*/
public function notes() {
if(is_null($this->notes))
$this->notes = new Notes($this);
return $this->notes;
}
/**
* Get Entity Id
* @return type
* @throws Exception in case of OrderId is null
*/
private function get_id() {
if(!isset($this->OrderId))
throw new Exception("You can't use this function without OrderId");
return $this->OrderId;
}
/**
* Provide relative url
* @return string
*/
public function get_appendix() {
return '/'.$this->get_id();
}
}