Public/Vendors/New-AspireVendors.ps1

<#
.SYNOPSIS
    Creates a new vendor in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a POST request to the /Vendors endpoint.
.PARAMETER VendorName
    The name of the vendor (required).
.PARAMETER BranchID
    The ID of the branch (optional).
.PARAMETER AccountingVendorID
    The accounting vendor ID (optional).
.PARAMETER BillingTerms
    The billing terms (optional).
.PARAMETER Active
    Whether the vendor is active (optional).
.OUTPUTS
    The response from the API containing the result.
.EXAMPLE
    New-AspireVendors -VendorName "Test Vendor" -Active $true
#>

function New-AspireVendors {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$VendorName,
        [int]$BranchID = $null,
        [string]$AccountingVendorID = $null,
        [string]$BillingTerms = $null,
        [bool]$Active = $null
    )

    $body = @{
        VendorName = $VendorName
    }

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

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