Public/ServiceTaxOverrides/Update-AspireServiceTaxOverride.ps1

<#
.SYNOPSIS
    Updates an existing service tax override in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a PUT request to the /ServiceTaxOverrides endpoint.
.PARAMETER ServiceTaxOverrideID
    The ID of the service tax override to update (required).
.PARAMETER ServiceID
    The ID of the service (optional).
.PARAMETER StateProvinceCode
    The state/province code (required).
.PARAMETER LaborTaxable
    Whether labor is taxable (optional).
.PARAMETER MaterialTaxable
    Whether material is taxable (optional).
.PARAMETER EquipmentTaxable
    Whether equipment is taxable (optional).
.PARAMETER SubTaxable
    Whether sub is taxable (optional).
.PARAMETER OtherTaxable
    Whether other is taxable (optional).
.OUTPUTS
    The response from the API containing the result.
.EXAMPLE
    Update-AspireServiceTaxOverride -ServiceTaxOverrideID 1 -StateProvinceCode "CA" -LaborTaxable $false
#>

function Update-AspireServiceTaxOverride {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [int]$ServiceTaxOverrideID,
        [int]$ServiceID = $null,
        [Parameter(Mandatory = $true)]
        [string]$StateProvinceCode,
        [bool]$LaborTaxable = $null,
        [bool]$MaterialTaxable = $null,
        [bool]$EquipmentTaxable = $null,
        [bool]$SubTaxable = $null,
        [bool]$OtherTaxable = $null
    )

    $body = @{
        ServiceTaxOverrideID = $ServiceTaxOverrideID
        StateProvinceCode = $StateProvinceCode
    }

    if ($ServiceID) {
        $body.ServiceID = $ServiceID
    }
    if ($LaborTaxable -ne $null) {
        $body.LaborTaxable = $LaborTaxable
    }
    if ($MaterialTaxable -ne $null) {
        $body.MaterialTaxable = $MaterialTaxable
    }
    if ($EquipmentTaxable -ne $null) {
        $body.EquipmentTaxable = $EquipmentTaxable
    }
    if ($SubTaxable -ne $null) {
        $body.SubTaxable = $SubTaxable
    }
    if ($OtherTaxable -ne $null) {
        $body.OtherTaxable = $OtherTaxable
    }

    return Invoke-AspireRequest -Method PUT -Path "/ServiceTaxOverrides" -Body $body -ApiVersion $null
}