Public/Get-GW2CommerceTransactions.ps1
|
<#
.SYNOPSIS Retrieves the account's trading post transactions. .DESCRIPTION The Get-GW2CommerceTransactions cmdlet retrieves the current or historical buy or sell transactions for the authenticated account. This endpoint requires an API key with the 'tradingpost' scope. .PARAMETER APIKey Your Guild Wars 2 API Key. .PARAMETER Type The type of transactions to retrieve. Valid values: "current", "history". .PARAMETER Side The side of the transaction. Valid values: "buys", "sells". .EXAMPLE Get-GW2CommerceTransactions -APIKey "Your-API-Key" -Type "current" -Side "buys" Retrieves current buy transactions. .EXAMPLE Get-GW2CommerceTransactions -APIKey "Your-API-Key" -Type "history" -Side "sells" Retrieves transaction history for sells. .NOTES API Endpoint: /v2/commerce/transactions/:type/:side #> function Get-GW2CommerceTransactions { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$APIKey, [Parameter(Mandatory = $false)] [ValidateSet("current", "history")] [string]$Type, [Parameter(Mandatory = $false)] [ValidateSet("buys", "sells")] [string]$Side ) $Uri = "https://api.guildwars2.com/v2/commerce/transactions" $Headers = @{ "Authorization" = "Bearer $APIKey" } If ($Side -and !$Type) { Write-Error "Type is required when Side is specified." } If ($Type) { $Uri += "/$Type" } If ($Side) { $Uri += "/$Side" } try { Invoke-RestMethod -Uri $Uri -Method Get -Headers $Headers } catch { Write-Error "Failed to retrieve commerce transactions: $_" } } |