getConversations method

  1. @override
Future<List<DOOConversation>> getConversations()
override

Gets all conversation of current DOO client instance

Implementation

@override
Future<List<DOOConversation>> getConversations() async {
  try {
    final createResponse = await _dio.get(
        "/public/api/v1/inboxes/${DOOClientApiInterceptor.INTERCEPTOR_INBOX_IDENTIFIER_PLACEHOLDER}/contacts/${DOOClientApiInterceptor.INTERCEPTOR_CONTACT_IDENTIFIER_PLACEHOLDER}/conversations");
    if ((createResponse.statusCode ?? 0).isBetween(199, 300)) {
      return (createResponse.data as List<dynamic>)
          .map(((json) => DOOConversation.fromJson(json)))
          .toList();
    } else {
      throw DOOClientException(
          createResponse.statusMessage ?? "unknown error",
          DOOClientExceptionType.GET_CONVERSATION_FAILED);
    }
  } on DioException catch (e) {
    throw DOOClientException(
        e.message!, DOOClientExceptionType.GET_CONVERSATION_FAILED);
  }
}