Pax8API/Public/Get-Pax8PortalCatalogProduct.ps1

function Get-Pax8PortalCatalogProduct {
    <#
    .SYNOPSIS
    Read Pax8 portal catalogue product cards by product UUID.

    .DESCRIPTION
    Uses the Pax8 portal catalogue endpoint that powers app.pax8.com product cards.
    This is not part of the published Partner OpenAPI spec, but it is a read-only
    path that exposes portal-only fields such as legacyId, billsInArrears,
    partnerCost, and customerCost.

    .PARAMETER ProductId
    One or more Pax8 product UUIDs.

    .PARAMETER Page
    Result page. Defaults to 0.

    .PARAMETER Size
    Page size. Defaults to 50.

    .PARAMETER Raw
    Return the unmodified portal response.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
        [Alias('Id', 'Uuid')]
        [guid[]]$ProductId,

        [ValidateRange(0, [int]::MaxValue)]
        [int]$Page = 0,

        [ValidateRange(1, 200)]
        [int]$Size = 50,

        [switch]$Raw
    )

    begin {
        $ids = [System.Collections.Generic.List[string]]::new()
    }

    process {
        foreach ($id in $ProductId) {
            if ($id -ne [guid]::Empty) {
                $ids.Add([string]$id)
            }
        }
    }

    end {
        Assert-Pax8Session -Audience 'https://api.pax8.com'

        $body = [ordered]@{
            productIds = @($ids | Select-Object -Unique)
        }
        $uri = [uri]("https://app.pax8.com/api/catalog/products/search?page=$Page&size=$Size")
        $response = Invoke-Pax8RestMethod -Uri $uri -Method POST -Body $body

        if ($Raw) {
            return $response
        }

        if ($response.PSObject.Properties['content']) {
            return $response.content
        }

        $response
    }
}