removeChannelMembers method

Future<ChannelMembersResult> removeChannelMembers(
  1. String channelId,
  2. Set<String> uuids, {
  3. int? limit,
  4. String? start,
  5. String? end,
  6. bool? includeCustomFields,
  7. bool? includeUUIDFields,
  8. bool? includeUUIDCustomFields,
  9. bool? includeCount = true,
  10. bool includeUUIDStatus = false,
  11. bool includeUUIDType = false,
  12. bool includeStatus = true,
  13. bool includeType = true,
  14. String? filter,
  15. Set<String>? sort,
  16. Keyset? keyset,
  17. String? using,
})

Removes channel members uuids from the specified channel channelId and returns remaining members paginated list optionally including the custom data objects for: the channel's perspective on their members set ("custom"), the channel's perspective of the member ("uuid"), and the uuid's custom data ("uuid.custom").

Provide uuids list of members for which member metadata need to be deleted

To include custom property fields of member in response, set includeCustomFields to true To include uuid metadata fields of channel's memebrs in response, set includeUUIDFields to true To include custom fields of channel member's uuidMetadata, set includeUUIDCustomFields to true

To omit status field from member metadata, set includeStatus to false Default is true.

To omit type field from member metadata, set includeType to false Default is true.

To get status field of UUID metadata, set includeUUIDStatus to true Default is false.

To omit type field of UUID metadata, set includeUUIDType to true Default is false.

Use limit to specify Number of objects to return in response. Default is 100, which is also the maximum value.

filter is a Expression used to filter the results. Only objects whose properties satisfy the given expression are returned.

Provide start and end for Previously-returned cursor bookmark for fetching the next/previous page.

To omit totalCount field from paginated list, set includeCount to false Default is true.

You can provide sort List of attributes to sort by. Append :asc or :desc to an attribute to specify sort direction. The default sort direction is ascending.

Implementation

Future<ChannelMembersResult> removeChannelMembers(
    String channelId, Set<String> uuids,
    {int? limit,
    String? start,
    String? end,
    bool? includeCustomFields,
    bool? includeUUIDFields,
    bool? includeUUIDCustomFields,
    bool? includeCount = true,
    bool includeUUIDStatus = false,
    bool includeUUIDType = false,
    bool includeStatus = true,
    bool includeType = true,
    String? filter,
    Set<String>? sort,
    Keyset? keyset,
    String? using}) async {
  keyset ??= _core.keysets[using];

  Ensure(channelId).isNotEmpty('channelId');

  var manageInput = <String, dynamic>{};
  var deleteInput = <UuIdInfo>[];
  uuids.forEach((id) => deleteInput.add(UuIdInfo(id)));
  manageInput['delete'] = deleteInput;

  var membersMetadata = await _core.parser.encode(manageInput);

  var include = <String>{};
  if (includeCustomFields != null && includeCustomFields) {
    include.add('custom');
  }
  if (includeUUIDFields != null && includeUUIDFields) {
    include.add('uuid');
  }
  if (includeUUIDCustomFields != null && includeUUIDCustomFields) {
    include.add('uuid.custom');
  }
  if (includeUUIDStatus) {
    include.add('uuid.status');
  }
  if (includeUUIDType) {
    include.add('uuid.type');
  }
  if (includeStatus) {
    include.add('status');
  }
  if (includeType) {
    include.add('type');
  }

  var params = ManageChannelMembersParams(keyset, channelId, membersMetadata,
      limit: limit,
      start: start,
      end: end,
      include: include,
      includeCount: includeCount,
      filter: filter,
      sort: sort);

  return defaultFlow<ManageChannelMembersParams, ChannelMembersResult>(
      keyset: keyset,
      core: _core,
      params: params,
      serialize: (object, [_]) => ChannelMembersResult.fromJson(object));
}