Public/Get-GW2GuildTreasury.ps1

<#
.SYNOPSIS
Retrieves guild treasury from the Guild Wars 2 API.
 
.DESCRIPTION
Calls the Guild Wars 2 API v2 /guild/:id/treasury endpoint.
Returns the contents of the guild's treasury (items needed for upgrades).
 
.PARAMETER GuildId
Required. The unique guild ID (GUID) to retrieve treasury for.
 
.PARAMETER APIKey
Required. The API key to use for authentication.
Requires the 'guilds' scope.
 
.EXAMPLE
Get-GW2GuildTreasury -GuildId "116E0C0E-0035-44A9-BB22-4AE3E23127E5" -APIKey "YOUR_API_KEY"
Returns the guild treasury contents.
 
.NOTES
- Requires network access to api.guildwars2.com.
- Requires an authenticated API key with 'guilds' scope.
- These endpoints access guild-specific data and require an API key from the guild owner to view.
#>

function Get-GW2GuildTreasury {
    param (
        [Parameter(Mandatory = $true)]
        [string]$GuildId,

        [Parameter(Mandatory = $true)]
        [string]$APIKey
    )
    
    $url = "https://api.guildwars2.com/v2/guild/$GuildId/treasury"
    
    $headers = @{
        "Authorization" = "Bearer $APIKey"
    }

    $response = Invoke-RestMethod -Uri $url -Method Get -Headers $headers
    
    return $response
}