sendMessage method
Sends message to solevato inbox
Implementation
Future<void> sendMessage(SolevatoNewMessageRequest request) async {
SolevatoConversation? conversation =
localStorage.conversationDao.getConversation();
SolevatoContact? contact = localStorage.contactDao.getContact();
if (conversation == null) {
conversation = await clientService.createNewConversation(
inboxIdentifier,
contact?.contactIdentifier ?? '',
);
await localStorage.conversationDao.saveConversation(conversation);
}
try {
final createdMessage = await clientService.createMessage(request);
await localStorage.messagesDao.saveMessage(createdMessage);
callbacks.onMessageSent?.call(createdMessage, request.echoId);
} on SolevatoClientException catch (e) {
callbacks.onError?.call(
SolevatoClientException(e.cause, e.type, data: request.echoId));
}
}