Request/Move-SDPRequestToTrash.ps1

Function Move-SDPRequestToTrash
{
    <#
    .SYNOPSIS
        Remove the request (move to trash)
 
    .PARAMETER RequestId
        Request id
 
    .EXAMPLE
        $Request = Move-SDPRequestToTrash -RequestId 547
 
    .NOTES
        Author: Michal Gajda
 
    .LINK
        https://ui.servicedeskplus.com/APIDocs3/index.html#delete-request
    #>

    [CmdletBinding(
        SupportsShouldProcess=$True,
        ConfirmImpact="Low"
    )]
    param (
        [String]$UriSDP,
        [String]$ApiKey,
        [Parameter(Mandatory=$true,
            ValueFromPipeline)]
        [Int]$RequestId
    )

    Begin
    {
        #Create headers
        if(!$MyInvocation.BoundParameters.ContainsKey("UriSDP")) { $UriSDP = $Global:UriSDP }
        if(!$MyInvocation.BoundParameters.ContainsKey("ApiKey")) { $ApiKey = $Global:ApiKey }
    }

    Process
    {
        #Get by ID
        $InvokeParams = @{
            UriSDP = $UriSDP
            ApiKey = $ApiKey
            Method = "DELETE"
            EntityUri = "/api/v3/requests/$RequestId/move_to_trash"
            InputData = $InputData
        }

        #Send request
        If ($PSCmdlet.ShouldProcess($RequestId,"Move request to trash by"))
        {
            $Result = Invoke-SDPAPIEntity @InvokeParams
            $Results = $Result.request
        }

        #Return result
        if($MyInvocation.BoundParameters.ContainsKey("Debug"))
        {
            Return $Result
        } else {
            Return $Results
        }
    }

    End{}
}