Public/UnitTypes/Update-AspireUnitTypes.ps1

<#
.SYNOPSIS
    Updates an existing unit type in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a PUT request to the /UnitTypes endpoint.
.PARAMETER UnitTypeID
    The ID of the unit type to update (required).
.PARAMETER UnitTypeName
    The name of the unit type (required).
.PARAMETER Active
    Whether the unit type is active (optional).
.OUTPUTS
    The response from the API containing the result.
.EXAMPLE
    Update-AspireUnitTypes -UnitTypeID 1 -UnitTypeName "Updated Type" -Active $true
#>

function Update-AspireUnitTypes {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [int]$UnitTypeID,
        [Parameter(Mandatory = $true)]
        [string]$UnitTypeName,
        [bool]$Active = $null
    )

    $body = @{
        UnitTypeID = $UnitTypeID
        UnitTypeName = $UnitTypeName
    }

    if ($Active -ne $null) {
        $body.Active = $Active
    }

    return Invoke-AspireRequest -Method PUT -Path "/UnitTypes" -Body $body
}