sendMessageRest method
Implementation
Future<JsonResult> sendMessageRest(String? jsonString) async {
//
var body = json.encode({"json": jsonString, "client": client});
//
final sendMessageUrl = BytedeskUtils.getHostUri('/visitor/api/v1/message/send');
final sendMessageResponse = await httpClient.post(sendMessageUrl,
headers: getHeadersForVisitor(), body: body);
//解决json解析中的乱码问题
Utf8Decoder utf8decoder = const Utf8Decoder(); // fix 中文乱码
//将string类型数据 转换为json类型的数据
final responseJson =
json.decode(utf8decoder.convert(sendMessageResponse.bodyBytes));
debugPrint("sendMessageRest responseJson $responseJson");
//
return JsonResult(
message: responseJson['message'],
code: responseJson['code'],
data: responseJson['data']);
}