Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow callback url to be supplied for emergency notifications #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/PushoverMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ 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.
Expand Down Expand Up @@ -324,6 +331,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.
*
Expand All @@ -344,6 +365,7 @@ public function toArray(): array
'expire' => $this->expire,
'html' => $this->format === static::FORMAT_HTML,
'monospace' => $this->format === static::FORMAT_MONOSPACE,
'callback' => $this->callback,
];
}

Expand Down
9 changes: 9 additions & 0 deletions tests/PushoverMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading