WIP 2025-09-18

This commit is contained in:
Frank Schubert
2025-09-19 10:45:12 +02:00
parent 822680e16f
commit 80cdbcb4ca
4 changed files with 311 additions and 4 deletions

View File

@@ -2,6 +2,54 @@
class Rimoapi {
public static function changeBuildingAddress($apikey, $building_external_id, $_data) {
if(!$apikey) return false;
if(!$building_external_id) return false;
$log = mfLoghandler::singleton();
$update_data = [];
foreach($_data as $key => $value) {
if(!in_array($key, ["address", "city", "zipCode", "district", "country", "lotNumber", "district2"])) continue;
if($value) {
$update_data[$key] = $value;
}
}
if(!count($update_data)) return false;
// send request to Rimo Api
$params = [];
$params['apiKey'] = $apikey;
$params['buildingId'] = $building_external_id;
$params = array_merge($params, $update_data);
$ctx_opts = [
'http' => [
'method' => 'PUT',
'header' => 'accept: application/json'
]
];
$qs = http_build_query($params);
//echo $qs."\n";
$createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_CHANGE_BUILDING_ADDRESS;
$put_url = $createOrderEp."?".$qs;
$ctx = stream_context_create($ctx_opts);
$log->debug(__METHOD__.": Creating OAID in Rimo: $put_url");
$response = file_get_contents($put_url, false, $ctx);
//var_dump($response);exit;
if($response === false) {
$log->error("Fehler beim Update der Adresse in RIMO ".$building_external_id);
return false;
}
$resp_data = json_decode($response);
if(!$resp_data->id) return false;
return true;
}
public static function getFtuData($oaid, $home_external_id) {
//$oaid = $oaid;
$log = mfLoghandler::singleton();
@@ -254,7 +302,7 @@ class Rimoapi {
}
}
var_dump($update_data);
//var_dump($update_data);
if(!count($update_data)) {
$log->debug(__METHOD__.": no valid update data");
return false;