Public/Invoke-GCWfmForecast.ps1

<#
.SYNOPSIS
    Generates a short-term forecast for a business unit in Genesys Cloud.

.DESCRIPTION
    Posts a forecast generation request to the Genesys Cloud API for a specific
    business unit and week. Creates a new short-term forecast based on the provided parameters.
    API Endpoint: POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekDateId}/shorttermforecasts/generate

.PARAMETER BusinessUnitId
    The unique identifier of the business unit to generate the forecast for.

.PARAMETER WeekDateId
    The start date of the week for the forecast in ISO 8601 date format (e.g., '2026-03-30').

.PARAMETER Body
    The request body containing forecast generation parameters such as description
    and configuration. Should conform to the Genesys Cloud forecast generation schema.

.EXAMPLE
    $forecastBody = @{
        description = 'Weekly forecast'
        weekCount = 1
        canUseForScheduling = $true
    }
    Invoke-GCWfmForecast -BusinessUnitId 'bu-123' -WeekDateId '2026-03-30' -Body $forecastBody
    Generates a short-term forecast for the specified business unit and week.

.NOTES
    Genesys Cloud API: POST /api/v2/workforcemanagement/businessunits/{businessUnitId}/weeks/{weekDateId}/shorttermforecasts/generate
#>

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

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

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

    $endpoint = "workforcemanagement/businessunits/$BusinessUnitId/weeks/$WeekDateId/shorttermforecasts/generate"
    return Invoke-GCApiRequest -Endpoint $endpoint -Method POST -Body $Body
}