Public/Get-GW2WvWObjectives.ps1
|
<#
.SYNOPSIS Retrieves WvW objectives from the Guild Wars 2 API. .DESCRIPTION The Get-GW2WvWObjectives cmdlet retrieves information about World vs. World objectives (camps, towers, keeps, etc.). .PARAMETER Ids The ID(s) of the objectives 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-GW2WvWObjectives -Ids "38-6" Retrieves information for a specific objective. .EXAMPLE Get-GW2WvWObjectives -Ids "all" Retrieves information for all objectives. .NOTES API Endpoint: /v2/wvw/objectives #> function Get-GW2WvWObjectives { [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/objectives" $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 objectives: $_" } } |