deleteMessageMetaArrayKeys method

Future<BaseMessage> deleteMessageMetaArrayKeys(
  1. BaseMessage message,
  2. List<String> keys
)

Deletes keys from MessageMetaArray given message.

Implementation

Future<BaseMessage> deleteMessageMetaArrayKeys(
  BaseMessage message,
  List<String> keys,
) async {
  if (message.channelUrl != channelUrl) {
    throw InvalidParameterError();
  }

  if (keys.isEmpty) {
    throw InvalidParameterError();
  }

  final metaArrays =
      keys.map((e) => MessageMetaArray(key: e, value: [])).toList();
  final cmd = Command.buildUpdateMessageMetaArray(
      message, metaArrays, MetaArrayUpdateMode.remove, false);

  try {
    var result = await _sdk.cmdManager.sendCommand(cmd);
    if (result != null) {
      return BaseMessage.msgFromJson(result.payload, type: result.cmd)!;
    } else {
      throw WebSocketError();
    }
  } catch (e) {
    rethrow;
  }
}