manageMemberships method
- List<
MembershipMetadataInput> setMetadata, - Set<
String> removeChannelIds, { - String? uuid,
- int? limit,
- String? start,
- String? end,
- bool? includeCustomFields,
- bool? includeChannelFields,
- bool? includeChannelCustomFields,
- bool? includeCount = true,
- bool includeChannelStatus = false,
- bool includeChannelType = false,
- bool includeStatus = true,
- bool includeType = true,
- String? filter,
- Set<
String> ? sort, - Keyset? keyset,
- String? using,
Sets channel membership metadata and/or deletes memberships metadata for the specified uuid.
setMetadata
is memberships metadata input to provide metadata details
It deletes uuid's membership from given removeChannelIds
channels
Returns the updated uuid's channel membership metadata, 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 picksuuid
from givenkeyset
or PubNub instance'suuid
-
If no
uuid
is set in PubNub instance default keyset,keyset
does not hold uuid anduuid
not provided in argument then it throws InvariantException -
You can change all of the membership object's properties, except its identifier.
-
Invalid property names are silently ignored and will not cause a request to fail.
-
If you set the "custom" property, you must completely replace it; partial updates are not supported.
-
The custom object can only contain scalar values.
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 channelmetadata, set includeChannelCustomFields
to true
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
.
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> manageMemberships(
List<MembershipMetadataInput> setMetadata, Set<String> removeChannelIds,
{String? uuid,
int? limit,
String? start,
String? end,
bool? includeCustomFields,
bool? includeChannelFields,
bool? includeChannelCustomFields,
bool? includeCount = true,
bool includeChannelStatus = false,
bool includeChannelType = false,
bool includeStatus = true,
bool includeType = true,
String? filter,
Set<String>? sort,
Keyset? keyset,
String? using}) async {
keyset ??= _core.keysets[using];
var manageMembershipMetadata = <String, dynamic>{};
manageMembershipMetadata['set'] = setMetadata;
var deleteInputs = <ChannelIdInfo>[];
removeChannelIds.forEach((id) => deleteInputs.add(ChannelIdInfo(id)));
manageMembershipMetadata['delete'] = deleteInputs;
var payload = await _core.parser.encode(manageMembershipMetadata);
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 = ManageMembershipsParams(keyset, payload,
uuid: uuid,
limit: limit,
start: start,
end: end,
include: include,
includeCount: includeCount,
filter: filter,
sort: sort);
return defaultFlow<ManageMembershipsParams, MembershipsResult>(
keyset: keyset,
core: _core,
params: params,
serialize: (object, [_]) => MembershipsResult.fromJson(object));
}