createMessage method
Sends message to ruut inbox
Implementation
@override
Future<RuutMessage> createMessage(
RuutNewMessageRequest request) async {
try {
final createResponse = await _dio.post(
"/public/api/v1/inboxes/${RuutChatClientApiInterceptor.INTERCEPTOR_INBOX_IDENTIFIER_PLACEHOLDER}/contacts/${RuutChatClientApiInterceptor.INTERCEPTOR_CONTACT_IDENTIFIER_PLACEHOLDER}/conversations/${RuutChatClientApiInterceptor.INTERCEPTOR_CONVERSATION_IDENTIFIER_PLACEHOLDER}/messages",
data: request.toJson());
if ((createResponse.statusCode ?? 0).isBetween(199, 300)) {
print("this is the response for server ${createResponse.data}");
return RuutMessage.fromJson(createResponse.data);
} else {
throw RuutClientException(
createResponse.statusMessage ?? "unknown error",
RuutClientExceptionType.SEND_MESSAGE_FAILED);
}
} on DioException catch (e) {
throw RuutClientException(
e.message ?? '', RuutClientExceptionType.SEND_MESSAGE_FAILED);
}
}