diff --git a/HaloAPI.psd1 b/HaloAPI.psd1 index cc55123..a666494 100644 --- a/HaloAPI.psd1 +++ b/HaloAPI.psd1 @@ -12,7 +12,7 @@ RootModule = '.\HaloAPI.psm1' # Version number of this module. - ModuleVersion = '1.14.0' + ModuleVersion = '1.14.1' # Supported PSEditions # CompatiblePSEditions = @() @@ -226,7 +226,9 @@ 'Set-HaloUser', 'Set-HaloWorkday', 'New-HaloTab', - 'Get-HaloTabs' + 'Get-HaloTabs', + 'Get-HaloOutcome', + 'New-HaloOutcome' ) diff --git a/Public/Get/Get-HaloOutcome.ps1 b/Public/Get/Get-HaloOutcome.ps1 new file mode 100644 index 0000000..5140572 --- /dev/null +++ b/Public/Get/Get-HaloOutcome.ps1 @@ -0,0 +1,63 @@ +# Get-HaloOutcome.ps1 +function Get-HaloOutcome { + [CmdletBinding( DefaultParameterSetName = 'Multi' )] + [OutputType([Object])] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Uses dynamic parameter parsing.')] + Param( + [Parameter( ParameterSetName = 'Single', Mandatory = $True )] + [int64]$OutcomeID, + [Parameter( ParameterSetName = 'Multi' )] + [int64]$Count, + [Parameter( ParameterSetName = 'Multi' )] + [Alias('pageinate')] + [switch]$Paginate, + [Parameter( ParameterSetName = 'Multi' )] + [Alias('page_size')] + [int32]$PageSize, + [Parameter( ParameterSetName = 'Multi' )] + [Alias('page_no')] + [int32]$PageNo, + [Parameter( ParameterSetName = 'Multi' )] + [string]$Order, + [Parameter( ParameterSetName = 'Multi' )] + [switch]$OrderDesc, + [Parameter( ParameterSetName = 'Single' )] + [switch]$IncludeDetails + ) + Invoke-HaloPreFlightCheck + $CommandName = $MyInvocation.MyCommand.Name + $Parameters = (Get-Command -Name $CommandName).Parameters + + if ($OutcomeID) { + $Parameters.Remove('OutcomeID') | Out-Null + } + try { + if ($OutcomeID) { + Write-Verbose "Running in single-item mode because '-OutcomeID' was provided." + $QSCollection = New-HaloQuery -CommandName $CommandName -Parameters $Parameters + $Resource = "api/Outcome/$($OutcomeID)" + $RequestParams = @{ + Method = 'GET' + Resource = $Resource + AutoPaginateOff = $True + QSCollection = $QSCollection + ResourceType = 'Outcome' + } + } else { + Write-Verbose 'Running in multi-item mode.' + $QSCollection = New-HaloQuery -CommandName $CommandName -Parameters $Parameters -IsMulti + $Resource = 'api/Outcome' + $RequestParams = @{ + Method = 'GET' + Resource = $Resource + AutoPaginateOff = $Paginate + QSCollection = $QSCollection + ResourceType = 'Outcome' + } + } + $OutcomeResults = New-HaloGETRequest @RequestParams + Return $OutcomeResults + } catch { + New-HaloError -ErrorRecord $_ + } +} diff --git a/Public/New/New-HaloOutcome.ps1 b/Public/New/New-HaloOutcome.ps1 new file mode 100644 index 0000000..3df3768 --- /dev/null +++ b/Public/New/New-HaloOutcome.ps1 @@ -0,0 +1,17 @@ +# New-HaloOutcome.ps1 +Function New-HaloOutcome { + [CmdletBinding( SupportsShouldProcess = $True )] + [OutputType([Object[]])] + Param ( + [Parameter( Mandatory = $True )] + [Object[]]$Outcome + ) + Invoke-HaloPreFlightCheck + try { + if ($PSCmdlet.ShouldProcess($Outcome -is [Array] ? 'Outcomes' : 'Outcome', 'Create')) { + New-HaloPOSTRequest -Object $Outcome -Endpoint 'Outcome' + } + } catch { + New-HaloError -ErrorRecord $_ + } +}