Public/Get-GW2GuildLog.ps1

<#
.SYNOPSIS
Retrieves the guild event log from the Guild Wars 2 API.
 
.DESCRIPTION
Calls the Guild Wars 2 API v2 /guild/:id/log endpoint.
Returns the guild event log.
 
.PARAMETER GuildId
Required. The unique guild ID (GUID) to retrieve the log for.
 
.PARAMETER APIKey
Required. The API key to use for authentication.
Requires the 'guilds' scope.
 
.PARAMETER Since
Optional. An event ID to start retrieving logs from (exclusive).
This filters out all log entries not newer than the id given.
 
.EXAMPLE
Get-GW2GuildLog -GuildId "116E0C0E-0035-44A9-BB22-4AE3E23127E5" -APIKey "YOUR_API_KEY"
Returns the guild log.
 
.EXAMPLE
Get-GW2GuildLog -GuildId "116E0C0E-0035-44A9-BB22-4AE3E23127E5" -APIKey "YOUR_API_KEY" -Since 12345
Returns new log entries since event 12345.
 
.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-GW2GuildLog {
    param (
        [Parameter(Mandatory = $true)]
        [string]$GuildId,

        [Parameter(Mandatory = $true)]
        [string]$APIKey,

        [Parameter(Mandatory = $false)]
        [int]$Since
    )
    
    $url = "https://api.guildwars2.com/v2/guild/$GuildId/log"
    
    if ($Since) {
        $url = $url + "?since=$Since"
    }

    $headers = @{
        "Authorization" = "Bearer $APIKey"
    }

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