corp-app/test-departments-api.ps1

45 lines
1.8 KiB
PowerShell

# Тестовый скрипт для проверки API отделов
$apiUrl = "https://corp.robotail.pro/api/v1/departments/"
Write-Host "Получение данных из API..." -ForegroundColor Yellow
Write-Host "URL: $apiUrl" -ForegroundColor Gray
Write-Host ""
try {
$response = Invoke-RestMethod -Uri $apiUrl -Method Get -Headers @{
"Accept" = "application/json"
}
Write-Host "✅ Успешно получено отделов: $($response.results.Count)" -ForegroundColor Green
Write-Host ""
# Выводим первые 3 отдела
$response.results | Select-Object -First 3 | ForEach-Object {
Write-Host "─────────────────────────────────" -ForegroundColor Cyan
Write-Host "ID: $($_.id)" -ForegroundColor White
Write-Host "Name: $($_.name)" -ForegroundColor White
Write-Host "Description: '$($_.description)'" -ForegroundColor Yellow
Write-Host "Description Length: $($_.description.Length)" -ForegroundColor Gray
Write-Host "Employees Count: $($_.employees_count)" -ForegroundColor White
if ($_.head) {
Write-Host "Head: $($_.head.full_name)" -ForegroundColor White
} else {
Write-Host "Head: null" -ForegroundColor Gray
}
}
Write-Host "─────────────────────────────────" -ForegroundColor Cyan
Write-Host ""
Write-Host "Полный JSON первого отдела:" -ForegroundColor Yellow
$response.results[0] | ConvertTo-Json -Depth 3
} catch {
Write-Host "❌ Ошибка: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host ""
Write-Host "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")