getContact method

  1. @override
Future<ChatwootContact> getContact()
override

Gets contact of current chatwoot client instance

Implementation

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