Public/Invoke-GCSearch.ps1

<#
.SYNOPSIS
    Performs a global search.

.DESCRIPTION
    Executes a search query across Genesys Cloud resources.
    Uses the POST /api/v2/search endpoint.

.PARAMETER Body
    The search criteria object containing query, types, and other search parameters.

.PARAMETER Profile
    Optional search profile to use.

.EXAMPLE
    $searchBody = @{ query = @(@{ type = 'EXACT'; fields = @('name'); value = 'John' }); types = @('users') }
    Invoke-GCSearch -Body $searchBody

.NOTES
    Genesys Cloud API: POST /api/v2/search
#>

function Invoke-GCSearch {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [object]$Body,

        [Parameter()]
        [string]$Profile
    )

    $endpoint = "search"
    $queryParams = @{}

    if ($Profile) { $queryParams['profile'] = $Profile }

    if ($queryParams.Count -gt 0) {
        return Invoke-GCApiRequest -Endpoint $endpoint -Method POST -Body $Body -QueryParameters $queryParams
    }

    return Invoke-GCApiRequest -Endpoint $endpoint -Method POST -Body $Body
}