getAppConfig method
Fetches and caches /app-config.
Implementation
Future<AppConfig> getAppConfig() async {
const label = 'GET /app-config';
final _Response response;
try {
response = await _send('GET', Uri.parse('${config.baseURL}/app-config'));
} on Object catch (error) {
throw ApiError('$label failed: $error');
}
if (response.statusCode >= 400) {
throw ApiError('$label failed: HTTP ${response.statusCode}');
}
final json = _decodeObject(response.body, label);
final capabilities = json['capabilities'];
final parsed = AppConfig(
publicAppUrl: (json['publicAppUrl'] as String?)?.trim().isNotEmpty == true
? json['publicAppUrl'] as String
: config.baseURL,
version: (json['version'] as String?) ?? '',
capabilities: capabilities is Map<String, Object?>
? AppCapabilities.fromJson(capabilities)
: null,
);
_appConfig = parsed;
return parsed;
}