From f52aa5825cb4035be9ba959c9fa44ef9d8dd403c Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Mon, 30 Sep 2024 15:43:18 +0200 Subject: [PATCH 1/2] added estmk networks for conneced state update in opsdata api --- .../Api/v1/Modules/Operationaldata/Snopp.php | 24 ++++++++++++++----- .../Api/v1/OperationaldataApicontroller.php | 10 -------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/application/Api/v1/Modules/Operationaldata/Snopp.php b/application/Api/v1/Modules/Operationaldata/Snopp.php index b585e0073..b77bba351 100644 --- a/application/Api/v1/Modules/Operationaldata/Snopp.php +++ b/application/Api/v1/Modules/Operationaldata/Snopp.php @@ -16,17 +16,27 @@ class Snopp extends Modules\ApiControllerModule } - public function setPreorderConnected($id) { - if(!$id || !is_numeric($id)) { + public function setPreorderConnected($req_id) { + if(!$req_id) { return \mfResponse::BadRequest(["message" => "id missing"]); } - $wohneinheit = new \ADBWohneinheit($id); - if(!$wohneinheit->id) { - return \mfResponse::NotFound(["message" => "Home not found"]); + $wohneinheit = false; + if(is_numeric($req_id)) { + $id = $req_id; + $wohneinheit = new \ADBWohneinheit($id); + } + if(!$wohneinheit || !$wohneinheit->id) { + $oaid = $req_id; + $wohneinheit = \ADBWohneinheitModel::getFirst(["oaid" => $oaid]); + if (!$wohneinheit) { + return \mfResponse::NotFound(["message" => "Home not found"]); + } } - $preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $id]); + //print_r($wohneinheit); + + $preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $wohneinheit->id]); if(!$preorder) { return \mfResponse::NotFound(["message" => "Home not found"]); } @@ -41,6 +51,8 @@ class Snopp extends Modules\ApiControllerModule $preorder->save(); } + //print_r($preorder);exit; + return \mfResponse::Ok(["message" => "OK"]); } diff --git a/application/Api/v1/OperationaldataApicontroller.php b/application/Api/v1/OperationaldataApicontroller.php index f614bbfa8..f8314f2bf 100644 --- a/application/Api/v1/OperationaldataApicontroller.php +++ b/application/Api/v1/OperationaldataApicontroller.php @@ -49,16 +49,6 @@ class OperationaldataApicontroller extends mfBaseApicontroller $this->addRoute("/operationaldata/home/:id/connected", [$modules["Snopp"], "setPreorderConnected"], "POST"); $this->addRoute("/operationaldata/home/:id/active", [$modules["Snopp"], "setPreorderActive"], "POST"); - /*$this->addRoute("/preorder/open", "getOpenPreorders", "GET"); - $this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "getCifData"], "GET"); - $this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "userSetCif"], "POST"); - - $this->addRoute("/preorder/:code/clientInstallationFinished", [$modules["Cif"], "providerSetCif"], "POST"); - $this->addRoute("/preorder/:code/serviceActivated", [$modules["Activation"], "setServiceActive"], "POST"); - $this->addRoute("/preorder/:code", "getPreorder", "GET"); - $this->addRoute("/preorder/:code", "cancelPreorder", "DELETE"); - */ - } /* From fa404eec3ce8ca21fd3d02f4daaa22cea8c6444a Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Mon, 30 Sep 2024 16:01:23 +0200 Subject: [PATCH 2/2] snopp can also update active state for estmk networks now --- .../Api/v1/Modules/Operationaldata/Snopp.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/application/Api/v1/Modules/Operationaldata/Snopp.php b/application/Api/v1/Modules/Operationaldata/Snopp.php index b77bba351..ce1046d49 100644 --- a/application/Api/v1/Modules/Operationaldata/Snopp.php +++ b/application/Api/v1/Modules/Operationaldata/Snopp.php @@ -56,17 +56,25 @@ class Snopp extends Modules\ApiControllerModule return \mfResponse::Ok(["message" => "OK"]); } - public function setPreorderActive($id) { - if(!$id || !is_numeric($id)) { + public function setPreorderActive($req_id) { + if(!$req_id) { return \mfResponse::BadRequest(["message" => "id missing"]); } - $wohneinheit = new \ADBWohneinheit($id); - if(!$wohneinheit->id) { - return \mfResponse::NotFound(["message" => "Home not found"]); + $wohneinheit = false; + if(is_numeric($req_id)) { + $id = $req_id; + $wohneinheit = new \ADBWohneinheit($id); + } + if(!$wohneinheit || !$wohneinheit->id) { + $oaid = $req_id; + $wohneinheit = \ADBWohneinheitModel::getFirst(["oaid" => $oaid]); + if (!$wohneinheit) { + return \mfResponse::NotFound(["message" => "Home not found"]); + } } - $preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $id]); + $preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $wohneinheit->id]); if(!$preorder) { return \mfResponse::NotFound(["message" => "Home not found"]); }