createNewConversation method
Creates a new conversation for inbox with inboxIdentifier
and contact with source id contactIdentifier
Implementation
@override
Future<SquadweConversation> 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 =
SquadweConversation.fromJson(createResponse.data);
return newConversation;
} else {
throw SquadweClientException(
createResponse.statusMessage ?? "unknown error",
SquadweClientExceptionType.CREATE_CONVERSATION_FAILED);
}
} on DioError catch (e) {
throw SquadweClientException(
e.message, SquadweClientExceptionType.CREATE_CONVERSATION_FAILED);
}
}