Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions DattoAPI/Private/apiCalls/ConvertTo-DattoQueryString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ function ConvertTo-DattoQueryString {
Converts uri filter parameters

.DESCRIPTION
The Invoke-DattoRequest cmdlet converts & formats uri filter parameters
The ConvertTo-DattoQueryString cmdlet converts & formats uri filter parameters
from a function which are later used to make the full resource uri for
an API call

This is an internal helper function the ties in directly with the
This is an internal helper function that ties in directly with the
Invoke-DattoRequest & any public functions that define parameters

.PARAMETER uri_Filter
Expand Down Expand Up @@ -44,7 +44,7 @@ function ConvertTo-DattoQueryString {

[CmdletBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
[hashtable]$uri_Filter,

[Parameter(Mandatory = $true)]
Expand All @@ -55,10 +55,6 @@ param(

process {

if (-not $uri_Filter) {
return ""
}

$excludedParameters = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable',
'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable',
'allPages', 'page', 'perPage',
Expand All @@ -69,20 +65,21 @@ param(

$query_Parameters = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)

ForEach ( $Key in $uri_Filter.GetEnumerator() ){
if ($uri_Filter) {
ForEach ( $Key in $uri_Filter.GetEnumerator() ){

if( $excludedParameters -contains $Key.Key ){$null}
elseif ( $Key.Value.GetType().IsArray ){
Write-Verbose "[ $($Key.Key) ] is an array parameter"
foreach ($Value in $Key.Value) {
#$ParameterName = $Key.Key
$query_Parameters.Add($Key.Key, $Value)
if( $excludedParameters -contains $Key.Key ){$null}
elseif ( $Key.Value.GetType().IsArray ){
Write-Verbose "[ $($Key.Key) ] is an array parameter"
foreach ($Value in $Key.Value) {
$query_Parameters.Add($Key.Key, $Value)
}
}
else{
$query_Parameters.Add($Key.Key, $Key.Value)
}
}
else{
$query_Parameters.Add($Key.Key, $Key.Value)
}

}
}

# Build the request and load it with the query string.
Expand Down
4 changes: 2 additions & 2 deletions docs/site/Internal/ConvertTo-DattoQueryString.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ConvertTo-DattoQueryString [-uri_Filter] <Hashtable> [-resource_Uri] <String> [<
```

## DESCRIPTION
The Invoke-DattoRequest cmdlet converts & formats uri filter parameters
The ConvertTo-DattoQueryString cmdlet converts & formats uri filter parameters
from a function which are later used to make the full resource uri for
an API call

Expand Down Expand Up @@ -58,7 +58,7 @@ Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: True
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Expand Down