Public/Get-GW2HomesteadDecorations.ps1

<#
.SYNOPSIS
Retrieves information about homestead decorations.
 
.DESCRIPTION
Calls the Guild Wars 2 API v2 /homestead/decorations endpoint.
- If no parameters are provided, returns a list of all available decoration IDs.
- If 'Ids' is provided, returns objects containing details for the specified decorations.
- If 'Page' and 'PageSize' are provided, returns a paged list of decorations.
 
.PARAMETER Ids
Optional. A list of decoration IDs (integers) to retrieve.
Example: 1, 2
 
.PARAMETER Page
Optional. The page number to retrieve (0-indexed).
 
.PARAMETER PageSize
Optional. The number of items per page.
 
.PARAMETER Lang
Optional. The language to return results in (en, es, de, fr, ko, zh).
 
.EXAMPLE
Get-GW2HomesteadDecorations
Returns a list of all decoration IDs.
 
.EXAMPLE
Get-GW2HomesteadDecorations -Ids 1
Returns details for the specified decoration.
 
.EXAMPLE
Get-GW2HomesteadDecorations -Page 0 -PageSize 10
Returns the first 10 decorations.
 
.notes
- Requires network access to api.guildwars2.com.
- This is a public endpoint and does not require an API key.
#>

function Get-GW2HomesteadDecorations {
    param (
        [Parameter(Mandatory = $false)]
        [int[]]$Ids,

        [Parameter(Mandatory = $false)]
        [int]$Page,

        [Parameter(Mandatory = $false)]
        [int]$PageSize,

        [Parameter(Mandatory = $false)]
        [ValidateSet("en", "es", "de", "fr", "ko", "zh")]
        [string]$Lang
    )
    
    $url = "https://api.guildwars2.com/v2/homestead/decorations"

    if ($Ids) {
        # Join IDs with commas for the query parameter
        $idString = $Ids -join ','
        $url = $url + "?ids=$idString"
    }
    elseif ($PSBoundParameters.ContainsKey('Page') -and $PSBoundParameters.ContainsKey('PageSize')) {
        $url = $url + "?page=$Page&page_size=$PageSize"
    }

    if ($Lang) {
        if ($url.Contains("?")) {
            $url = $url + "&lang=$Lang"
        }
        else {
            $url = $url + "?lang=$Lang"
        }
    }

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