Skip to content

Commit

Permalink
Update SlackMessage.php
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell authored Oct 24, 2024
1 parent 6988698 commit d59488f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/Slack/SlackMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,6 @@ public function to(string $channel): self
return $this;
}

/**
* Set the Block Kit Builder json payload.
*
* @throws JsonException
* @throws LogicException
*/
public function usingBlockKitTemplate(string $template): self
{
$blocks = json_decode($template, true, flags: JSON_THROW_ON_ERROR);

if (! array_key_exists('blocks', $blocks)) {
throw new LogicException('The blocks array key is missing.');
}

array_push($this->blocks, ...$blocks['blocks']);

return $this;
}

/**
* Set the fallback and notification text of the Slack message.
*/
Expand Down Expand Up @@ -288,6 +269,25 @@ public function broadcastReply(?bool $broadcastReply = true): self
return $this;
}

/**
* Specify a raw Block Kit Builder JSON payload for the message.
*
* @throws JsonException
* @throws LogicException
*/
public function usingBlockKitTemplate(string $template): self
{
$blocks = json_decode($template, true, flags: JSON_THROW_ON_ERROR);

if (! array_key_exists('blocks', $blocks)) {
throw new LogicException('The blocks array key is missing.');
}

array_push($this->blocks, ...$blocks['blocks']);

return $this;
}

/**
* Get the instance as an array.
*/
Expand Down

0 comments on commit d59488f

Please sign in to comment.