public/Get-UnraidNotification.ps1

function Get-UnraidNotification {
    <#
    .SYNOPSIS
        Gets system notifications.

    .PARAMETER Offset
        Skip count for pagination.

    .PARAMETER Limit
        Max notifications to return (default 100).

    .PARAMETER Type
        Filter: ALL, unread, or archive.

    .PARAMETER Session
        Unraid session (defaults to current session).

    .EXAMPLE
        Get-UnraidNotification

    .EXAMPLE
        Get-UnraidNotification -Type unread
    #>

    [CmdletBinding()]
    [OutputType("UnraidNotification")]
    param(
        [Parameter()]
        [int]$Offset = 0,

        [Parameter()]
        [int]$Limit = 100,

        [Parameter()]
        [ValidateSet("ALL", "unread", "archive")]
        [string]$Type = "ALL",

        [Parameter()]
        [UnraidSession]$Session = $script:DefaultUnraidSession
    )

    process {
        $typesToQuery = if ($Type -eq "ALL") { @('UNREAD', 'ARCHIVE') } else { @($Type) }

        foreach ($specificType in $typesToQuery) {
            
            $gqlQuery = @"
            query GetNotifications {
                notifications {
                    list(filter: { type: $specificType, offset: $Offset, limit: $Limit }) {
                        id title subject description importance link type timestamp formattedTimestamp
                    }
                }
            }
"@


            if ($typesToQuery.Count -gt 1) { Write-Verbose "Fetching '$specificType' notifications..." }

            $result = Invoke-UnraidQuery -Query $gqlQuery -Session $Session 

            if ($result.notifications -and $result.notifications.list) {
                foreach ($item in $result.notifications.list) {
                    [UnraidNotification]::new($item)
                }
            }
        }
    }
}