20 lines
682 B
Dart
20 lines
682 B
Dart
import 'package:sweet_chat_app/models/chat_message.dart';
|
|
import 'package:sweet_chat_app/models/chat_session.dart';
|
|
import 'package:sweet_chat_app/services/dio_service.dart';
|
|
|
|
Future<List<ChatSession>> getChatSessionApi(int userId) async {
|
|
final res = await dioService.get('/message/session/$userId');
|
|
|
|
if (res.data == null) return [];
|
|
|
|
return (res.data as List).map((e) => ChatSession.fromJson(e)).toList();
|
|
}
|
|
|
|
Future<List<ChatMessage>> getChatMessageApi(int conversationId) async {
|
|
final res = await dioService.get('/message/session/$conversationId/detail');
|
|
|
|
if (res.data == null) return [];
|
|
|
|
return (res.data as List).map((e) => ChatMessage.fromJson(e)).toList();
|
|
}
|