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? includeCount = true,
  9. String? filter,
  10. Set<String>? sort,
  11. Keyset? keyset,
  12. 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 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? 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');
  }

  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));
}