Public/MessageCompositionObjects/New-SlackConfirmationDialogObject.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
34
35
36
37
38
39
40
41
42
function New-SlackConfirmationDialogObject {
    <#
    .SYNOPSIS
        Returns a Slack Confirmation Dialog Object.
    .DESCRIPTION
        This function returns a Slack Confirmation Dialog Object as a PSCustomObject ready to combine with any Slack Element,
        ConvertTo-Json, and send to Slack.
    .PARAMETER title
        Text that defines the dialog's title.
    .PARAMETER text
        Text that defines the explanatory text that appears in the confirm dialog.
    .PARAMETER confirmationText
        Text to define the text of the button that confirms the action.
    .PARAMETER denialText
        Text to define the text of the button that cancels the action.
    .LINK
        https://api.slack.com/reference/messaging/composition-objects#confirm
    .EXAMPLE
        New-SlackConfirmationDialogObject -title "Are you sure?" -text "Really?" -confirmationText "Yes" -denialText "No"
    #>

    [CmdletBinding()]
    param(
        [string]
        $title,

        [string]
        $text,

        [string]
        $confirmationText,

        [string]
        $denialText
    )
    $SlackConfirmation = [pscustomobject]@{
        title   = New-SlackTextObject -type plain_text -text $title
        text    = New-SlackTextObject -type mrkdwn -text $text
        confirm = New-SlackTextObject -type plain_text -text $confirmationText
        deny    = New-SlackTextObject -type plain_text -text $denialText
    }
    return $SlackConfirmation
}