Merge branch 'fronkdev' of code.fronk.at:fronk/thetool into fronkdev
This commit is contained in:
@@ -266,6 +266,122 @@ class Citycom_OanApiClient {
|
||||
return $types;
|
||||
}
|
||||
|
||||
public function getOntStatus($oan_id) {
|
||||
if(!$this->token) {
|
||||
$this->getAuthToken();
|
||||
if(!$this->token) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->baseurl.CITYCOM_OAN_API_EP_GET_ONT_STATUS;
|
||||
$url = str_replace("{oan_id}", $oan_id, $url);
|
||||
$ctx_options = [
|
||||
"http" => [
|
||||
"ignore_errors" => true,
|
||||
"method" => "GET",
|
||||
"header" => [
|
||||
"Accept: application/json",
|
||||
"Authorization: Bearer ".$this->token,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$ctx = stream_context_create($ctx_options);
|
||||
$output = file_get_contents($url, false, $ctx);
|
||||
|
||||
$resp = json_decode($output);
|
||||
if(!is_object($resp)) {
|
||||
return false;
|
||||
}
|
||||
if(!property_exists($resp, "success") || !$resp->success || !property_exists($resp, "data")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp->data;
|
||||
}
|
||||
|
||||
public function getOntPortStatus($oan_id) {
|
||||
if(!$this->token) {
|
||||
$this->getAuthToken();
|
||||
if(!$this->token) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->baseurl.CITYCOM_OAN_API_EP_GET_ONT_PORTSTATUS;
|
||||
$url = str_replace("{oan_id}", $oan_id, $url);
|
||||
$ctx_options = [
|
||||
"http" => [
|
||||
"ignore_errors" => true,
|
||||
"method" => "GET",
|
||||
"header" => [
|
||||
"Accept: application/json",
|
||||
"Authorization: Bearer ".$this->token,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$ctx = stream_context_create($ctx_options);
|
||||
$output = file_get_contents($url, false, $ctx);
|
||||
|
||||
$resp = json_decode($output);
|
||||
if(!is_object($resp)) {
|
||||
return false;
|
||||
}
|
||||
if(!property_exists($resp, "success") || !$resp->success || !property_exists($resp, "data")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp->data;
|
||||
}
|
||||
|
||||
public function getOntMacAddresses($oan_id) {
|
||||
if(!$this->token) {
|
||||
$this->getAuthToken();
|
||||
if(!$this->token) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->baseurl.CITYCOM_OAN_API_EP_GET_ONT_MACADDRESSES;
|
||||
$url = str_replace("{oan_id}", $oan_id, $url);
|
||||
$ctx_options = [
|
||||
"http" => [
|
||||
"ignore_errors" => true,
|
||||
"method" => "GET",
|
||||
"header" => [
|
||||
"Accept: application/json",
|
||||
"Authorization: Bearer ".$this->token,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$ctx = stream_context_create($ctx_options);
|
||||
$output = file_get_contents($url, false, $ctx);
|
||||
|
||||
$resp = json_decode($output);
|
||||
if(!is_object($resp)) {
|
||||
return false;
|
||||
}
|
||||
if(!property_exists($resp, "success") || !$resp->success || !property_exists($resp, "data")) {
|
||||
return false;
|
||||
}
|
||||
return $resp->data;
|
||||
}
|
||||
|
||||
public function getOntStatusDetail($oan_id) {
|
||||
$ont_status = $this->getOntStatus($oan_id);
|
||||
$ont_port_status = $this->getOntPortStatus($oan_id);
|
||||
$ont_mac_addresses = $this->getOntMacAddresses($oan_id);
|
||||
|
||||
return [
|
||||
$ont_status,
|
||||
$ont_port_status,
|
||||
$ont_mac_addresses
|
||||
];
|
||||
}
|
||||
|
||||
private function getAuthToken() {
|
||||
$token = new mfConfig("adb.import.citycom.auth.token");
|
||||
if($token && $token->value()) {
|
||||
|
||||
Reference in New Issue
Block a user