getMessagesService function

Future<List<Message>?> getMessagesService({
  1. required String threadhash,
  2. required int limit,
})

Implementation

Future<List<Message>?> getMessagesService({
  required String threadhash,
  required int limit,
}) async {
  log('getMessagesService: threadhash= $threadhash');
  final path = '/v1/chat/conversationhash/$threadhash?fetchLimit=$limit';

  final result = await http.get(path: path);

  if (result == null) {
    return null;
  }

  if (result is List) {
    return result.map((e) => Message.fromJson(e)).toList();
  }

  return null;
}