Public/Get-GCExternalContacts.ps1

<#
.SYNOPSIS
    Retrieves a list of external contacts.

.DESCRIPTION
    Returns a paginated list of external contacts from Genesys Cloud.
    Uses the GET /api/v2/externalcontacts/contacts endpoint.

.PARAMETER PageSize
    The number of results per page. Defaults to 25.

.PARAMETER PageNumber
    The page number to retrieve. Defaults to 1.

.PARAMETER Q
    Search query string to filter contacts.

.EXAMPLE
    Get-GCExternalContacts

.EXAMPLE
    Get-GCExternalContacts -Q 'John'

.NOTES
    Genesys Cloud API: GET /api/v2/externalcontacts/contacts
#>

function Get-GCExternalContacts {
    [CmdletBinding()]
    param(
        [Parameter()]
        [int]$PageSize = 25,

        [Parameter()]
        [int]$PageNumber = 1,

        [Parameter()]
        [string]$Q
    )

    $endpoint = "externalcontacts/contacts"
    $queryParams = @{
        pageSize   = $PageSize
        pageNumber = $PageNumber
    }

    if ($Q) { $queryParams['q'] = $Q }

    return Invoke-GCApiRequest -Endpoint $endpoint -Method GET -QueryParameters $queryParams
}