Private/Get-Market.ps1

function Get-Market {
  [CmdletBinding()]
  param (
    [Parameter(ValueFromPipelineByPropertyName = $true)]
    [string]$Id,

    [Parameter()]
    [string]$Search,

    [Parameter()]
    [switch]$Active,

    [Parameter()]
    [int]$Limit = 20,

    [Parameter()]
    [ValidateSet('table', 'json')]
    [string]$Output = 'table'
  )

  process {
    $client = [GammaClient]::new()
    if ($Id) {
      $result = $client.GetMarket($Id)
    } else {
      $params = @{
        limit  = $Limit
        active = $Active.IsPresent
      }
      if ($Search) { $params['search'] = $Search }
      $result = $client.GetMarkets($params)
    }

    [PolymarketOutput]::Format($result, $Output)
  }
}