Merge branch 'fronkdev' into 'master'
Added status check logic in Citycom API Helper and Snopp API See merge request fronk/thetool!1659
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace application\Api\v1\Modules\Operationaldata;
|
namespace application\Api\v1\Modules\Operationaldata;
|
||||||
use application\Api\v1\Modules;
|
use application\Api\v1\Modules;
|
||||||
|
use PreorderCtag;
|
||||||
|
|
||||||
require_once(APPDIR."/Api/v1/Modules/ApiControllerModule.php");
|
require_once(APPDIR."/Api/v1/Modules/ApiControllerModule.php");
|
||||||
|
|
||||||
@@ -56,6 +57,17 @@ class SnoppCitycom extends Modules\ApiControllerModule
|
|||||||
return \mfResponse::NotFound(["message" => "Home not found"]);
|
return \mfResponse::NotFound(["message" => "Home not found"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if all services are ordered and active, finish order and return active
|
||||||
|
$ctag = PreorderCtag::getFirstActive(["preorder_id" => $preorder->id, "service_type" => "inet"]);
|
||||||
|
if($ctag->ext_id && $ctag->ext_status == "finished") {
|
||||||
|
if($preorder->status->code < 500) {
|
||||||
|
$preorder->setNewStatusCode(500);
|
||||||
|
$preorder->save();
|
||||||
|
}
|
||||||
|
return \mfResponse::Ok(["message" => "Service active already", "activation_status" => "active"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Home must have Status 300, else return deferred
|
// Home must have Status 300, else return deferred
|
||||||
if($wohneinheit->status->code < 300) {
|
if($wohneinheit->status->code < 300) {
|
||||||
return \mfResponse::Ok(["message" => "ONT not yet installed. Deferred", "activation_status" => "deferred"]);
|
return \mfResponse::Ok(["message" => "ONT not yet installed. Deferred", "activation_status" => "deferred"]);
|
||||||
@@ -86,15 +98,21 @@ class SnoppCitycom extends Modules\ApiControllerModule
|
|||||||
$cc_api = new \Citycom_OanApiHelper($cc_api_client);
|
$cc_api = new \Citycom_OanApiHelper($cc_api_client);
|
||||||
|
|
||||||
// order Service at Citycom and set Preorder to 500 Finished
|
// order Service at Citycom and set Preorder to 500 Finished
|
||||||
$services = $cc_api->orderServices($preorder, $cc_home_id, $data);
|
if(!$cc_api->orderServices($preorder, $cc_home_id, $data)) {
|
||||||
if(!$services) {
|
|
||||||
return \mfResponse::InternalServerError(["message" => "Error activating service"]);
|
return \mfResponse::InternalServerError(["message" => "Error activating service"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// live check if service is active, if not return deferred
|
||||||
|
$ctag = PreorderCtag::getFirstActive(["preorder_id" => $preorder->id, "service_type" => "inet"]);
|
||||||
|
if($ctag->ext_id && $ctag->ext_status == "finished") {
|
||||||
|
if($preorder->status->code < 500) {
|
||||||
$preorder->setNewStatusCode(500);
|
$preorder->setNewStatusCode(500);
|
||||||
$preorder->save();
|
$preorder->save();
|
||||||
|
}
|
||||||
|
return \mfResponse::Ok(["message" => "Service active already", "activation_status" => "active"]);
|
||||||
|
}
|
||||||
|
|
||||||
return \mfResponse::Ok(["message" => "Services ordered successfully", "activation_status" => "active"]);
|
return \mfResponse::Ok(["message" => "Services ordered, not yet finished", "activation_status" => "deferred"]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,20 @@ class Citycom_OanApiHelper {
|
|||||||
// order all services and save ctags
|
// order all services and save ctags
|
||||||
$cc_service_types = $this->api->getServiceTypes();
|
$cc_service_types = $this->api->getServiceTypes();
|
||||||
|
|
||||||
|
$this->log->debug(print_r($want_services, true));
|
||||||
|
|
||||||
|
// check if we have these services already
|
||||||
|
foreach($cc_service_types as $stype) {
|
||||||
|
if(!in_array($stype->name, CITYCOM_OAN_API_SERVICES_FOR_ORDER)) continue;
|
||||||
|
$ctag_service_type = array_flip(CITYCOM_OAN_API_SERVICES_FOR_ORDER)[$stype->name];
|
||||||
|
if(PreorderCtag::getFirstActive(["preorder_id" => $preorder->id, "service_type" => $ctag_service_type])) {
|
||||||
|
// service was ordered already, remove from want_services
|
||||||
|
unset($want_services[$ctag_service_type]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->log->debug(print_r($want_services, true));
|
||||||
|
|
||||||
$new_services = [];
|
$new_services = [];
|
||||||
|
|
||||||
if($ctag_range_search) {
|
if($ctag_range_search) {
|
||||||
@@ -124,7 +138,7 @@ class Citycom_OanApiHelper {
|
|||||||
|
|
||||||
$this->log->debug(print_r($ctags, true));
|
$this->log->debug(print_r($ctags, true));
|
||||||
|
|
||||||
if(!$ctags) {
|
if(!is_array($ctags)) {
|
||||||
$this->log->error(__METHOD__.": No Free Ctags (Preorder ".$preorder->id.")");
|
$this->log->error(__METHOD__.": No Free Ctags (Preorder ".$preorder->id.")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -141,7 +155,6 @@ class Citycom_OanApiHelper {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$service_count = 0;
|
$service_count = 0;
|
||||||
$service_return = [];
|
|
||||||
foreach($cc_service_types as $stype) {
|
foreach($cc_service_types as $stype) {
|
||||||
// was this service type requested
|
// was this service type requested
|
||||||
if(!in_array($stype->name, $want_services)) continue;
|
if(!in_array($stype->name, $want_services)) continue;
|
||||||
@@ -173,7 +186,7 @@ class Citycom_OanApiHelper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$service_return[] = [
|
/*$service_return[] = [
|
||||||
"service_number" => $new_service->service_number,
|
"service_number" => $new_service->service_number,
|
||||||
"sublocation_id" => $sublocation_id,
|
"sublocation_id" => $sublocation_id,
|
||||||
"service_type" => $ctag_service_type,
|
"service_type" => $ctag_service_type,
|
||||||
@@ -182,7 +195,7 @@ class Citycom_OanApiHelper {
|
|||||||
"serial" => $new_service->ont->serial,
|
"serial" => $new_service->ont->serial,
|
||||||
"fsan" => $new_service->ont->fsan,
|
"fsan" => $new_service->ont->fsan,
|
||||||
],
|
],
|
||||||
];
|
];*/
|
||||||
|
|
||||||
/*$service_return[] = [
|
/*$service_return[] = [
|
||||||
"sublocation_id" => $sublocation_id,
|
"sublocation_id" => $sublocation_id,
|
||||||
@@ -225,7 +238,7 @@ class Citycom_OanApiHelper {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $service_return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user