createNewConversation method
Creates a new conversation for inbox with inboxIdentifier
and contact with source id contactIdentifier
Implementation
@override
Future<ChatwootConversation> 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)) {
//creating contact successful continue with request
final newConversation =
ChatwootConversation.fromJson(createResponse.data);
return newConversation;
} else {
throw ChatwootClientException(
createResponse.statusMessage ?? "unknown error",
ChatwootClientExceptionType.CREATE_CONVERSATION_FAILED);
}
} on DioException catch (e) {
throw ChatwootClientException(
e.message ?? "", ChatwootClientExceptionType.CREATE_CONVERSATION_FAILED);
}
}