Public/Get-GW2WvWUpgrades.ps1
|
<#
.SYNOPSIS Retrieves WvW upgrades from the Guild Wars 2 API. .DESCRIPTION The Get-GW2WvWUpgrades cmdlet retrieves information about World vs. World upgrades (for objectives). .PARAMETER Ids The ID(s) of the upgrades 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-GW2WvWUpgrades -Ids 1 Retrieves information for specific upgrade ID 1. .EXAMPLE Get-GW2WvWUpgrades -Ids "all" Retrieves information for all upgrades. .NOTES API Endpoint: /v2/wvw/upgrades #> function Get-GW2WvWUpgrades { [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/upgrades" $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 upgrades: $_" } } |