Public/Get-GW2BackstoryAnswers.ps1

<#
    .SYNOPSIS
        Retrieves Biography answers from the Guild Wars 2 API.
 
    .DESCRIPTION
        The Get-GW2BackstoryAnswers cmdlet retrieves information about Biography answers from the Guild Wars 2 API.
        This endpoint provides details about the answers available during character creation.
 
    .PARAMETER Ids
        The ID(s) of the answers 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-GW2BackstoryAnswers -Ids "7-53"
        Retrieves information for the answer with ID "7-53".
 
    .EXAMPLE
        Get-GW2BackstoryAnswers -Ids "all"
        Retrieves information for all answers.
 
    .NOTES
        API Endpoint: /v2/backstory/answers
    #>

function Get-GW2BackstoryAnswers {
    [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/answers"
    
    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 answers: $_"
    }
}