Skip to content

Notification improvements #498

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

Merged
merged 7 commits into from
Feb 21, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Support for actions and reply
  • Loading branch information
andreascreten committed Feb 20, 2025
commit 10837d5ec995f8cff00cd6450804205ebd0774e8
24 changes: 24 additions & 0 deletions src/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class Notification

protected string $event = '';

private bool $hasReply = false;

private string $replyPlaceholder = '';

private array $actions = [];

final public function __construct(protected Client $client)
{
$this->title = config('app.name');
Expand Down Expand Up @@ -45,6 +51,21 @@ public function event(string $event): self
return $this;
}

public function hasReply(string $placeholder = ''): self
{
$this->hasReply = true;
$this->replyPlaceholder = $placeholder;

return $this;
}

public function addAction(string $label): self
{
$this->actions[] = $label;

return $this;
}

public function message(string $body): self
{
$this->body = $body;
Expand All @@ -59,6 +80,9 @@ public function show(): self
'title' => $this->title,
'body' => $this->body,
'event' => $this->event,
'hasReply' => $this->hasReply,
'replyPlaceholder' => $this->replyPlaceholder,
'actions' => $this->actions,
]);

$this->reference = $response->json('reference');
Expand Down