Public/New-GCWfmTimeOffRequest.ps1

<#
.SYNOPSIS
    Creates a new time off request in a management unit in Genesys Cloud.

.DESCRIPTION
    Posts a new time off request to the Genesys Cloud API for a specific management unit.
    API Endpoint: POST /api/v2/workforcemanagement/managementunits/{managementUnitId}/timeoffrequests

.PARAMETER ManagementUnitId
    The unique identifier of the management unit to create the time off request in.

.PARAMETER Body
    The request body containing time off request details such as user ID, activity code ID,
    date ranges, and notes. Should conform to the Genesys Cloud time off request schema.

.EXAMPLE
    $requestBody = @{
        users = @(@{ id = 'user-456' })
        activityCodeId = 'activity-789'
        dateRanges = @(@{
            startDate = '2026-03-15'
            lengthMinutes = 480
        })
        notes = 'Vacation day'
    }
    New-GCWfmTimeOffRequest -ManagementUnitId 'mu-123' -Body $requestBody
    Creates a new time off request for the specified user in the management unit.

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

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

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

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