Public/Get-GW2CommerceExchangeCoins.ps1
|
<#
.SYNOPSIS Calculates the exchange rate from coins to gems. .DESCRIPTION The Get-GW2CommerceExchangeCoins cmdlet retrieves the current exchange rate for converting a specified amount of coins into gems. .PARAMETER Quantity The amount of coins (in copper) to exchange. .EXAMPLE Get-GW2CommerceExchangeCoins -Quantity 400000 Returns the amount of gems received for 400 gold. .NOTES API Endpoint: /v2/commerce/exchange/coins #> function Get-GW2CommerceExchangeCoins { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [int]$Quantity ) $Uri = "https://api.guildwars2.com/v2/commerce/exchange/coins" If ($Quantity -gt 0) { $Uri += "?quantity=$Quantity" } try { Invoke-RestMethod -Uri $Uri -Method Get } catch { Write-Error "Failed to retrieve coin exchange rate: $_" } } |