migliorato find monitor e contatti

This commit is contained in:
Giuseppe Nucifora 2022-07-21 17:10:25 +02:00
parent 6d1fdb9289
commit b981b3cfdb
2 changed files with 25 additions and 4 deletions

View File

@ -144,7 +144,7 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
* @param bool $forceRefresh
* @return mixed|AlertContact|null
*/
public function find($id, $forceRefresh = false)
public function find($id = null, $name = null, $value = null, $forceRefresh = false)
{
if (empty($this->cachedAlertContacts) || $forceRefresh) {
$this->getAlertContacts();
@ -152,7 +152,28 @@ class UptimeRobotAlertContacsService extends UptimeRobotService
/** @var AlertContact $alertContact */
foreach ($this->cachedAlertContacts as $alertContact) {
if ($alertContact->getId() === $id) {
if ($alertContact->getId() === $id || $alertContact->getFriendlyName() === $name || $alertContact->getValue() === $value ) {
return $alertContact;
}
}
return null;
}
/**
* @param $id
* @param bool $forceRefresh
* @return mixed|AlertContact|null
*/
public function findbyName($name, $forceRefresh = false)
{
if (empty($this->cachedAlertContacts) || $forceRefresh) {
$this->getAlertContacts();
}
/** @var AlertContact $alertContact */
foreach ($this->cachedAlertContacts as $alertContact) {
if ($alertContact->getFriendlyName() === $name) {
return $alertContact;
}
}

View File

@ -223,7 +223,7 @@ class UptimeRobotMonitorService extends UptimeRobotService
* @param bool $forceRefresh
* @return mixed|Monitor|null
*/
public function find($id, $forceRefresh = false)
public function find($id = null, $name = null, $url = null, $forceRefresh = false)
{
if (empty($this->cachedMonitors) || $forceRefresh) {
$this->getMonitors();
@ -231,7 +231,7 @@ class UptimeRobotMonitorService extends UptimeRobotService
/** @var Monitor $monitor */
foreach ($this->cachedMonitors as $monitor) {
if ($monitor->getId() === $id) {
if ($monitor->getId() === $id || $monitor->getFriendlyName() === $name || $monitor->getUrl() === $url) {
return $monitor;
}
}