Public/Properties/New-AspireProperty.ps1

<#
.SYNOPSIS
    Creates a new property in the Aspire API.
.DESCRIPTION
    Uses Invoke-AspireRequest to perform a POST request to the /Properties endpoint.
.PARAMETER PropertyName
    The name of the property (required).
.PARAMETER BranchID
    The branch ID (required).
.PARAMETER PropertyNameAbr
    Optional abbreviated property name.
.PARAMETER PropertyStatusID
    Optional property status ID.
.PARAMETER PropertyTags
    Optional property tags.
.PARAMETER AddressLine1
    Optional address line 1.
.PARAMETER AddressLine2
    Optional address line 2.
.PARAMETER City
    Optional city.
.PARAMETER StateProvinceCode
    Optional state/province code.
.PARAMETER ZipCode
    Optional zip code.
.PARAMETER CountyID
    Optional county ID.
.PARAMETER TaxJurisdictionID
    Optional tax jurisdiction ID.
.PARAMETER GEOPerimeter
    Optional GEO perimeter.
.PARAMETER SequenceNumber
    Optional sequence number.
.PARAMETER Budget
    Optional budget.
.PARAMETER AccountOwnerContactID
    Optional account owner contact ID.
.PARAMETER PrimaryContactID
    Optional primary contact ID.
.PARAMETER BillingContactID
    Optional billing contact ID.
.PARAMETER ProductionManagerContactID
    Optional production manager contact ID.
.PARAMETER Active
    Optional active status (default: true).
.PARAMETER SeparateInvoices
    Optional separate invoices flag.
.PARAMETER EmailInvoiceFlag
    Optional email invoice flag.
.PARAMETER UpdateBranchReference
    Optional update branch reference flag.
.PARAMETER PaymentTermsID
    Optional payment terms ID.
.PARAMETER IndustryID
    Optional industry ID.
.PARAMETER LeadSourceID
    Optional lead source ID.
.PARAMETER CompetitorID
    Optional competitor ID.
.PARAMETER PropertyGroupID
    Optional property group ID.
.PARAMETER Note
    Optional note.
.PARAMETER ProductionNote
    Optional production note.
.PARAMETER SnowNote
    Optional snow note.
.PARAMETER CollectionNotes
    Optional collection notes.
.PARAMETER IntegrationID
    Optional integration ID.
.PARAMETER PropertyTypeID
    Optional property type ID.
.OUTPUTS
    The response from the API containing the property details.
.EXAMPLE
    New-AspireProperty -PropertyName "Sample Property" -BranchID 1
#>

function New-AspireProperty {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$PropertyName,
        [Parameter(Mandatory = $true)]
        [int]$BranchID,
        [string]$PropertyNameAbr = $null,
        [int]$PropertyStatusID = $null,
        [string]$PropertyTags = $null,
        [string]$AddressLine1 = $null,
        [string]$AddressLine2 = $null,
        [string]$City = $null,
        [string]$StateProvinceCode = $null,
        [string]$ZipCode = $null,
        [int]$CountyID = $null,
        [int]$TaxJurisdictionID = $null,
        [double]$GEOPerimeter = $null,
        [string]$SequenceNumber = $null,
        [double]$Budget = $null,
        [int]$AccountOwnerContactID = $null,
        [int]$PrimaryContactID = $null,
        [int]$BillingContactID = $null,
        [int]$ProductionManagerContactID = $null,
        [bool]$Active = $true,
        [bool]$SeparateInvoices = $null,
        [bool]$EmailInvoiceFlag = $null,
        [bool]$UpdateBranchReference = $null,
        [int]$PaymentTermsID = $null,
        [int]$IndustryID = $null,
        [int]$LeadSourceID = $null,
        [int]$CompetitorID = $null,
        [int]$PropertyGroupID = $null,
        [string]$Note = $null,
        [string]$ProductionNote = $null,
        [string]$SnowNote = $null,
        [string]$CollectionNotes = $null,
        [string]$IntegrationID = $null,
        [int]$PropertyTypeID = $null
    )

    $body = @{
        PropertyName = $PropertyName
        BranchID = $BranchID
        Active = $Active
    }

    if ($PropertyNameAbr) {
        $body.PropertyNameAbr = $PropertyNameAbr
    }
    if ($PropertyStatusID) {
        $body.PropertyStatusID = $PropertyStatusID
    }
    if ($PropertyTags) {
        $body.PropertyTags = $PropertyTags
    }
    if ($AddressLine1) {
        $body.AddressLine1 = $AddressLine1
    }
    if ($AddressLine2) {
        $body.AddressLine2 = $AddressLine2
    }
    if ($City) {
        $body.City = $City
    }
    if ($StateProvinceCode) {
        $body.StateProvinceCode = $StateProvinceCode
    }
    if ($ZipCode) {
        $body.ZipCode = $ZipCode
    }
    if ($CountyID) {
        $body.CountyID = $CountyID
    }
    if ($TaxJurisdictionID) {
        $body.TaxJurisdictionID = $TaxJurisdictionID
    }
    if ($GEOPerimeter) {
        $body.GEOPerimeter = $GEOPerimeter
    }
    if ($SequenceNumber) {
        $body.SequenceNumber = $SequenceNumber
    }
    if ($Budget) {
        $body.Budget = $Budget
    }
    if ($AccountOwnerContactID) {
        $body.AccountOwnerContactID = $AccountOwnerContactID
    }
    if ($PrimaryContactID) {
        $body.PrimaryContactID = $PrimaryContactID
    }
    if ($BillingContactID) {
        $body.BillingContactID = $BillingContactID
    }
    if ($ProductionManagerContactID) {
        $body.ProductionManagerContactID = $ProductionManagerContactID
    }
    if ($SeparateInvoices -ne $null) {
        $body.SeparateInvoices = $SeparateInvoices
    }
    if ($EmailInvoiceFlag -ne $null) {
        $body.EmailInvoiceFlag = $EmailInvoiceFlag
    }
    if ($UpdateBranchReference -ne $null) {
        $body.UpdateBranchReference = $UpdateBranchReference
    }
    if ($PaymentTermsID) {
        $body.PaymentTermsID = $PaymentTermsID
    }
    if ($IndustryID) {
        $body.IndustryID = $IndustryID
    }
    if ($LeadSourceID) {
        $body.LeadSourceID = $LeadSourceID
    }
    if ($CompetitorID) {
        $body.CompetitorID = $CompetitorID
    }
    if ($PropertyGroupID) {
        $body.PropertyGroupID = $PropertyGroupID
    }
    if ($Note) {
        $body.Note = $Note
    }
    if ($ProductionNote) {
        $body.ProductionNote = $ProductionNote
    }
    if ($SnowNote) {
        $body.SnowNote = $SnowNote
    }
    if ($CollectionNotes) {
        $body.CollectionNotes = $CollectionNotes
    }
    if ($IntegrationID) {
        $body.IntegrationID = $IntegrationID
    }
    if ($PropertyTypeID) {
        $body.PropertyTypeID = $PropertyTypeID
    }

    return Invoke-AspireRequest -Method POST -Path "/Properties" -Body $body -ApiVersion $null
}