Public/Get-GW2WvWRanks.ps1
|
<#
.SYNOPSIS Retrieves WvW ranks from the Guild Wars 2 API. .DESCRIPTION The Get-GW2WvWRanks cmdlet retrieves information about World vs. World ranks. .PARAMETER Ids The ID(s) of the ranks to retrieve. Can be a single ID, an array of IDs, or "all". .PARAMETER Page The page number to retrieve. .PARAMETER PageSize The number of results per page. .PARAMETER Lang The language to return localized text in. Defaults to "en". Valid values: "en", "es", "de", "fr", "zh". .EXAMPLE Get-GW2WvWRanks -Ids 1 Retrieves information for specific rank ID 1. .EXAMPLE Get-GW2WvWRanks -Ids "all" Retrieves information for all ranks. .NOTES API Endpoint: /v2/wvw/ranks #> function Get-GW2WvWRanks { [CmdletBinding()] param ( [Parameter(Mandatory = $false)] [object]$Ids, [Parameter(Mandatory = $false)] [int]$Page, [Parameter(Mandatory = $false)] [int]$PageSize, [Parameter(Mandatory = $false)] [ValidateSet("en", "es", "de", "fr", "zh")] [string]$Lang = "en" ) $Uri = "https://api.guildwars2.com/v2/wvw/ranks" $QueryParams = @{} if ($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 } if ($PSBoundParameters.ContainsKey('Lang')) { $QueryParams["lang"] = $Lang } try { Invoke-RestMethod -Uri $Uri -Method Get -Body $QueryParams } catch { Write-Error "Failed to retrieve WvW ranks: $_" } } |