Public/Get-GW2PvPSeasonLeaderboards.ps1

<#
    .SYNOPSIS
        Retrieves PvP season leaderboards from the Guild Wars 2 API.
 
    .DESCRIPTION
        The Get-GW2PvPSeasonLeaderboards cmdlet retrieves leaderboard information for a specific PvP season.
 
    .PARAMETER SeasonId
        The ID of the PvP season to retrieve leaderboards for.
 
    .PARAMETER Board
        The type of leaderboard to retrieve.
        Valid values: "ladder", "legendary", "guild".
        Note: "ladder" is typically used for newer seasons (Season 5+), while "legendary" and "guild" are used for older seasons.
 
    .PARAMETER Region
        The region for the leaderboard.
        Valid values: "na", "eu".
 
    .EXAMPLE
        Get-GW2PvPSeasonLeaderboards -SeasonId "A54849B7-7DBD-4958-91EF-72E18CD659BA" -Board "ladder" -Region "na"
        Retrieves the NA ladder leaderboard for the specified season.
 
    .NOTES
        API Endpoint: /v2/pvp/seasons/:id/leaderboards
    #>

function Get-GW2PvPSeasonLeaderboards {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$SeasonId,

        [Parameter(Mandatory = $false)]
        [ValidateSet("ladder", "legendary", "guild")]
        [string]$Board,

        [Parameter(Mandatory = $false)]
        [ValidateSet("na", "eu")]
        [string]$Region
    )

    $Uri = "https://api.guildwars2.com/v2/pvp/seasons/$SeasonId/leaderboards"
    
    if (-not [string]::IsNullOrEmpty($Board)) {
        $Uri += "/$Board"
        if (-not [string]::IsNullOrEmpty($Region)) {
            $Uri += "/$Region"
        }
    }

    try {
        Invoke-RestMethod -Uri $Uri -Method Get
    }
    catch {
        Write-Error "Failed to retrieve PvP season leaderboards: $_"
    }
}