Public/MessageCompositionObjects/New-SlackOptionGroupObject.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
30
31
32
33
function New-SlackOptionGroupObject {
    <#
    .SYNOPSIS
        Returns a Slack Option Group Object.
    .DESCRIPTION
        This function returns a Slack Option Group Object as a PSCustomObject ready to combine with select menus,
        ConvertTo-Json, and send to Slack.
    .PARAMETER label
        Text that defines the label shown above this group of options.
    .PARAMETER slackOptions
        An array of option objects that belong to this specific group.
    .LINK
        https://api.slack.com/reference/messaging/composition-objects#option-group
    .EXAMPLE
        New-SlackOptionGroupObject -label "Jedis" -value $Jedis
    #>

    [CmdletBinding()]
    param(
        [ValidateLength(1, 75)]
        [string]
        $label,

        [ValidateLength(1, 100)]
        [pscustomobject[]]
        $SlackOptions
    )

    $SlackOptionGroup = [pscustomobject]@{
        label   = New-SlackTextObject -type plain_text -text $label
        options = $SlackOptions
    }
    return $SlackOptionGroup
}