Public/Get-GW2PvPAmulets.ps1

<#
.SYNOPSIS
Retrieves information about PvP amulets.
 
.DESCRIPTION
Calls the Guild Wars 2 API v2 /pvp/amulets endpoint.
- If no parameters are provided, returns a list of all available amulet IDs.
- If 'Ids' is provided, returns objects containing details for the specified amulets.
- If 'Ids' is set to 'all', returns details for all amulets.
 
.PARAMETER Ids
Optional. A list of amulet IDs (integers) or the string 'all'.
Example: 4, 12 or "all"
 
.PARAMETER Lang
Optional. The language to return results in (en, es, de, fr, ko, zh).
 
.EXAMPLE
Get-GW2PvPAmulets
Returns a list of all amulet IDs.
 
.EXAMPLE
Get-GW2PvPAmulets -Ids 4
Returns details for the specified amulet.
 
.EXAMPLE
Get-GW2PvPAmulets -Ids "all"
Returns details for all amulets.
 
.NOTES
- Requires network access to api.guildwars2.com.
- This is a public endpoint and does not require an API key.
#>

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

        [Parameter(Mandatory = $false)]
        [ValidateSet("en", "es", "de", "fr", "ko", "zh")]
        [string]$Lang
    )
    
    $url = "https://api.guildwars2.com/v2/pvp/amulets"

    if ($Ids) {
        if ($Ids -eq "all") {
            $url = $url + "?ids=all"
        }
        else {
            # Join IDs with commas for the query parameter
            if ($Ids -is [array]) {
                $idString = $Ids -join ','
            }
            else {
                $idString = $Ids
            }
            $url = $url + "?ids=$idString"
        }
    }

    if ($Lang) {
        if ($url.Contains("?")) {
            $url = $url + "&lang=$Lang"
        }
        else {
            $url = $url + "?lang=$Lang"
        }
    }

    $response = Invoke-RestMethod -Uri $url -Method Get
    
    return $response
}