getMemberships method

Future<MembershipsResult> getMemberships({
  1. String? uuid,
  2. int? limit,
  3. String? start,
  4. String? end,
  5. bool? includeCustomFields,
  6. bool? includeChannelFields,
  7. bool? includeChannelCustomFields,
  8. bool includeChannelStatus = false,
  9. bool includeChannelType = false,
  10. bool includeStatus = true,
  11. bool includeType = true,
  12. bool? includeCount = true,
  13. String? filter,
  14. Set<String>? sort,
  15. Keyset? keyset,
  16. String? using,
})

Returns the specified uuid channel memberships, optionally including the custom data objects for: the uuid's perspective on their membership set ("custom"), the uuid's perspective on the channel ("channel"), and the channel's custom data ("channel.custom").

  • If uuid not provided then it picks uuid from given keyset or PubNub instance's uuid
  • If no uuid is set in PubNub instance default keyset, keyset does not hold uuid and uuidnot provided in argument then it throws InvariantException

To include custom property fields of membership in response, set includeCustomFields to true To include channel metadata fields of uuid's membership in response, set includeChannelFields to true To include custom fields of membership's channel metadata, set includeChannelCustomFields to true

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 status field from membership metadata, set includeStatus to false Default is true.

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

To get status field of channel metadata, set includeChannelStatus to true Default is false.

To omit type field of channel metadata, set includeChannelType to true Default is false.

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<MembershipsResult> getMemberships(
    {String? uuid,
    int? limit,
    String? start,
    String? end,
    bool? includeCustomFields,
    bool? includeChannelFields,
    bool? includeChannelCustomFields,
    bool includeChannelStatus = false,
    bool includeChannelType = false,
    bool includeStatus = true,
    bool includeType = true,
    bool? includeCount = true,
    String? filter,
    Set<String>? sort,
    Keyset? keyset,
    String? using}) async {
  keyset ??= _core.keysets[using];

  var include = <String>{};
  if (includeCustomFields != null && includeCustomFields) {
    include.add('custom');
  }
  if (includeChannelFields != null && includeChannelFields) {
    include.add('channel');
  }
  if (includeChannelCustomFields != null && includeChannelCustomFields) {
    include.add('channel.custom');
  }
  if (includeChannelStatus) {
    include.add('channel.status');
  }
  if (includeChannelType) {
    include.add('channel.type');
  }
  if (includeStatus) {
    include.add('status');
  }
  if (includeType) {
    include.add('type');
  }

  var params = GetMembershipsMetadataParams(keyset,
      uuid: uuid,
      limit: limit,
      start: start,
      end: end,
      include: include,
      includeCount: includeCount,
      filter: filter,
      sort: sort);

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