Private/accountsearch.ps1
<#
.SYNOPSIS Search for accounts .DESCRIPTION Search for accounts .NOTES Private function .EXAMPLE #> function accountsearch { [CmdletBinding(DefaultParameterSetName="ImplicitAuth")] param ( # User's API token [Parameter(Mandatory, ParameterSetName="ExplicitAuth")] [string] $authToken, # Text to search for [Parameter()] [string] $text, # Number of results to display [Parameter()] [int] $count, # Category's Id for filtering [Parameter()] [int] $categoryId, # Client's Id for filtering [Parameter()] [int] $clientId, # Tags' Id for filtering [Parameter()] [array] $tagsId, # Operator used for filtering. It can be either 'or' or 'and' [Parameter()] [string] $op ) begin { } process { $commonParameters = "Debug,WarningAction,ErrorVariable,InformationVariable,OutBuffer,Verbose,ErrorAction,InformationAction,WarningVariable,OutVariable,PipelineVariable" -split "," foreach ($commonParameter in $commonParameters) { if ($PSBoundParameters.ContainsKey($commonParameter)) { $PSBoundParameters.Remove($commonParameter) } } if ($PSCmdlet.ParameterSetName -eq "ImplicitAuth") { $PSBoundParameters["authToken"] = $global:__SysPassGlobal.Token.UserName } $payload = New-JsonRpcPayload -method "account/search" -params $PSBoundParameters Write-Debug "Payload:`n$payload" $response = Invoke-RestMethod -URI "$($global:__SysPassGlobal.uri)/api.php" -Body $payload -Method POST -ContentType "application/json" Write-Debug "Response:`n$($response | ConvertTo-Json)" if ($response.result.resultCode -eq 0) { $response.result.result } else { $response.error } } end { } } |