Public/Get-GW2Recipes.ps1

<#
.SYNOPSIS
Retrieves information about recipes.
 
.DESCRIPTION
Calls the Guild Wars 2 API v2 /recipes endpoint.
- If no parameters are provided, returns a list of all available recipe IDs.
- If 'Ids' is provided, returns objects containing details for the specified recipes.
 
.PARAMETER Ids
Optional. A list of recipe IDs (integers).
Example: 7319, 7314
 
.EXAMPLE
Get-GW2Recipes
Returns a list of all recipe IDs.
 
.EXAMPLE
Get-GW2Recipes -Ids 7319
Returns details for the specified recipe.
 
.NOTES
- Requires network access to api.guildwars2.com.
- This is a public endpoint and does not require an API key.
#>

function Get-GW2Recipes {
    param (
        [Parameter(Mandatory = $false)]
        [object]$Ids
    )
    
    $url = "https://api.guildwars2.com/v2/recipes"

    if ($Ids) {
        # Join IDs with commas for the query parameter
        if ($Ids -is [array]) {
            $idString = $Ids -join ','
        }
        else {
            $idString = $Ids
        }
        $url = $url + "?ids=$idString"
    }

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