Public/Get-GW2MapChests.ps1

<#
.SYNOPSIS
Retrieves map chest information from the Guild Wars 2 API.
 
.DESCRIPTION
Calls the Guild Wars 2 API v2 /mapchests endpoint.
- If no parameters are provided, returns a list of all available map chest IDs.
- If 'Ids' is provided, returns objects containing details for the specified map chests.
- If 'All' is specified, returns all available map chests.
 
.PARAMETER Ids
Optional. A list of map chest IDs (strings) to retrieve.
Example: "auric_basin_heros_choice_chest"
 
.PARAMETER All
Optional. If set, retrieves all map chests.
 
.EXAMPLE
Get-GW2MapChests
Returns a list of all map chest IDs.
 
.EXAMPLE
Get-GW2MapChests -Ids "auric_basin_heros_choice_chest"
Returns details for the specified map chest.
 
.EXAMPLE
Get-GW2MapChests -All
Returns details for all map chests.
 
.NOTES
- Requires network access to api.guildwars2.com.
- This is a public endpoint and does not require an API key.
#>

function Get-GW2MapChests {
    param (
        [Parameter(Mandatory = $false)]
        [string[]]$Ids,

        [Parameter(Mandatory = $false)]
        [switch]$All
    )
    
    $url = "https://api.guildwars2.com/v2/mapchests"

    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
}