diff --git a/src/Events/Notifications/NotificationActionClicked.php b/src/Events/Notifications/NotificationActionClicked.php new file mode 100644 index 00000000..de658b3c --- /dev/null +++ b/src/Events/Notifications/NotificationActionClicked.php @@ -0,0 +1,23 @@ +title = config('app.name'); @@ -22,6 +30,13 @@ public static function new() return new static(new Client); } + public function reference(string $reference): self + { + $this->reference = $reference; + + return $this; + } + public function title(string $title): self { $this->title = $title; @@ -36,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; @@ -43,12 +73,23 @@ public function message(string $body): self return $this; } - public function show(): void + public function show(): self { - $this->client->post('notification', [ + $response = $this->client->post('notification', [ + 'reference' => $this->reference, 'title' => $this->title, 'body' => $this->body, 'event' => $this->event, + 'hasReply' => $this->hasReply, + 'replyPlaceholder' => $this->replyPlaceholder, + 'actions' => array_map(fn(string $label) => [ + 'type' => 'button', + 'text' => $label + ], $this->actions), ]); + + $this->reference = $response->json('reference'); + + return $this; } }