Public/Get-GW2Colors.ps1
|
<#
.SYNOPSIS Retrieves information about dye colors. .DESCRIPTION This function retrieves information about dye colors from the Guild Wars 2 API. It supports retrieving specific colors by ID or all colors. .PARAMETER Ids The ID(s) of the colors 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-GW2Colors -Ids 10,20 Retrieves information for colors with IDs 10 and 20. .EXAMPLE Get-GW2Colors -Ids "all" Retrieves information for all colors. .LINK https://wiki.guildwars2.com/wiki/API:2/colors #> function Get-GW2Colors { [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/colors" $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 colors: $_" } } |