Skip to content

Commit cbd1177

Browse files
authored
Merge pull request #10 from codebar-ag/finalize-beekeeper-api
Make Stream Post Title & Text Optional
2 parents 4c59e2b + b730a01 commit cbd1177

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Requests/CreateAPostInAGivenStream.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CreateAPostInAGivenStream extends Request implements HasBody
2020

2121
public function __construct(
2222
protected readonly string $streamId,
23-
protected readonly string $text,
23+
protected readonly ?string $text = null,
2424
protected readonly ?string $title = null,
2525
protected null|array|Collection $labels = null,
2626
protected readonly bool $sticky = false,
@@ -53,14 +53,16 @@ protected function defaultQuery(): array
5353

5454
public function defaultBody(): array
5555
{
56-
$body = [
57-
'text' => $this->text,
58-
];
56+
$body = [];
5957

60-
if (! empty($this->title)) {
58+
if (filled($this->title)) {
6159
$body = Arr::add(array: $body, key: 'title', value: $this->title);
6260
}
6361

62+
if (filled($this->text)) {
63+
$body = Arr::add(array: $body, key: 'text', value: $this->text);
64+
}
65+
6466
$labels = $this->labels;
6567

6668
if ($labels instanceof Collection) {

0 commit comments

Comments
 (0)