From 89542cdb38d4d41b54e867a23f9a53819b6241fe Mon Sep 17 00:00:00 2001 From: Stijn Bernards Date: Sat, 15 Jun 2024 18:15:39 +0200 Subject: [PATCH 1/2] feat: allow callback url to be supplied for emergency notification callback requests --- src/PushoverMessage.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/PushoverMessage.php b/src/PushoverMessage.php index 2882ac1..96affb0 100644 --- a/src/PushoverMessage.php +++ b/src/PushoverMessage.php @@ -85,6 +85,12 @@ class PushoverMessage * @var string|null */ public string|null $image = null; + /** + * The (optional) publicly-accessible url that Pushover will use to notify your system when a user + * acknowledges an Emergency notification + * @var string|null + */ + public string|null $callback = null; /** * Message formats. @@ -324,6 +330,20 @@ public function emergencyPriority(int $retryTimeout, int $expireAfter): static return $this->priority(self::EMERGENCY_PRIORITY, $retryTimeout, $expireAfter); } + /** + * Set the callback url used by pushover to let your system + * know when a emergency notification has been acknowledged + * + * @param string $url + * @return $this + */ + public function callback(string $url): static + { + $this->callback = $url; + + return $this; + } + /** * Array representation of Pushover Message. * @@ -344,6 +364,7 @@ public function toArray(): array 'expire' => $this->expire, 'html' => $this->format === static::FORMAT_HTML, 'monospace' => $this->format === static::FORMAT_MONOSPACE, + 'callback' => $this->callback ]; } From c7810ee957ae31b361c390171f5be7d0a80c386a Mon Sep 17 00:00:00 2001 From: SBernards Date: Fri, 9 Aug 2024 11:58:02 +0200 Subject: [PATCH 2/2] fix: add tests for callback url and correct codestyle --- src/PushoverMessage.php | 9 +++++---- tests/PushoverMessageTest.php | 9 +++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/PushoverMessage.php b/src/PushoverMessage.php index 96affb0..1389a83 100644 --- a/src/PushoverMessage.php +++ b/src/PushoverMessage.php @@ -87,7 +87,8 @@ class PushoverMessage public string|null $image = null; /** * The (optional) publicly-accessible url that Pushover will use to notify your system when a user - * acknowledges an Emergency notification + * acknowledges an Emergency notification. + * * @var string|null */ public string|null $callback = null; @@ -332,9 +333,9 @@ public function emergencyPriority(int $retryTimeout, int $expireAfter): static /** * Set the callback url used by pushover to let your system - * know when a emergency notification has been acknowledged + * know when a emergency notification has been acknowledged. * - * @param string $url + * @param string $url * @return $this */ public function callback(string $url): static @@ -364,7 +365,7 @@ public function toArray(): array 'expire' => $this->expire, 'html' => $this->format === static::FORMAT_HTML, 'monospace' => $this->format === static::FORMAT_MONOSPACE, - 'callback' => $this->callback + 'callback' => $this->callback, ]; } diff --git a/tests/PushoverMessageTest.php b/tests/PushoverMessageTest.php index 1440806..5b42b8e 100644 --- a/tests/PushoverMessageTest.php +++ b/tests/PushoverMessageTest.php @@ -190,4 +190,13 @@ public function it_can_set_the_priority_to_emergency(): void $this->assertEquals(2, $this->message->priority); } + + public function it_can_set_the_callback_url(): void + { + $callbackUrl = 'https://www.example.com/callback'; + + $this->message->callback($callbackUrl); + + $this->assertEquals($callbackUrl, $this->message->callback); + } }