getContact method

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

Gets contact of current ruut client instance

Implementation

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