1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-24 22:09:21 +00:00
comunicmobile/lib/helpers/forez_groups_helper.dart

32 lines
1.0 KiB
Dart
Raw Permalink Normal View History

2021-04-23 16:46:35 +00:00
import 'package:comunic/helpers/groups_helper.dart';
2021-04-26 07:33:54 +00:00
import 'package:comunic/helpers/users_helper.dart';
import 'package:comunic/models/advanced_user_info.dart';
2021-04-23 16:46:35 +00:00
import 'package:comunic/models/api_request.dart';
import 'package:comunic/models/group.dart';
/// Forez groups helper
///
/// @author Pierre Hubert
class ForezGroupsHelper {
static Future<List<Group>> getForezGroups() async {
return (await APIRequest.withLogin("forez/get_groups").execWithThrow())
.getArray()!
2021-04-23 16:46:35 +00:00
.cast<Map<String, dynamic>>()
.map(GroupsHelper.getGroupFromAPI)
.toList();
}
2021-04-26 07:33:54 +00:00
/// Get advanced information about a Forez member
///
/// This methods throws an exception in case of failure
static Future<AdvancedUserInfo> getMemberInfo(int groupID, int userID) async {
final response = await (APIRequest.withLogin("forez/get_member_info")
2021-04-26 07:33:54 +00:00
.addInt("group", groupID)
.addInt("user", userID)
.execWithThrowGetObject());
2021-04-26 07:33:54 +00:00
return UsersHelper.apiToAdvancedUserInfo(response);
}
2021-04-23 16:46:35 +00:00
}