Public/Get-GW2Quests.ps1
|
<#
.SYNOPSIS Retrieves quests from the Guild Wars 2 API. .DESCRIPTION The Get-GW2Quests cmdlet retrieves information about quests constituting the stories found in the Story Journal from the Guild Wars 2 API. .PARAMETER Ids The ID(s) of the quests 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-GW2Quests -Ids 16 Retrieves information for the quest with ID 16. .EXAMPLE Get-GW2Quests -Ids "all" Retrieves information for all quests. .NOTES API Endpoint: /v2/quests #> function Get-GW2Quests { [CmdletBinding()] param ( [Parameter(Mandatory = $false)] [string[]]$Ids, [Parameter(Mandatory = $false)] [int]$Page, [Parameter(Mandatory = $false)] [int]$PageSize, [Parameter(Mandatory = $false)] [ValidateSet("en", "es", "de", "fr", "zh")] [string]$Lang ) $Uri = "https://api.guildwars2.com/v2/quests" if ($Ids) { $Uri += "?ids=$($Ids -join ",")" } if ($Page) { $Uri += "&page=$Page" } if ($PageSize) { $Uri += "&page_size=$PageSize" } if ($Lang) { $Uri += "&lang=$Lang" } try { Invoke-RestMethod -Uri $Uri -Method Get } catch { Write-Error "Failed to retrieve quests: $_" } } |