param( [Parameter(Mandatory = $true)] [string]$BaseUrl, [Parameter(Mandatory = $true)] [string]$Token, [string]$Phone = "+393331112233", [string]$Extension = "205", [string]$EventId = "evt-win-test-001" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $headers = @{ "X-CTI-Token" = $Token } function Invoke-Step { param( [Parameter(Mandatory = $true)] [string]$Label, [Parameter(Mandatory = $true)] [scriptblock]$Action ) Write-Host "" Write-Host "==== $Label ====" & $Action } Invoke-Step -Label "1. Lookup rubrica" -Action { $uri = "{0}/api/v1/cti/panasonic/lookup?phone={1}" -f $BaseUrl.TrimEnd('/'), [uri]::EscapeDataString($Phone) $response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get $response | ConvertTo-Json -Depth 8 } Invoke-Step -Label "2. Simulazione incoming" -Action { $body = @{ phone = $Phone direction = "inbound" event_type = "Delivered" called_extension = $Extension event_id = $EventId called_at = (Get-Date).ToString("o") note = "test incoming da PowerShell Windows" } | ConvertTo-Json $response = Invoke-RestMethod -Uri ("{0}/api/v1/cti/panasonic/incoming" -f $BaseUrl.TrimEnd('/')) -Headers $headers -Method Post -ContentType "application/json" -Body $body $response | ConvertTo-Json -Depth 8 } Start-Sleep -Seconds 2 Invoke-Step -Label "3. Simulazione call-ended" -Action { $body = @{ phone = $Phone direction = "inbound" event_type = "ConnectionCleared" called_extension = $Extension event_id = $EventId duration_seconds = 12 outcome = "risposta" ended_at = (Get-Date).ToString("o") note = "test call-ended da PowerShell Windows" } | ConvertTo-Json $response = Invoke-RestMethod -Uri ("{0}/api/v1/cti/panasonic/call-ended" -f $BaseUrl.TrimEnd('/')) -Headers $headers -Method Post -ContentType "application/json" -Body $body $response | ConvertTo-Json -Depth 8 } Write-Host "" Write-Host "Test completato. Se tutti i blocchi rispondono ok=true, la parte HTTP verso NetGescon e pronta."