@davoodmehraban89 / LifeMate / commits / 44013aa
Fork 0

LifeMate — Personal, Family & Learning Companion

feat: expose family member and guardian API operations

davoodmehraban89 committed Oct 5, 2026 at 07:59 UTC 44013aac21badfd9c1d6932c731bda629b16a1dd
1 file changed +36
apps/lifemate/lib/api.dart
+36
@@ -23,6 +23,7 @@ abstract class IdentityApi {
23 String? themePreference,
24 });
25 Future<List<Map<String, dynamic>>> listFamilies();
26 + Future<List<Map<String, dynamic>>> listFamilyMembers(String familyId);
27 Future<Map<String, dynamic>> createFamily(String name, {String? role});
28 Future<void> inviteMember({
29 required String familyId,
@@ -31,6 +32,11 @@ abstract class IdentityApi {
32 String? themePreference,
33 });
34 Future<void> acceptInvitation(String token);
35 + Future<void> setGuardian({
36 + required String familyId,
37 + required String guardianUserId,
38 + required String minorUserId,
39 + });
40 }
41
42 class ApiException implements Exception {
@@ -192,6 +198,19 @@ class HttpIdentityApi implements IdentityApi {
198 .toList();
199 }
200
201 + @override
202 + Future<List<Map<String, dynamic>>> listFamilyMembers(String familyId) async {
203 + final result = await _json(
204 + 'GET',
205 + '/v1/families/$familyId/members',
206 + auth: true,
207 + );
208 + final members = (result['members'] as List<dynamic>? ?? const []);
209 + return members
210 + .map((item) => Map<String, dynamic>.from(item as Map))
211 + .toList();
212 + }
213 +
214 @override
215 Future<Map<String, dynamic>> createFamily(
216 String name, {
@@ -230,4 +249,21 @@ class HttpIdentityApi implements IdentityApi {
249 body: {'token': token},
250 );
251 }
252 +
253 + @override
254 + Future<void> setGuardian({
255 + required String familyId,
256 + required String guardianUserId,
257 + required String minorUserId,
258 + }) async {
259 + await _json(
260 + 'POST',
261 + '/v1/families/$familyId/guardians',
262 + auth: true,
263 + body: {
264 + 'guardianUserId': guardianUserId,
265 + 'minorUserId': minorUserId,
266 + },
267 + );
268 + }
269 }