Solian/lib/providers/content/realm.dart

33 lines
893 B
Dart
Raw Normal View History

2024-05-25 16:11:00 +00:00
import 'package:get/get.dart';
import 'package:solian/providers/auth.dart';
class RealmProvider extends GetxController {
2024-05-29 14:42:11 +00:00
Future<Response> getRealm(String alias) async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = auth.configureClient(service: 'passport');
2024-05-29 14:42:11 +00:00
final resp = await client.get('/api/realms/$alias');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
return resp;
}
2024-05-25 16:11:00 +00:00
Future<Response> listAvailableRealm() async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = auth.configureClient(service: 'passport');
2024-05-25 16:11:00 +00:00
2024-05-28 14:13:23 +00:00
final resp = await client.get('/api/realms/me/available');
2024-05-25 16:11:00 +00:00
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
return resp;
}
}