Skip to content

Commit

Permalink
Fixes for PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ritzcrackr committed Feb 22, 2019
1 parent 9324d34 commit c2536e8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
20 changes: 19 additions & 1 deletion ConfluencePS/Private/Copy-CommonParameter.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
function Copy-CommonParameter
{
<#
.SYNOPSIS
This is a helper function to assist in creating a hashtable for splatting parameters to inner function calls.
.DESCRIPTION
This command copies all of the keys of a hashtable to a new hashtable if the key name matches the DefaultParameter
or the AdditionalParameter values. This function is designed to help select only function parameters that have been
set, so they can be passed to inner functions if and only if they have been set.
.EXAMPLE
PS C:\> Copy-CommonParameter -InputObject $PSBoundParameters
Returns a hashtable that contains all of the bound default parameters.
.EXAMPLE
PS C:\> Copy-CommonParameter -InputObject $PSBoundParameters -AdditionalParameter "ApiUri"
Returns a hashtable that contains all of the bound default parameters and the "ApiUri" parameter.
#>
[CmdletBinding( SupportsShouldProcess = $false )]
[OutputType(
[hashtable]
)]
#[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')]
param
(
[Parameter(Mandatory = $true)]
Expand Down
12 changes: 6 additions & 6 deletions ConfluencePS/Public/Get-ChildPage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ function Get-ChildPage {
}

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Uri'] = if ($Recurse.IsPresent) {"$ApiUri/content/{0}/descendant/page" -f $PageID} else {"$ApiUri/content/{0}/child/page" -f $PageID}
$iwParameters['Method'] = 'Get'
$iwParameters['Uri'] = if ($Recurse.IsPresent) {"$ApiUri/content/{0}/descendant/page" -f $PageID} else {"$ApiUri/content/{0}/child/page" -f $PageID}
$iwParameters['Method'] = 'Get'
$iwParameters['GetParameters'] = @{
expand = "space,version,body.storage,ancestors"
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Page]
expand = "space,version,body.storage,ancestors"
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Page]

# Paging
($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object {
Expand Down
5 changes: 3 additions & 2 deletions ConfluencePS/Public/New-Page.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ function New-Page {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"

$resourceApi = "$ApiUri/content"

#this is the splat hashtable that passes the auth and uri to calls but not Invoke-Method, i.e. Get-Page
$authAndApiUri = Copy-CommonParameter -InputObject $PSBoundParameters -AdditionalParameter "ApiUri"
}

PROCESS {
Expand Down Expand Up @@ -96,14 +99,12 @@ function New-Page {

if (($ParentID) -and !($SpaceKey)) {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] SpaceKey not specified. Retrieving from Get-ConfluencePage -PageID $ParentID"
$authAndApiUri = Copy-CommonParameter -InputObject $PSBoundParameters -AdditionalParameter "ApiUri"
$SpaceKey = (Get-Page -PageID $ParentID @authAndApiUri).Space.Key
}

# If -Convert is flagged, call ConvertTo-ConfluenceStorageFormat against the -Body
if ($Convert) {
Write-Verbose '[$($MyInvocation.MyCommand.Name)] -Convert flag active; converting content to Confluence storage format'
$authAndApiUri = Copy-CommonParameter -InputObject $PSBoundParameters -AdditionalParameter "ApiUri"
$Body = ConvertTo-StorageFormat -Content $Body @authAndApiUri
}

Expand Down

0 comments on commit c2536e8

Please sign in to comment.