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');
|
|
|
|
|
2024-06-22 14:39:32 +00:00
|
|
|
final client = auth.configureClient('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');
|
|
|
|
|
2024-06-22 14:39:32 +00:00
|
|
|
final client = auth.configureClient('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;
|
|
|
|
}
|
|
|
|
}
|