diff --git a/DattoAPI/Private/apiCalls/ConvertTo-DattoQueryString.ps1 b/DattoAPI/Private/apiCalls/ConvertTo-DattoQueryString.ps1 index 1823b10..9411fa7 100644 --- a/DattoAPI/Private/apiCalls/ConvertTo-DattoQueryString.ps1 +++ b/DattoAPI/Private/apiCalls/ConvertTo-DattoQueryString.ps1 @@ -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 @@ -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)] @@ -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', @@ -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. diff --git a/docs/site/Internal/ConvertTo-DattoQueryString.md b/docs/site/Internal/ConvertTo-DattoQueryString.md index 98b505d..6f60513 100644 --- a/docs/site/Internal/ConvertTo-DattoQueryString.md +++ b/docs/site/Internal/ConvertTo-DattoQueryString.md @@ -20,7 +20,7 @@ ConvertTo-DattoQueryString [-uri_Filter] [-resource_Uri] [< ``` ## 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 @@ -58,7 +58,7 @@ Type: Hashtable Parameter Sets: (All) Aliases: -Required: True +Required: False Position: 1 Default value: None Accept pipeline input: True (ByValue)