Skip to content

Commit

Permalink
Update Get-JiraIssueCreateMetadata.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmbaker authored Oct 9, 2023
1 parent 873c3a7 commit 007e0c0
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions JiraPS/Public/Get-JiraIssueCreateMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,40 +46,16 @@ function Get-JiraIssueCreateMetadata {
Method = "GET"
Credential = $Credential
}

Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter

if ($result) {
if (@($result.projects).Count -eq 0) {
$errorMessage = @{
Category = "InvalidResult"
CategoryActivity = "Validating response"
Message = "No projects were found for the given project [$Project]. Use Get-JiraProject for more details."
}
Write-Error @errorMessage
}
elseif (@($result.projects).Count -gt 1) {
$errorMessage = @{
Category = "InvalidResult"
CategoryActivity = "Validating response"
Message = "Multiple projects were found for the given project [$Project]. Refine the parameters to return only one project."
}
Write-Error @errorMessage
}

if (@($result.projects.issuetypes) -eq 0) {
$errorMessage = @{
Category = "InvalidResult"
CategoryActivity = "Validating response"
Message = "No issue types were found for the given issue type [$IssueType]. Use Get-JiraIssueType for more details."
}
Write-Error @errorMessage
}
elseif (@($result.projects.issuetypes).Count -gt 1) {
if (@($result.values).Count -eq 0) {
$errorMessage = @{
Category = "InvalidResult"
CategoryActivity = "Validating response"
Message = "Multiple issue types were found for the given issue type [$IssueType]. Refine the parameters to return only one issue type."
Message = "No values were found for the given project [$Project]. Use Get-JiraProject for more details."
}
Write-Error @errorMessage
}
Expand Down

0 comments on commit 007e0c0

Please sign in to comment.