queryAnswer method

Future<RequestAnswerResult> queryAnswer(
  1. String? tid,
  2. String? aid
)

Implementation

Future<RequestAnswerResult> queryAnswer(String? tid, String? aid) async {
  //
  final queryAnswerUrl = BytedeskUtils.getHostUri(
      '/api/answer/query', {'tid': tid, 'aid': aid, 'client': client});
  debugPrint("query Url $queryAnswerUrl");
  final initResponse =
      await httpClient.get(queryAnswerUrl, headers: getHeaders());
  //
  //解决json解析中的乱码问题
  Utf8Decoder utf8decoder = const Utf8Decoder(); // fix 中文乱码
  //将string类型数据 转换为json类型的数据
  final responseJson =
      json.decode(utf8decoder.convert(initResponse.bodyBytes));
  // 判断token是否过期
  if (responseJson.toString().contains('invalid_token')) {
    bytedeskEventBus.fire(InvalidTokenEventBus());
  }
  //
  return RequestAnswerResult.fromJson(responseJson);
}