forked from eatvio/eatvio_app
32 lines
883 B
Dart
32 lines
883 B
Dart
import 'package:eatvio_app/features/chat/models/chat_room_model.dart';
|
|
import 'package:eatvio_app/features/chat/models/websocket_info_model.dart';
|
|
import 'package:eatvio_app/features/chat/services/chat_service.dart';
|
|
|
|
class ChatRepository {
|
|
final ChatService chatService;
|
|
|
|
ChatRepository({
|
|
required this.chatService,
|
|
});
|
|
|
|
/// TODO use "dartz" package because need Either<Failure, Result> for error handling
|
|
Future<ChatRoomModel> getChatRoom(String chatId) async {
|
|
try {
|
|
return (await chatService.getChatRoomModel(chatId))['chatRoom']!;
|
|
} catch (e) {
|
|
print(e);
|
|
throw (e);
|
|
}
|
|
}
|
|
|
|
/// TODO use "dartz" package because need Either<Failure, Result> for error handling
|
|
Future<WebsocketInfoModel> getWebsocket() async {
|
|
try {
|
|
return (await chatService.getWebsocket());
|
|
} catch (e) {
|
|
print(e);
|
|
throw (e);
|
|
}
|
|
}
|
|
}
|