Public/Get-Pax8Products.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function Get-Pax8Products {
  [CmdletBinding()]
  Param(
    [ValidateSet("name", "vendor")]    
    [string]$sort,
    [string]$vendorName,
    [string]$id
  )

  if ($id) {
    $Products = Invoke-Pax8Request -method get -resource "products/$id"
  } else {

    $resourcefilter = ''
    if ($sort) {
      $resourcefilter = "$($resourcefilter)&sort=$($sort)"
    }
    if ($vendorName) {
      $resourcefilter = "$($resourcefilter)&vendorName=$($vendorName)"
    }
   
    $Products = Invoke-Pax8Request -method get -resource "products" -ResourceFilter $resourcefilter
  }

  return $Products

}