Public/Invoke-GCWfmHistoricalAdherenceQuery.ps1

<#
.SYNOPSIS
    Queries historical adherence data for a management unit in Genesys Cloud.

.DESCRIPTION
    Posts a query to the Genesys Cloud API to retrieve historical adherence
    information for agents within a specific management unit over a given time period.
    API Endpoint: POST /api/v2/workforcemanagement/managementunits/{managementUnitId}/historicaladherencequery

.PARAMETER ManagementUnitId
    The unique identifier of the management unit to query historical adherence for.

.PARAMETER Body
    The query request body containing parameters such as start date, end date,
    and user IDs. Should conform to the Genesys Cloud historical adherence query schema.

.EXAMPLE
    $queryBody = @{
        startDate = '2026-01-01T00:00:00Z'
        endDate = '2026-01-07T23:59:59Z'
        userIds = @('user-id-1', 'user-id-2')
    }
    Invoke-GCWfmHistoricalAdherenceQuery -ManagementUnitId 'abc123-def456' -Body $queryBody
    Queries historical adherence for specified users during the first week of January 2026.

.NOTES
    Genesys Cloud API: POST /api/v2/workforcemanagement/managementunits/{managementUnitId}/historicaladherencequery
#>

function Invoke-GCWfmHistoricalAdherenceQuery {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$ManagementUnitId,

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

    $endpoint = "workforcemanagement/managementunits/$ManagementUnitId/historicaladherencequery"
    return Invoke-GCApiRequest -Endpoint $endpoint -Method POST -Body $Body
}