diff --git a/src/Service/UptimeRobotAlertContacsService.php b/src/Service/UptimeRobotAlertContacsService.php index 0da2cee..b589098 100644 --- a/src/Service/UptimeRobotAlertContacsService.php +++ b/src/Service/UptimeRobotAlertContacsService.php @@ -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; } } diff --git a/src/Service/UptimeRobotMonitorService.php b/src/Service/UptimeRobotMonitorService.php index 24c1223..2916805 100644 --- a/src/Service/UptimeRobotMonitorService.php +++ b/src/Service/UptimeRobotMonitorService.php @@ -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; } }