Public/Get-GW2BackstoryQuestions.ps1
|
<#
.SYNOPSIS Retrieves Biography questions from the Guild Wars 2 API. .DESCRIPTION The Get-GW2BackstoryQuestions cmdlet retrieves information about Biography questions from the Guild Wars 2 API. This endpoint provides details about the questions presented during character creation. .PARAMETER Ids The ID(s) of the questions 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-GW2BackstoryQuestions -Ids 7 Retrieves information for the question with ID 7. .EXAMPLE Get-GW2BackstoryQuestions -Ids "all" Retrieves information for all questions. .NOTES API Endpoint: /v2/backstory/questions #> function Get-GW2BackstoryQuestions { [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/backstory/questions" 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 backstory questions: $_" } } |