Skip to content

Commit

Permalink
Outcome Support
Browse files Browse the repository at this point in the history
New-HaloOutcome and Get-HaloOutcome support the ticket actions /Outcome (TOutcome) endpoint to retrieve and create ticket actions.
  • Loading branch information
cscaminaci committed Jul 8, 2023
1 parent 8a2787b commit 54c87d4
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
6 changes: 4 additions & 2 deletions HaloAPI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = '.\HaloAPI.psm1'

# Version number of this module.
ModuleVersion = '1.14.0'
ModuleVersion = '1.14.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -226,7 +226,9 @@
'Set-HaloUser',
'Set-HaloWorkday',
'New-HaloTab',
'Get-HaloTabs'
'Get-HaloTabs',
'Get-HaloOutcome',
'New-HaloOutcome'
)


Expand Down
63 changes: 63 additions & 0 deletions Public/Get/Get-HaloOutcome.ps1
Original file line number Diff line number Diff line change
@@ -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 $_
}
}
17 changes: 17 additions & 0 deletions Public/New/New-HaloOutcome.ps1
Original file line number Diff line number Diff line change
@@ -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 $_
}
}

0 comments on commit 54c87d4

Please sign in to comment.