Skip to content

Commit

Permalink
Fixed logic of how to retrieve components from project
Browse files Browse the repository at this point in the history
Logic for retrieving components from project now works fine for Project objects over the pipeline
  • Loading branch information
lipkau committed Jan 11, 2019
1 parent a0e29a6 commit 9db4972
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions JiraPS/Public/Get-JiraComponent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,22 @@ function Get-JiraComponent {

switch ($PSCmdlet.ParameterSetName) {
"ByProject" {
if ($Project.PSObject.TypeNames -contains 'JiraPS.Project') {
Write-Output (Get-JiraComponent -ComponentId ($Project.Components).id)
}
else {
foreach ($_project in $Project) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$_project]"
Write-Debug "[$($MyInvocation.MyCommand.Name)] Processing `$_project [$_project]"

if ($_project -is [string]) {
$parameter = @{
URI = $resourceURi -f "/project/$_project/components"
Method = "GET"
Credential = $Credential
}
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter
foreach ($_project in $Project) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Processing [$_project]"
Write-Debug "[$($MyInvocation.MyCommand.Name)] Processing `$_project [$_project]"

Write-Output (ConvertTo-JiraComponent -InputObject $result)
}
if ($_project -isnot [string]) {
$_project = $_project.Key
}
$parameter = @{
URI = $resourceURi -f "/project/$_project/components"
Method = "GET"
Credential = $Credential
}
Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking JiraMethod with `$parameter"
$result = Invoke-JiraMethod @parameter

Write-Output (ConvertTo-JiraComponent -InputObject $result)
}
}
"ByID" {
Expand Down

0 comments on commit 9db4972

Please sign in to comment.