Functions/New-IAWidgetConfigurationHistories.ps1

Function New-IAWidgetConfigurationHistories {
    <#
        .SYNOPSIS
            This is an internal command. This is used to create a new History Widget Configuration based on an inputted IAWidgetConfigurationHistories.
        .DESCRIPTION
            This command will take an inputted WidgetConfigurationHistoryObject and fit it in a webrequest after which it will be sent to Insight Analytics to be created.
            This is nessessary when creating a new Widget, usage is better explained when looking into New-IAWidgetObject.
    #>

    Param(
        [Parameter(Mandatory = $true)]
        [PSObject] $IAWidgetConfigurationHistories,
        [Switch] $Passthru
    )

    $Uri = "WidgetConfigurationHistories"
    $Body = $IAWidgetConfigurationHistories | ConvertTo-Json

    Write-Verbose "Body: $Body"

    $response = Invoke-IAQuery -QueryUrl $Uri -Method Post -Body $Body

    if($Passthru){

        if ($null -eq $response) {
            return $null
        }

        return $response
    }
}