diff --git a/src/Requests/CreateAPostInAGivenStream.php b/src/Requests/CreateAPostInAGivenStream.php index 9bcdc8f..898442a 100644 --- a/src/Requests/CreateAPostInAGivenStream.php +++ b/src/Requests/CreateAPostInAGivenStream.php @@ -20,7 +20,7 @@ class CreateAPostInAGivenStream extends Request implements HasBody public function __construct( protected readonly string $streamId, - protected readonly string $text, + protected readonly ?string $text = null, protected readonly ?string $title = null, protected null|array|Collection $labels = null, protected readonly bool $sticky = false, @@ -53,14 +53,16 @@ protected function defaultQuery(): array public function defaultBody(): array { - $body = [ - 'text' => $this->text, - ]; + $body = []; - if (! empty($this->title)) { + if (filled($this->title)) { $body = Arr::add(array: $body, key: 'title', value: $this->title); } + if (filled($this->text)) { + $body = Arr::add(array: $body, key: 'text', value: $this->text); + } + $labels = $this->labels; if ($labels instanceof Collection) {