Public/MessageLayoutBlocks/New-SlackDividerBlock.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function New-SlackDividerBlock {
        <#
    .SYNOPSIS
        Returns a Slack Divider Block PSCustomObject
    .DESCRIPTION
        This function returns a Slack Divider Block as a PSCustomObject ready to ConvertTo-Json and send to Slack.
    .PARAMETER block_id
        Specifies the block_id of the Slack Block for reference by the Slack APIs.
    .LINK
        https://api.slack.com/reference/messaging/blocks#divider
    .EXAMPLE
        Get-SlackDividerBlock -block_id "123ABC"
    #>

    [cmdletbinding()]
    param(
        [ValidateLength(1,255)]
        [string]
        $block_id
    )

    $SlackDivider = [pscustomobject]@{
        type = "divider"
    }
    if($block_id){
        $SlackDivider | Add-Member -NotePropertyName "block_id" -NotePropertyValue $block_id
    }
    
    return $SlackDivider
}