Public/Get-GW2WvWMatches.ps1

<#
    .SYNOPSIS
        Retrieves WvW matches from the Guild Wars 2 API.
 
    .DESCRIPTION
        The Get-GW2WvWMatches cmdlet retrieves information about World vs. World matches.
        You can search by Match ID(s) or by World ID.
 
    .PARAMETER Ids
        The ID(s) of the matches to retrieve. Can be a single ID, an array of IDs, or "all".
 
    .PARAMETER WorldId
        The ID of a world to retrieve the current match for.
 
    .PARAMETER Type
        The type of match information to retrieve.
        Valid values: "overview", "scores", "stats".
        If omitted, returns the standard match details.
 
    .PARAMETER Page
        The page number to retrieve.
 
    .PARAMETER PageSize
        The number of results per page.
 
    .EXAMPLE
        Get-GW2WvWMatches -WorldId 1008
        Retrieves the current match for Jade Quarry.
 
    .EXAMPLE
        Get-GW2WvWMatches -Ids "all"
        Retrieves all current matches.
 
    .NOTES
        API Endpoint: /v2/wvw/matches
    #>

function Get-GW2WvWMatches {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $false)]
        [object]$Ids,

        [Parameter(Mandatory = $false)]
        [int]$WorldId,

        [Parameter(Mandatory = $false)]
        [ValidateSet("overview", "scores", "stats")]
        [string]$Type,

        [Parameter(Mandatory = $false)]
        [int]$Page,

        [Parameter(Mandatory = $false)]
        [int]$PageSize
    )

    $Uri = "https://api.guildwars2.com/v2/wvw/matches"
    
    if (-not [string]::IsNullOrEmpty($Type)) {
        $Uri += "/$Type"
    }

    $QueryParams = @{}

    if ($PSBoundParameters.ContainsKey('WorldId')) {
        $QueryParams["world"] = $WorldId
    }
    elseif ($null -ne $Ids) {
        if ($Ids -is [array]) {
            $QueryParams["ids"] = $Ids -join ","
        }
        elseif ($Ids -eq "all") {
            $QueryParams["ids"] = "all"
        }
        else {
            $QueryParams["ids"] = $Ids
        }
    }

    if ($PSBoundParameters.ContainsKey('Page')) {
        $QueryParams["page"] = $Page
    }

    if ($PSBoundParameters.ContainsKey('PageSize')) {
        $QueryParams["page_size"] = $PageSize
    }

    try {
        Invoke-RestMethod -Uri $Uri -Method Get -Body $QueryParams
    }
    catch {
        Write-Error "Failed to retrieve WvW matches: $_"
    }
}