Classes/Public/TMActionParameter.ps1
class TMActionParameterPrompt { [String]$type = 'BLANK' [bool]$canCache = $true [bool]$allowMultiple [int]$minSize = 0 [int]$maxSize = 1024 ## Default Constructor TMActionParameterPrompt() {} ## ParamPrompt Object Constructor TMActionParameterPrompt([psobject]$_item) { $this.type = $_item.type $this.canCache = $_item.canCache $this.allowMultiple = $_item.allowMultiple $this.minSize = $_item.minSize $this.maxSize = $_item.maxSize } ## ParamName String Constructor ## This is a legacy compatibility constructor. Versions of TM prior to 6.3 ## did not have a 'prompt' object. The name of the parameter defined the prompt configuration settings TMActionParameterPrompt([string]$paramName) { ## Look for a Prompt prefix in the param name if ($ParamName -like 'get_*') { ## Split the ParamName into the requisite parts $ParamNameParts = $ParamName -split '_' $this.canCache = -Not ($ParamNameParts[1] -ilike '*-NOSAVE') $this.type = $ParamNameParts[1].ToUpper() -replace '-NOSAVE', '' } } } class TMActionParameter { [String]$paramName [String]$desc [String]$description [String]$type [String]$context [String]$fieldName [String]$fieldLabel ## Unofficial update that is not honored by TM [object]$value [bool]$required [TMActionParameterPrompt]$prompt TMActionParameter() {} TMActionParameter([String]$_json) { $ParameterData = ($_json | ConvertFrom-Json) $this.paramName = $ParameterData.paramName } TMActionParameter([PsCustomObject]$_item) { $this.paramName = $_item.paramName $this.context = $_item.context ?? 'USER_DEF' $this.description = $_item.description ? $_item.description : $_item.desc $this.desc = $_item.description ? $_item.description : $_item.desc $this.type = $_item.type ?? 'string' $this.fieldName = $_item.fieldName ?? '' $this.fieldLabel = $_item.fieldLabel ?? '' $this.required = $_item.required ?? $true $this.value = $_item.value ?? '' ## Test if the parameter name contains legacy prompt configurations if ($_item.paramName -like 'get_*') { $this.prompt = [TMActionParameterPrompt]::new($_item.paramName) $this.paramName = ($_item.paramName -split '_')[2] } elseif($_item.prompt) { $this.prompt = [TMActionParameterPrompt]::new($_item.prompt) } else { $this.prompt = [TMActionParameterPrompt]::new() } } } |