Citycom API
This commit is contained in:
85
application/Api/v1/Modules/Operationaldata/SnoppCitycom.php
Normal file
85
application/Api/v1/Modules/Operationaldata/SnoppCitycom.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace application\Api\v1\Modules\Operationaldata;
|
||||
use application\Api\v1\Modules;
|
||||
|
||||
require_once(APPDIR."/Api/v1/Modules/ApiControllerModule.php");
|
||||
|
||||
/*
|
||||
* API Endpoints for Operationaldata from SNOPP
|
||||
*/
|
||||
class SnoppCitycom extends Modules\ApiControllerModule
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function orderService($req_id) {
|
||||
if(!$req_id) {
|
||||
return \mfResponse::BadRequest(["message" => "id missing"]);
|
||||
}
|
||||
|
||||
$bb_up = $this->post["bb_up"];
|
||||
$bb_down = $this->post["bb_down"];
|
||||
$execution_date = false;
|
||||
|
||||
if($this->post["execution_date"]) {
|
||||
try {
|
||||
$execution_date = new DateTime($this->post["execution_date"]);
|
||||
} catch(\Exception $e) {
|
||||
return mfResponse::BadRequest(["message" => "Invalid Timestamp format"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!is_numeric($bb_down) || !$bb_down || !is_numeric($bb_up) || !$bb_up || !$bb_down > 10000 || $bb_up > 10000) {
|
||||
return \mfResponse::BadRequest(["message" => "Invalid bandwidth"]);
|
||||
}
|
||||
|
||||
$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" => $wohneinheit->id]);
|
||||
if(!$preorder) {
|
||||
return \mfResponse::NotFound(["message" => "Home not found"]);
|
||||
}
|
||||
|
||||
$cc_home_id = \Citycom_OanApiHelper::hausnummerExtrefToCitycomId($wohneinheit->extref);
|
||||
$data["bb_up"] = $bb_up;
|
||||
$data["bb_down"] = $bb_down;
|
||||
$data["product_name"] = false;
|
||||
$data["execution_date"] = ($execution_date) ? $execution_date->format("Y-m-d") : false;
|
||||
$data["services"] = CITYCOM_OAN_API_SERVICES_FOR_ORDER;
|
||||
|
||||
if($preorder->campaign->name == "Citycom - Graz") {
|
||||
$data["product_name"] = "Estmk OAN $bb_down/$bb_up";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$cc_api_client = new \Citycom_OanApiClient(CITYCOM_OAN_API_USER, CITYCOM_OAN_API_PASS);
|
||||
$cc_api = new \Citycom_OanApiHelper($cc_api_client);
|
||||
|
||||
if(!$cc_api->orderServices($preorder, $cc_home_id, $data)) {
|
||||
return \mfResponse::InternalServerError(["message" => "Error activating service"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,6 +49,8 @@ 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("/operationaldata/preorder/:id/orderService", [$modules["SnoppCitycom"], "orderService"], "POST");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -132,8 +134,12 @@ class OperationaldataApicontroller extends mfBaseApicontroller
|
||||
$name = $network->name;
|
||||
|
||||
if($network->adb_netzgebiet_id) {
|
||||
$cityname = preg_replace('/^Liezen\s+-\s+/', '', $network->adb_netzgebiet->name);
|
||||
$name = "ROC_".$network->adb_netzgebiet->extref."_".$cityname;
|
||||
if($network->adb_netzgebiet->source == "citycom-oan-api") {
|
||||
$name = "OC ".$network->adb_netzgebiet->name;
|
||||
} else {
|
||||
$cityname = preg_replace('/^Liezen\s+-\s+/', '', $network->adb_netzgebiet->name);
|
||||
$name = "ROC_" . $network->adb_netzgebiet->extref . "_" . $cityname;
|
||||
}
|
||||
}
|
||||
|
||||
$net = [];
|
||||
@@ -224,7 +230,13 @@ class OperationaldataApicontroller extends mfBaseApicontroller
|
||||
$woStateNameToId["Cancelled"] = 99;
|
||||
|
||||
|
||||
foreach(PreorderModel::searchActive(["preordercampaign_id" => $campaign_id, "partner_id" => $isp_ids]) as $preorder) {
|
||||
$preorder_search = ["preordercampaign_id" => $campaign_id];
|
||||
if(count($isp_ids)) {
|
||||
$preorder_search["partner_id"] = $isp_ids;
|
||||
}
|
||||
|
||||
|
||||
foreach(PreorderModel::searchActive($preorder_search) as $preorder) {
|
||||
$hausnummer_id = $preorder->adb_hausnummer_id;
|
||||
$wohneinheit_id = $preorder->adb_wohneinheit_id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user