Public/UnitTypes/New-AspireUnitTypes.ps1

<#
.SYNOPSIS
    Creates a new unit type in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a POST request to the /UnitTypes endpoint.
.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
    New-AspireUnitTypes -UnitTypeName "Test Type" -Active $true
#>

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

    $body = @{
        UnitTypeName = $UnitTypeName
    }

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

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