updateContact method

  1. @override
Future<ChatwootContact> updateContact(
  1. dynamic update
)
override

Update current client instance's contact

Implementation

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