diff --git a/.idea/php.xml b/.idea/php.xml
index 949b6a9..424c32b 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -35,7 +35,7 @@
-
+
\ No newline at end of file
diff --git a/composer.json b/composer.json
index d4dfeee..ee5ff3e 100644
--- a/composer.json
+++ b/composer.json
@@ -11,7 +11,7 @@
],
"minimum-stability": "stable",
"require": {
- "php": ">=7.1",
+ "php": ">=7.4",
"symfony/framework-bundle": ">=4.3",
"symfony/flex": "^1.2",
"symfony/dependency-injection": "^v4.4",
diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml
index 9341d92..515b3f9 100644
--- a/src/Resources/config/services.yaml
+++ b/src/Resources/config/services.yaml
@@ -11,3 +11,7 @@ services:
arguments:
- '%uptime_robot.credentials.api_key%'
- '@Symfony\Component\Serializer\SerializerInterface'
+ calls:
+ - setInterval: '%uptime_robot.configurations.interval%'
+ - setAlertContactsString: '%uptime_robot.configurations.alert_contacts%'
+
diff --git a/src/Service/UptimeRobotApiService.php b/src/Service/UptimeRobotApiService.php
index 8353f34..dd13a0e 100644
--- a/src/Service/UptimeRobotApiService.php
+++ b/src/Service/UptimeRobotApiService.php
@@ -2,6 +2,7 @@
namespace Pn\UptimeRobotBundle\Service;
+use Pn\UptimeRobotBundle\Model\AlertContact;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Serializer\SerializerInterface;
use Vdhicts\UptimeRobot\Client\Client;
@@ -11,6 +12,12 @@ class UptimeRobotApiService
{
private $apiKey;
+ private $interval;
+
+ private string $alertContactsString;
+
+ private array $alertContacts;
+
/** @var $client */
protected $client;
@@ -35,6 +42,7 @@ class UptimeRobotApiService
$this->client = new Client($configuration);
$this->serializer = $serializer;
+ $this->alertContacts = [];
}
/**
@@ -42,7 +50,8 @@ class UptimeRobotApiService
*
* @return bool
*/
- public function isActive(){
+ public function isActive()
+ {
return !empty($this->apiKey);
}
@@ -62,13 +71,64 @@ class UptimeRobotApiService
return $this;
}
+ /**
+ * @return mixed
+ */
+ public function getInterval()
+ {
+ return $this->interval;
+ }
+
+ /**
+ * @param mixed $interval
+ */
+ public function setInterval($interval): void
+ {
+ $this->interval = $interval;
+ }
+
+ /**
+ * @param mixed $alertContactsString
+ */
+ public function setAlertContactsString(?string $alertContactsString): void
+ {
+ $this->alertContactsString = $alertContactsString;
+ if (!empty($alertContactsString) && $this->isActive()) {
+ $alertContacts = explode(',', $alertContactsString);
+
+ foreach ($alertContacts as $alertContactName) {
+
+ $alertContact = $this->alertContactService->findbyName($alertContactName);
+ if ($alertContact instanceof AlertContact) {
+ $this->alertContacts[] = $alertContact;
+ }
+ }
+ }
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getAlertContacts()
+ {
+ return $this->alertContacts;
+ }
+
+ /**
+ * @param mixed $alertContacts
+ */
+ public function setAlertContacts($alertContacts): void
+ {
+ $this->alertContacts = $alertContacts;
+ }
+
/**
* @return UptimeRobotMonitorService
*/
public function getMonitorService(): UptimeRobotMonitorService
{
if (null === $this->monitorService) {
- $this->monitorService = New UptimeRobotMonitorService($this->client);
+ $this->monitorService = new UptimeRobotMonitorService($this->client);
if ($this->io instanceof SymfonyStyle) {
$this->monitorService->setIo($this->io);
}
@@ -82,7 +142,7 @@ class UptimeRobotApiService
public function getAlertContactService(): UptimeRobotAlertContacsService
{
if (null === $this->alertContactService) {
- $this->alertContactService = New UptimeRobotAlertContacsService($this->client);
+ $this->alertContactService = new UptimeRobotAlertContacsService($this->client);
if ($this->io instanceof SymfonyStyle) {
$this->alertContactService->setIo($this->io);
}