removeMessage method

Future<bool> removeMessage({
  1. required String id,
})

Implementation

Future<bool> removeMessage({required String id}) async {
  if (_sdkInfo == null) throw _clientError(LiveTalkErrorCodes.emptyInfo);

  final request = http.Request(
    'POST',
    Uri.parse('$_base${LiveTalkEndpoints.removeMessage}'),
  )
    ..headers.addAll({
      'Content-Type': 'application/json',
      'Authorization': 'Bearer ${_sdkInfo!["access_token"]}',
    })
    ..body = json.encode({
      'room_id':    _sdkInfo!['room_id'] ?? '',
      'message_id': id,
    });

  final streamed = await request.send();
  if (streamed.statusCode != 200) {
    throw _httpError(streamed.statusCode, streamed.reasonPhrase);
  }

  final data     = await streamed.stream.bytesToString();
  final jsonData = json.decode(data) as Map<String, dynamic>;
  if (jsonData['status_code'] == -9999) throw _apiBodyError(jsonData);

  return true;
}