Migrate HickLab3D dashboard and add production auto deployment
Deploy HickLab3D Dashboard / Deploy to production (push) Failing after 19s

This commit is contained in:
Hickmeister
2026-10-10 18:51:23 +01:00
parent 8410a50f26
commit 88dd00551f
974 changed files with 14609 additions and 162573 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
use RuntimeException;
use Throwable;
class Bambuddy
{
public function configured(): bool
{
return filled(config('services.bambuddy.url')) && filled(config('services.bambuddy.api_key'));
}
public function printers(): array
{
if (! $this->configured()) {
throw new RuntimeException('BamBuddy API key is not configured.');
}
$url = rtrim(config('services.bambuddy.url'), '/').'/api/v1/printers';
$printers = Http::withHeaders(['X-API-Key' => config('services.bambuddy.api_key')])
->acceptJson()->connectTimeout(3)->timeout(8)->get($url)->throw()->json() ?? [];
return collect($printers)->filter(fn ($printer) => is_array($printer) && isset($printer['id']))
->take(20)->map(function (array $printer): array {
try {
$status = Http::withHeaders(['X-API-Key' => config('services.bambuddy.api_key')])
->acceptJson()->connectTimeout(3)->timeout(5)
->get(rtrim(config('services.bambuddy.url'), '/').'/api/v1/printers/'.(int) $printer['id'].'/status')
->throw()->json() ?? [];
return $printer + ['live' => $status];
} catch (Throwable $exception) {
report($exception);
return $printer + ['live' => []];
}
})->values()->all();
}
}