fix status

This commit is contained in:
Giuseppe Nucifora 2022-07-22 12:38:42 +02:00
parent 9ffc956e81
commit 8d33a26168
2 changed files with 74 additions and 62 deletions

View File

@ -26,6 +26,7 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
$response = json_decode($jsonResponse);
if ($response) {
switch ($response->stat) {
case 'ok':
@ -40,6 +41,7 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
default:
break;
}
}
return $this->cachedAlertContacts;
@ -66,7 +68,7 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
}
$response = json_decode($jsonResponse);
if ($response) {
switch ($response->stat) {
case 'ok':
$alertContact->setId($response->alertcontact->id);
@ -76,7 +78,8 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
return false;
break;
}
}
return null;
}
/**
@ -102,16 +105,18 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
$response = json_decode($jsonResponse);
if ($response) {
switch ($response->stat) {
case 'ok':
$alertContact->setId($response->alert_contact->id);
return $alertContact;
break;
default:
return false;
return null;
break;
}
}
}
/**
* @param AlertContact $alertContact
@ -128,16 +133,18 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
}
$response = json_decode($jsonResponse);
if ($response) {
switch ($response->stat) {
case 'ok':
return $alertContact;
break;
default:
return false;
return null;
break;
}
}
return null;
}
/**
* @param $id
@ -152,7 +159,7 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
/** @var AlertContact $alertContact */
foreach ($this->cachedAlertContacts as $alertContact) {
if ($alertContact->getId() === $id || $alertContact->getFriendlyName() === $name || $alertContact->getValue() === $value ) {
if ($alertContact->getId() === $id || $alertContact->getFriendlyName() === $name || $alertContact->getValue() === $value) {
return $alertContact;
}
}

View File

@ -143,7 +143,7 @@ class UptimeRobotMonitorService extends UptimeRobotService
'status' => $monitor->getStatus()
];
if (!empty($alertContactsString)){
if (!empty($alertContactsString)) {
$params['alert_contacts'] = $alertContactsString;
}
@ -156,7 +156,7 @@ class UptimeRobotMonitorService extends UptimeRobotService
}
$response = json_decode($jsonResponse);
if ($response) {
switch ($response->stat) {
case 'ok':
$monitor->setId($response->monitor->id);
@ -167,6 +167,7 @@ class UptimeRobotMonitorService extends UptimeRobotService
break;
}
}
}
/**
* @param Monitor $monitor
@ -183,7 +184,7 @@ class UptimeRobotMonitorService extends UptimeRobotService
}
$response = json_decode($jsonResponse);
if ($response) {
switch ($response->stat) {
case 'ok':
return $monitor;
@ -193,6 +194,8 @@ class UptimeRobotMonitorService extends UptimeRobotService
break;
}
}
return null;
}
/**
* @param Monitor $monitor
@ -209,7 +212,7 @@ class UptimeRobotMonitorService extends UptimeRobotService
}
$response = json_decode($jsonResponse);
if ($response) {
switch ($response->stat) {
case 'ok':
return $monitor;
@ -219,6 +222,8 @@ class UptimeRobotMonitorService extends UptimeRobotService
break;
}
}
return null;
}
/**
* @param $id