Public/CatalogItems/Update-AspireCatalogItem.ps1
|
<#
.SYNOPSIS Updates an existing catalog item in the Aspire API. .DESCRIPTION Uses Invoke-AspireRequest to perform a PUT request to the /CatalogItems endpoint. .PARAMETER CatalogItemID The ID of the catalog item to update (required). .PARAMETER CatalogItemCategoryID The ID of the catalog item category (required). .PARAMETER ItemType The type of the item (required). .PARAMETER AvailableToBid Whether the item is available to bid (required). .PARAMETER Active Whether the item is active (required). .PARAMETER ItemName Optional name of the item. .PARAMETER ItemAlternateName Optional alternate name of the item. .PARAMETER ItemDescription Optional description of the item. .PARAMETER ItemCode Optional code of the item. .PARAMETER ItemCost Optional cost of the item (decimal). .PARAMETER PurchaseUnitTypeID Optional ID of the purchase unit type. .PARAMETER AllocationUnitTypeID Optional ID of the allocation unit type. .PARAMETER UnitTypeAllocationConversion Optional conversion factor for unit types. .PARAMETER EPANumber Optional EPA number. .PARAMETER EPAName Optional EPA name. .PARAMETER Inventory Optional inventory flag. .PARAMETER TakeoffItemID Optional takeoff item ID. .PARAMETER PurchaseUnitCost Optional purchase unit cost. .PARAMETER ForceUnitPricing Optional force unit pricing flag. .PARAMETER AllocateFromMobile Optional allocate from mobile flag. .PARAMETER CatalogId Optional catalog ID. .PARAMETER MaterialBarcode1 Optional material barcode 1. .PARAMETER MaterialBarcode2 Optional material barcode 2. .PARAMETER CatalogItemBranches Optional array of catalog item branches. .OUTPUTS The ID of the updated catalog item. .EXAMPLE Update-AspireCatalogItem -CatalogItemID 123 -CatalogItemCategoryID 1 -ItemType "Material" -AvailableToBid $true -Active $true -ItemName "Updated Item" #> function Update-AspireCatalogItem { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [int]$CatalogItemID, [Parameter(Mandatory = $true)] [int]$CatalogItemCategoryID, [Parameter(Mandatory = $true)] [string]$ItemType, [Parameter(Mandatory = $true)] [bool]$AvailableToBid, [Parameter(Mandatory = $true)] [bool]$Active, [string]$ItemName = $null, [string]$ItemAlternateName = $null, [string]$ItemDescription = $null, [string]$ItemCode = $null, [decimal]$ItemCost = $null, [int]$PurchaseUnitTypeID = $null, [int]$AllocationUnitTypeID = $null, [decimal]$UnitTypeAllocationConversion = $null, [string]$EPANumber = $null, [string]$EPAName = $null, [bool]$Inventory = $null, [int]$TakeoffItemID = $null, [decimal]$PurchaseUnitCost = $null, [bool]$ForceUnitPricing = $null, [bool]$AllocateFromMobile = $null, [int]$CatalogId = $null, [string]$MaterialBarcode1 = $null, [string]$MaterialBarcode2 = $null, [array]$CatalogItemBranches = $null ) $body = @{ CatalogItemID = $CatalogItemID CatalogItemCategoryID = $CatalogItemCategoryID ItemType = $ItemType AvailableToBid = $AvailableToBid Active = $Active } if ($ItemName) { $body.ItemName = $ItemName } if ($ItemAlternateName) { $body.ItemAlternateName = $ItemAlternateName } if ($ItemDescription) { $body.ItemDescription = $ItemDescription } if ($ItemCode) { $body.ItemCode = $ItemCode } if ($ItemCost) { $body.ItemCost = $ItemCost } if ($PurchaseUnitTypeID) { $body.PurchaseUnitTypeID = $PurchaseUnitTypeID } if ($AllocationUnitTypeID) { $body.AllocationUnitTypeID = $AllocationUnitTypeID } if ($UnitTypeAllocationConversion) { $body.UnitTypeAllocationConversion = $UnitTypeAllocationConversion } if ($EPANumber) { $body.EPANumber = $EPANumber } if ($EPAName) { $body.EPAName = $EPAName } if ($Inventory -ne $null) { $body.Inventory = $Inventory } if ($TakeoffItemID) { $body.TakeoffItemID = $TakeoffItemID } if ($PurchaseUnitCost) { $body.PurchaseUnitCost = $PurchaseUnitCost } if ($ForceUnitPricing -ne $null) { $body.ForceUnitPricing = $ForceUnitPricing } if ($AllocateFromMobile -ne $null) { $body.AllocateFromMobile = $AllocateFromMobile } if ($CatalogId) { $body.CatalogId = $CatalogId } if ($MaterialBarcode1) { $body.MaterialBarcode1 = $MaterialBarcode1 } if ($MaterialBarcode2) { $body.MaterialBarcode2 = $MaterialBarcode2 } if ($CatalogItemBranches) { $body.CatalogItemBranches = $CatalogItemBranches } return Invoke-AspireRequest -Method PUT -Path "/CatalogItems" -Body $body -ApiVersion $null } |