Public/Set-GCUserPresenceSource.ps1

<#
.SYNOPSIS
    Updates the presence of a user from a specific source in Genesys Cloud.

.DESCRIPTION
    Partially updates the presence status of a specific user from a given presence source
    using a PATCH request. This allows setting source-specific presence information.
    API Endpoint: PATCH /api/v2/users/{userId}/presences/{sourceId}

.PARAMETER UserId
    The unique identifier of the user.

.PARAMETER SourceId
    The presence source identifier (e.g., 'PURECLOUD', 'MICROSOFT').

.PARAMETER Body
    The request body containing the presence update. Accepts a hashtable or JSON string.
    Should include the 'presenceDefinition' with an 'id' property.

.EXAMPLE
    Set-GCUserPresenceSource -UserId '12345678-1234-1234-1234-123456789012' -SourceId 'PURECLOUD' -Body @{ presenceDefinition = @{ id = 'presence-def-id' } }
    Updates the user's presence from the specified source.

.NOTES
    Genesys Cloud API: PATCH /api/v2/users/{userId}/presences/{sourceId}
#>

function Set-GCUserPresenceSource {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$UserId,

        [Parameter(Mandatory = $true)]
        [string]$SourceId,

        [Parameter(Mandatory = $true)]
        [object]$Body
    )

    $endpoint = "users/$UserId/presences/$SourceId"
    return Invoke-GCApiRequest -Endpoint $endpoint -Method PATCH -Body $Body
}