Public/Get-GW2StorySeasons.ps1
|
<#
.SYNOPSIS Retrieves story seasons from the Guild Wars 2 API. .DESCRIPTION The Get-GW2StorySeasons cmdlet retrieves information about the story seasons in the Story Journal from the Guild Wars 2 API. .PARAMETER Ids The ID(s) of the seasons 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-GW2StorySeasons -Ids "215AAA0F-CD37-4F66-8BC0-3614B743B8A5" Retrieves information for the specified season ID. .EXAMPLE Get-GW2StorySeasons -Ids "all" Retrieves information for all story seasons. .NOTES API Endpoint: /v2/stories/seasons #> function Get-GW2StorySeasons { [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/stories/seasons" 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 story seasons: $_" } } |