Public/Get-GW2Continents.ps1

<#
    .SYNOPSIS
        Retrieves information about continents.
 
    .DESCRIPTION
        This function retrieves information about continents from the Guild Wars 2 API.
        It supports retrieving specific continents by ID or all continents.
 
    .PARAMETER Ids
        The ID(s) of the continents to retrieve. Can be a single ID, an array of IDs, or "all".
 
    .PARAMETER Lang
        The language to return localized text in. Defaults to "en".
        Valid values: "en", "es", "de", "fr", "zh".
 
    .EXAMPLE
        Get-GW2Continents -Ids 1,2
        Retrieves information for continents with IDs 1 and 2.
 
    .EXAMPLE
        Get-GW2Continents -Ids "all"
        Retrieves information for all continents.
 
    .LINK
        https://wiki.guildwars2.com/wiki/API:2/continents
#>

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

        [Parameter(Mandatory = $false)]
        [ValidateSet("en", "es", "de", "fr", "zh")]
        [string]$Lang = "en"
    )

    $Uri = "https://api.guildwars2.com/v2/continents"
    $QueryParams = @{
        lang = $Lang
    }

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

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