updateMessage method

  1. @override
Future<ChatwootMessage> updateMessage(
  1. String messageIdentifier,
  2. dynamic update
)
override

Update message with id messageIdentifier with contents of update

Implementation

@override
Future<ChatwootMessage> updateMessage(
    String messageIdentifier, update) async {
  try {
    final updateResponse = await _dio.patch(
        "/public/api/v1/inboxes/${ChatwootClientApiInterceptor.INTERCEPTOR_INBOX_IDENTIFIER_PLACEHOLDER}/contacts/${ChatwootClientApiInterceptor.INTERCEPTOR_CONTACT_IDENTIFIER_PLACEHOLDER}/conversations/${ChatwootClientApiInterceptor.INTERCEPTOR_CONVERSATION_IDENTIFIER_PLACEHOLDER}/messages/$messageIdentifier",
        data: update);
    if ((updateResponse.statusCode ?? 0).isBetween(199, 300)) {
      return ChatwootMessage.fromJson(updateResponse.data);
    } else {
      throw ChatwootClientException(
          updateResponse.statusMessage ?? "unknown error",
          ChatwootClientExceptionType.UPDATE_MESSAGE_FAILED);
    }
  } on DioException catch (e) {
    throw ChatwootClientException(
        e.message ?? "", ChatwootClientExceptionType.UPDATE_MESSAGE_FAILED);
  }
}