Public/Get-GW2WorldBosses.ps1
|
<#
.SYNOPSIS Retrieves world boss information from the Guild Wars 2 API. .DESCRIPTION Calls the Guild Wars 2 API v2 /worldbosses endpoint. - If no parameters are provided, returns a list of all available world boss IDs. - If 'Ids' is provided, returns objects containing details for the specified world bosses. - If 'All' is specified, returns all available world bosses. .PARAMETER Ids Optional. A list of world boss IDs (strings) to retrieve. Example: "admiral_taidha_covington", "claw_of_jormag" .PARAMETER All Optional. If set, retrieves all world bosses. .EXAMPLE Get-GW2WorldBosses Returns a list of all world boss IDs. .EXAMPLE Get-GW2WorldBosses -Ids "claw_of_jormag" Returns details for the specified world boss. .EXAMPLE Get-GW2WorldBosses -All Returns details for all world bosses. .NOTES - Requires network access to api.guildwars2.com. - This is a public endpoint and does not require an API key. #> function Get-GW2WorldBosses { param ( [Parameter(Mandatory = $false)] [string[]]$Ids, [Parameter(Mandatory = $false)] [switch]$All ) $url = "https://api.guildwars2.com/v2/worldbosses" if ($All) { $url = $url + "?ids=all" } elseif ($Ids) { # Join IDs with commas for the query parameter $idString = $Ids -join ',' $url = $url + "?ids=$idString" } $response = Invoke-RestMethod -Uri $url -Method Get return $response } |