Public/Get-Pax8CompaniesV2API.ps1
function Get-Pax8CompaniesV2API { [CmdletBinding()] Param( [ValidateSet("name", "city", "country", "stateOrProvince", "postalCode")] [string]$sort, [string]$city, [string]$country, [string]$stateOrProvince, [string]$postalCode, [bool]$selfServiceAllowed, [bool]$billOnBehalfOfEnabled, [bool]$orderApprovalRequired, [ValidateSet("Active", "Inactive", "Deleted")] [string]$status, [string]$id ) if ($id) { $Companies = Invoke-Pax8Request -method get -resource "company/$id" } else { $resourcefilter = '' if ($sort) { $resourcefilter = "$($resourcefilter)&sort=$($sort)" } if ($city) { $resourcefilter = "$($resourcefilter)&city=$($city)" } if ($country) { $resourcefilter = "$($resourcefilter)&country=$($country)" } if ($stateOrProvince) { $resourcefilter = "$($resourcefilter)&stateOrProvince=$($stateOrProvince)" } if ($postalCode) { $resourcefilter = "$($resourcefilter)&postalCode=$($postalCode)" } if ($selfServiceAllowed) { $resourcefilter = "$($resourcefilter)&selfServiceAllowed=$($selfServiceAllowed)" } if ($billOnBehalfOfEnabled) { $resourcefilter = "$($resourcefilter)&billOnBehalfOfEnabled=$($billOnBehalfOfEnabled)" } if ($orderApprovalRequired) { $resourcefilter = "$($resourcefilter)&orderApprovalRequired=$($orderApprovalRequired)" } if ($status) { $resourcefilter = "$($resourcefilter)&status=$($status)" } $Companies = Invoke-Pax8Request -method get -resource "company" -ResourceFilter $resourcefilter -v2API:$true } return $Companies } |