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