Merge branch 'fronkdev' into 'master'
Added AddressDB bulk update + address update in rimo See merge request fronk/thetool!1780
This commit is contained in:
@@ -2,6 +2,56 @@
|
||||
|
||||
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__.": Address Change in Rimo: $put_url");
|
||||
$response = file_get_contents($put_url, false, $ctx);
|
||||
//var_dump($response);exit;
|
||||
$log->debug(__METHOD__.": response: ".print_r($response,true));
|
||||
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 +304,7 @@ class Rimoapi {
|
||||
}
|
||||
}
|
||||
|
||||
var_dump($update_data);
|
||||
//var_dump($update_data);
|
||||
if(!count($update_data)) {
|
||||
$log->debug(__METHOD__.": no valid update data");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user