Public/New-SlackActionConfirmation.ps1


function New-RyverActionConfirmation {
    <#
    .SYNOPSIS
        Creates an action confirmation to use in a Ryver action.
 
    .DESCRIPTION
        Creates an action confirmation to use in a Ryver action.
 
    .PARAMETER Text
        Describe in detail the consequences of the action and contextualize your button text choices.
        Use a maximum of 30 characters or so for best results across form factors.
 
    .PARAMETER Title
        Title the pop up window. Please be brief.
         
    .PARAMETER OkText
        The text label for the button to continue with an action. Keep it short. Defaults to Okay.
 
    .PARAMETER DismissText
        The text label for the button to cancel the action. Keep it short. Defaults to Cancel.
 
    .EXAMPLE
 
        # This example illustrates a pattern where you might
        # want to add an action (button or menu) to your Ryver attachment.
        # This can be useful when working with Ryver bots or integrations that
        # make calls out with the action data. Activating the button pops up a
        # confirmation dialog.
 
        # Create an action using the New-RyverAction command
        $confirmation = New-RyverActionConfirmation -Text "Are you sure?"
 
        $action = New-RyverAction -Name Acknowledge `
                                -Text Acknowledge `
                                -Type button `
                                -Confirmation $confirmation
 
        $WebhookUri = "https://hooks.ryver.com/services/SomeUniqueId"
 
        # Construct and send the message!
        New-RyverMessageAttachment -Color $PSRyverColorMap.orange `
                                   -Title 'Failed to process account' `
                                   -Actions $action `
                                   -Fallback 'Your client is bad' |
            New-RyverMessage |
            Send-RyverMessage -Uri $WebhookUri
 
        # We create an action object with an 'Acknowledge' button
        # Creates an attachment with the button created in the action object
        # Creates a message from that attachment and sents it with a uri
         
    .LINK
        https://tlindsay42.github.io/PSRyver/Public/New-RyverActionConfirmation/
 
    .LINK
        https://api.ryver.com/docs/interactive-message-field-guide#confirmation_fields
    #>

    [CmdletBinding(
        HelpUri = 'https://tlindsay42.github.io/PSRyver/Public/New-RyverActionConfirmation/'
    )]
    [OutputType([System.Collections.Hashtable])]
    Param
    (
        [Parameter(Mandatory = $true,
            Position = 0)]
        [ValidateLength(1, 30)]
        [String] $Text,

        [String] $Title,

        [String] $OkText,

        [String] $DismissText
    )

    Process {
        $ActionConfirmation = @{}
        switch ($PSBoundParameters.Keys) {
            'text' {$ActionConfirmation.text = $Text}
            'title' {$ActionConfirmation.title = $Title}
            'oktext' {$ActionConfirmation.ok_text = $OkText}
            'dismissText' {$ActionConfirmation.dismiss_text = $DismissText}
        }

        Add-ObjectDetail -InputObject $ActionConfirmation -TypeName 'PSRyver.ActionConfirmation' -Passthru $false

        $ActionConfirmation
    }
}