getHelpSupportArticles method
Implementation
Future<List<HelpArticle>> getHelpSupportArticles(int? categoryId) async {
//
final categoriesUrl = BytedeskUtils.getHostUri('/visitor/api/category/articles',
{'categoryId': categoryId.toString(), 'client': client});
debugPrint("getHelpSupportArticles Url $categoriesUrl");
final initResponse = await httpClient.get(categoriesUrl);
//
//解决json解析中的乱码问题
Utf8Decoder utf8decoder = const Utf8Decoder(); // fix 中文乱码
//将string类型数据 转换为json类型的数据
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
debugPrint("responseJson $responseJson");
//
List<HelpArticle> articles = (responseJson['data'] as List<dynamic>)
.map((item) => HelpArticle.fromJson(item))
.toList();
//
return articles;
}