getAllMessages method
Gets all messages of current ruut client instance's conversation
Implementation
@override
Future<List<RuutMessage>> getAllMessages() async {
try {
final createResponse = await _dio.get(
"/public/api/v1/inboxes/${RuutChatClientApiInterceptor.INTERCEPTOR_INBOX_IDENTIFIER_PLACEHOLDER}/contacts/${RuutChatClientApiInterceptor.INTERCEPTOR_CONTACT_IDENTIFIER_PLACEHOLDER}/conversations/${RuutChatClientApiInterceptor.INTERCEPTOR_CONVERSATION_IDENTIFIER_PLACEHOLDER}/messages");
if ((createResponse.statusCode ?? 0).isBetween(199, 300)) {
printFullText(
"this is the response for get from server ${createResponse.data}");
return (createResponse.data as List<dynamic>)
.map(((json) => RuutMessage.fromJson(json)))
.toList();
} else {
throw RuutClientException(
createResponse.statusMessage ?? "unknown error",
RuutClientExceptionType.GET_MESSAGES_FAILED);
}
} on DioException catch (e) {
throw RuutClientException(
e.message ?? '', RuutClientExceptionType.GET_MESSAGES_FAILED);
}
}