Public/Get-GW2RecipeSearch.ps1
|
<#
.SYNOPSIS Searches for recipes. .DESCRIPTION Calls the Guild Wars 2 API v2 /recipes/search endpoint. Allows searching for recipes by input (ingredient) or output (crafted item). .PARAMETER Input Optional. The item ID of an ingredient to search for. .PARAMETER Output Optional. The item ID of a crafted item to search for. .EXAMPLE Get-GW2RecipeSearch -Input 19700 Returns recipes that use item 19700 as an ingredient. .EXAMPLE Get-GW2RecipeSearch -Output 19700 Returns recipes that craft item 19700. .NOTES - Requires network access to api.guildwars2.com. - This is a public endpoint and does not require an API key. - Input and Output parameters are mutually exclusive. #> function Get-GW2RecipeSearch { [CmdletBinding(DefaultParameterSetName = "InputSearch")] param ( [Parameter(Mandatory = $true, ParameterSetName = "InputSearch")] [ValidateNotNullOrEmpty()] [int]$InputItemId, [Parameter(Mandatory = $true, ParameterSetName = "OutputSearch")] [ValidateNotNullOrEmpty()] [int]$OutputItemId ) $query = if ($PSCmdlet.ParameterSetName -eq "InputSearch") { "input=$InputItemId" } else { "output=$OutputItemId" } $url = "https://api.guildwars2.com/v2/recipes/search?$query" Invoke-RestMethod -Uri $url -Method Get } |