Skip to content

Commit

Permalink
Applied formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ritzcrackr committed Feb 22, 2019
1 parent c2536e8 commit 9fd7a16
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 56 deletions.
9 changes: 3 additions & 6 deletions ConfluencePS/Private/Copy-CommonParameter.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function Copy-CommonParameter
{
function Copy-CommonParameter {
<#
.SYNOPSIS
This is a helper function to assist in creating a hashtable for splatting parameters to inner function calls.
Expand Down Expand Up @@ -36,10 +35,8 @@ function Copy-CommonParameter
)

[hashtable]$ht = @{}
foreach($key in $InputObject.Keys)
{
if ($key -in ($DefaultParameter + $AdditionalParameter))
{
foreach ($key in $InputObject.Keys) {
if ($key -in ($DefaultParameter + $AdditionalParameter)) {
$ht[$key] = $InputObject[$key]
}
}
Expand Down
6 changes: 3 additions & 3 deletions ConfluencePS/Public/Add-Attachment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ function Add-Attachment {
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Uri'] = "$ApiUri/content/{0}/child/attachment" -f $PageID
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Attachment]
$iwParameters['Uri'] = "$ApiUri/content/{0}/child/attachment" -f $PageID
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Attachment]

foreach ($file in $FilePath) {
$iwParameters["InFile"] = $file
Expand Down
4 changes: 2 additions & 2 deletions ConfluencePS/Public/Add-Label.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function Add-Label {
}

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Label]
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Label]

# Extract name if an Object is provided
if (($Label -is [ConfluencePS.Label]) -or $Label -is [ConfluencePS.Label[]]) {
Expand Down
10 changes: 5 additions & 5 deletions ConfluencePS/Public/ConvertTo-StorageFormat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ function ConvertTo-StorageFormat {
Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Uri'] = "$ApiUri/contentbody/convert/storage"
$iwParameters['Method'] = 'Post'
$iwParameters['Uri'] = "$ApiUri/contentbody/convert/storage"
$iwParameters['Method'] = 'Post'

foreach ($_content in $Content) {
$iwParameters['Body'] = @{
value = "$_content"
representation = 'wiki'
} | ConvertTo-Json
value = "$_content"
representation = 'wiki'
} | ConvertTo-Json

Write-Debug "[$($MyInvocation.MyCommand.Name)] Content to be sent: $($_content | Out-String)"
(Invoke-Method @iwParameters).value
Expand Down
13 changes: 7 additions & 6 deletions ConfluencePS/Public/ConvertTo-Table.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ function ConvertTo-Table {

# This ForEach needed if the content wasn't piped in
$Content | ForEach-Object {
If ($Vertical) {
If ($HeaderGenerated) {$pipe = '|'}
Else {$pipe = '||'}
if ($Vertical) {
if ($HeaderGenerated) {$pipe = '|'}
else {$pipe = '||'}

# Put an empty row between multiple tables (objects)
If ($Spacer) {
if ($Spacer) {
$null = $sb.AppendLine('')
}

Expand All @@ -42,9 +42,10 @@ function ConvertTo-Table {
}

$Spacer = $true
} Else {
}
else {
# Header row enclosed by ||
If (-not $HeaderGenerated) {
if (-not $HeaderGenerated) {
$null = $sb.AppendLine("|| {0} ||" -f ($_.PSObject.Properties.Name -join " || "))
$HeaderGenerated = $true
}
Expand Down
10 changes: 5 additions & 5 deletions ConfluencePS/Public/Get-Attachment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ function Get-Attachment {
}

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Method'] = 'Get'
$iwParameters['Method'] = 'Get'
$iwParameters['GetParameters'] = @{
expand = "version"
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Attachment]
expand = "version"
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Attachment]

if ($FileNameFilter) {
$iwParameters["GetParameters"]["filename"] = $FileNameFilter
Expand Down
8 changes: 4 additions & 4 deletions ConfluencePS/Public/Get-Label.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ function Get-Label {
}

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Method'] = 'Get'
$iwParameters['Method'] = 'Get'
$iwParameters['GetParameters'] = @{
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Label]
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Label]

# Paging
($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object {
Expand Down
9 changes: 5 additions & 4 deletions ConfluencePS/Public/Get-Page.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ function Get-Page {
$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Method'] = 'Get'
$iwParameters['GetParameters'] = @{
expand = "space,version,body.storage,ancestors"
limit = $PageSize
}
expand = "space,version,body.storage,ancestors"
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Page]
}

Expand All @@ -112,7 +112,8 @@ function Get-Page {
}
break
}
"bySpace" { # This includes 'bySpaceObject'
"bySpace" {
# This includes 'bySpaceObject'
$iwParameters["Uri"] = $resourceApi -f ''
$iwParameters["GetParameters"]["type"] = "page"
if ($SpaceKey) { $iwParameters["GetParameters"]["spaceKey"] = $SpaceKey }
Expand Down
10 changes: 5 additions & 5 deletions ConfluencePS/Public/Get-Space.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ function Get-Space {
Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Method'] = 'Get'
$iwParameters['Method'] = 'Get'
$iwParameters['GetParameters'] = @{
expand = "description.plain,icon,homepage,metadata.labels"
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Space]
expand = "description.plain,icon,homepage,metadata.labels"
limit = $PageSize
}
$iwParameters['OutputType'] = [ConfluencePS.Space]

# Paging
($PSCmdlet.PagingParameters | Get-Member -MemberType Property).Name | ForEach-Object {
Expand Down
8 changes: 4 additions & 4 deletions ConfluencePS/Public/Invoke-Method.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ function Invoke-Method {
$PSDefaultParameterValues = $global:PSDefaultParameterValues

$splatParameters = Copy-CommonParameter -InputObject $PSBoundParameters -AdditionalParameter @("Uri", "Method", "InFile", "OutFile")
$splatParameters['Headers'] = $_headers
$splatParameters['ContentType'] = "application/json; charset=utf-8"
$splatParameters['Headers'] = $_headers
$splatParameters['ContentType'] = "application/json; charset=utf-8"
$splatParameters['UseBasicParsing'] = $true
$splatParameters['ErrorAction'] = 'Stop'
$splatParameters['Verbose'] = $false # Overwrites verbose output
$splatParameters['ErrorAction'] = 'Stop'
$splatParameters['Verbose'] = $false # Overwrites verbose output

#add 'start' query parameter if Paging with Skip is being used
if (($PSCmdlet.PagingParameters) -and ($PSCmdlet.PagingParameters.Skip)) {
Expand Down
6 changes: 3 additions & 3 deletions ConfluencePS/Public/New-Page.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ function New-Page {
Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Uri'] = $resourceApi
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Page]
$iwParameters['Uri'] = $resourceApi
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Page]

$Content = [PSObject]@{
type = "page"
Expand Down
6 changes: 3 additions & 3 deletions ConfluencePS/Public/New-Space.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function New-Space {
}

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Uri'] = $resourceApi
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Space]
$iwParameters['Uri'] = $resourceApi
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Space]

$Body = @{
key = $SpaceKey
Expand Down
6 changes: 3 additions & 3 deletions ConfluencePS/Public/Set-Attachment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ function Set-Attachment {
Write-DebugMessage "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Uri'] = $resourceApi -f $Attachment.PageID, $Attachment.ID
$iwParameters['Method'] = 'Post'
$iwParameters['InFile'] = $FilePath
$iwParameters['Uri'] = $resourceApi -f $Attachment.PageID, $Attachment.ID
$iwParameters['Method'] = 'Post'
$iwParameters['InFile'] = $FilePath
$iwParameters['OutputType'] = [ConfluencePS.Attachment]

Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoking Set Attachment Method with `$parameter"
Expand Down
4 changes: 2 additions & 2 deletions ConfluencePS/Public/Set-Label.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function Set-Label {
}

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Label]
$iwParameters['Method'] = 'Post'
$iwParameters['OutputType'] = [ConfluencePS.Label]

$authAndApiUri = Copy-CommonParameter -InputObject $PSBoundParameters -AdditionalParameter "ApiUri"
foreach ($_page in $PageID) {
Expand Down
2 changes: 1 addition & 1 deletion ConfluencePS/Public/Set-Page.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function Set-Page {
Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

$iwParameters = Copy-CommonParameter -InputObject $PSBoundParameters
$iwParameters['Method'] = 'Put'
$iwParameters['Method'] = 'Put'
$iwParameters['OutputType'] = [ConfluencePS.Page]

$Content = [PSObject]@{
Expand Down

0 comments on commit 9fd7a16

Please sign in to comment.