createNewConversation method
Creates a new conversation for inbox with inboxIdentifier
and contact with source id contactIdentifier
Implementation
@override
Future<RuutConversation> createNewConversation(
String inboxIdentifier, String contactIdentifier) async {
try {
final createResponse = await dio.post(
"/public/api/v1/inboxes/$inboxIdentifier/contacts/$contactIdentifier/conversations");
if ((createResponse.statusCode ?? 0).isBetween(199, 300)) {
printFullText(
"this is the create response data ==> ${createResponse.data}");
//creating contact successful continue with request
final newConversation =
RuutConversation.fromJson(createResponse.data);
return newConversation;
} else {
throw RuutClientException(
createResponse.statusMessage ?? "unknown error",
RuutClientExceptionType.CREATE_CONVERSATION_FAILED);
}
} on DioException catch (e) {
throw RuutClientException(
e.message ?? '', RuutClientExceptionType.CREATE_CONVERSATION_FAILED);
}
}