client->get($request, '/users/me/bonuses', [], retry: true); if ($res->successful()) { $body = $res->json() ?: []; $items = $body['data'] ?? $body['bonuses'] ?? $body; $out = []; foreach ((array) $items as $b) { if (!is_array($b)) continue; $out[] = [ 'id' => $b['id'] ?? null, 'amount' => isset($b['amount']) ? (float) $b['amount'] : 0.0, 'wager_required' => isset($b['wager_required']) ? (float) $b['wager_required'] : 0.0, 'wager_progress' => isset($b['wager_progress']) ? (float) $b['wager_progress'] : 0.0, 'expires_at' => $b['expires_at'] ?? null, 'is_active' => (bool) ($b['is_active'] ?? false), 'completed_at' => $b['completed_at'] ?? null, 'promo' => isset($b['promo']) && is_array($b['promo']) ? [ 'code' => $b['promo']['code'] ?? null, 'wager_multiplier' => isset($b['promo']['wager_multiplier']) ? (int) $b['promo']['wager_multiplier'] : null, ] : null, ]; } return response()->json(['data' => $out], 200); } if ($res->clientError()) return $this->mapClientError($res); if ($res->serverError()) return $this->mapServiceUnavailable($res); return $this->mapBadGateway(); } catch (\Throwable $e) { return $this->mapBadGateway('API server not reachable'); } } }