From c9ba9a80b1d77f47b69aecaa8ec69efce795a9b4 Mon Sep 17 00:00:00 2001 From: Mohit Tejani <60129002+mohitpubnub@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:06:48 +0530 Subject: [PATCH] feat: Support for `status` and `type` fields in AppContext APIs (#130) * feat: appContext apis: added support for `status` and `type` fields * added prameter descriptions * fix: dart analyze, removed dead code. * PubNub SDK v5.1.0 release. --------- Co-authored-by: Mohit Tejani Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> --- .pubnub.yml | 7 +- pubnub/CHANGELOG.md | 6 + pubnub/README.md | 2 +- pubnub/lib/src/core/core.dart | 2 +- pubnub/lib/src/crypto/encryption_mode.dart | 2 - pubnub/lib/src/dx/_endpoints/push.dart | 4 - .../lib/src/dx/channel/channel_history.dart | 2 - .../lib/src/dx/objects/channel_metadata.dart | 40 +++ pubnub/lib/src/dx/objects/objects.dart | 331 +++++++++++++++++- pubnub/lib/src/dx/objects/schema.dart | 32 +- pubnub/lib/src/dx/objects/uuid_metadata.dart | 40 +++ pubnub/lib/src/dx/pam/resource.dart | 2 - pubnub/pubspec.yaml | 2 +- 13 files changed, 446 insertions(+), 26 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index f550efec..04d0652d 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,5 +1,10 @@ --- changelog: + - date: 2024-12-18 + version: v5.1.0 + changes: + - type: feature + text: "Added support for `status` and `type` fields in AppContext APIs." - date: 2024-12-10 version: v5.0.0 changes: @@ -461,7 +466,7 @@ supported-platforms: platforms: - "Dart SDK >=2.6.0 <3.0.0" version: "PubNub Dart SDK" -version: "5.0.0" +version: "5.1.0" sdks: - full-name: PubNub Dart SDK diff --git a/pubnub/CHANGELOG.md b/pubnub/CHANGELOG.md index 4272697a..299e7206 100644 --- a/pubnub/CHANGELOG.md +++ b/pubnub/CHANGELOG.md @@ -1,3 +1,9 @@ +## v5.1.0 +December 18 2024 + +#### Added +- Added support for `status` and `type` fields in AppContext APIs. + ## v5.0.0 December 10 2024 diff --git a/pubnub/README.md b/pubnub/README.md index f5393d94..46bbcd7a 100644 --- a/pubnub/README.md +++ b/pubnub/README.md @@ -14,7 +14,7 @@ To add the package to your Dart or Flutter project, add `pubnub` as a dependency ```yaml dependencies: - pubnub: ^5.0.0 + pubnub: ^5.1.0 ``` After adding the dependency to `pubspec.yaml`, run the `dart pub get` command in the root directory of your project (the same that the `pubspec.yaml` is in). diff --git a/pubnub/lib/src/core/core.dart b/pubnub/lib/src/core/core.dart index 4bc11d56..09350333 100644 --- a/pubnub/lib/src/core/core.dart +++ b/pubnub/lib/src/core/core.dart @@ -21,7 +21,7 @@ class Core { /// Internal module responsible for supervising. SupervisorModule supervisor = SupervisorModule(); - static String version = '5.0.0'; + static String version = '5.1.0'; Core( {Keyset? defaultKeyset, diff --git a/pubnub/lib/src/crypto/encryption_mode.dart b/pubnub/lib/src/crypto/encryption_mode.dart index b620f2f8..351aa511 100644 --- a/pubnub/lib/src/crypto/encryption_mode.dart +++ b/pubnub/lib/src/crypto/encryption_mode.dart @@ -11,8 +11,6 @@ extension EncryptionModeExtension on EncryptionMode { return AESMode.cbc; case EncryptionMode.ECB: return AESMode.ecb; - default: - throw Exception('Unreachable state'); } } } diff --git a/pubnub/lib/src/dx/_endpoints/push.dart b/pubnub/lib/src/dx/_endpoints/push.dart index 417d9710..a8f4bcbb 100644 --- a/pubnub/lib/src/dx/_endpoints/push.dart +++ b/pubnub/lib/src/dx/_endpoints/push.dart @@ -23,8 +23,6 @@ extension EnvironmentExtension on Environment { return 'development'; case Environment.production: return 'production'; - default: - throw Exception('Invalid Gateway Type'); } } } @@ -43,8 +41,6 @@ extension PushGatewayExtension on PushGateway { return 'apns'; case PushGateway.apns2: return 'apns2'; - default: - throw Exception('Invalid Gateway Type'); } } } diff --git a/pubnub/lib/src/dx/channel/channel_history.dart b/pubnub/lib/src/dx/channel/channel_history.dart index 5314c397..1f1a31ca 100644 --- a/pubnub/lib/src/dx/channel/channel_history.dart +++ b/pubnub/lib/src/dx/channel/channel_history.dart @@ -19,8 +19,6 @@ extension ChannelHistoryOrderExtension on ChannelHistoryOrder { return descending; case ChannelHistoryOrder.ascending: return ascending; - default: - throw Exception('Unreachable state'); } } } diff --git a/pubnub/lib/src/dx/objects/channel_metadata.dart b/pubnub/lib/src/dx/objects/channel_metadata.dart index a3ac63db..a18d8c58 100644 --- a/pubnub/lib/src/dx/objects/channel_metadata.dart +++ b/pubnub/lib/src/dx/objects/channel_metadata.dart @@ -17,6 +17,18 @@ class ChannelMetadata { /// 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. /// @@ -41,6 +53,10 @@ class ChannelMetadata { bool? includeUUIDFields, bool? includeUUIDCustomFields, bool? includeCount, + bool includeUUIDStatus = false, + bool includeUUIDType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort}) => _objects.setChannelMembers(_id, channelMembersMetadata, @@ -50,6 +66,10 @@ class ChannelMetadata { includeCustomFields: includeCustomFields, includeUUIDFields: includeUUIDFields, includeUUIDCustomFields: includeUUIDCustomFields, + includeUUIDStatus: includeUUIDStatus, + includeUUIDType: includeUUIDType, + includeStatus: includeStatus, + includeType: includeType, includeCount: includeCount, filter: filter, sort: sort); @@ -61,6 +81,18 @@ class ChannelMetadata { /// 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. /// @@ -84,6 +116,10 @@ class ChannelMetadata { bool? includeUUIDFields, bool? includeUUIDCustomFields, bool? includeCount, + bool includeUUIDStatus = false, + bool includeUUIDType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort}) => _objects.removeChannelMembers(_id, uuids, @@ -94,6 +130,10 @@ class ChannelMetadata { includeCustomFields: includeCustomFields, includeUUIDFields: includeUUIDFields, includeUUIDCustomFields: includeUUIDCustomFields, + includeUUIDStatus: includeUUIDStatus, + includeUUIDType: includeUUIDType, + includeStatus: includeStatus, + includeType: includeType, includeCount: includeCount, filter: filter, sort: sort); diff --git a/pubnub/lib/src/dx/objects/objects.dart b/pubnub/lib/src/dx/objects/objects.dart index c408bf4f..ef5aeff2 100644 --- a/pubnub/lib/src/dx/objects/objects.dart +++ b/pubnub/lib/src/dx/objects/objects.dart @@ -29,6 +29,12 @@ class ObjectsDx { /// To include `custom` property fields in response, set [includeCustomFields] to `true` /// Omit this parameter if you don't want to retrieve additional metadata. /// + /// To omit `status` field from metadata, set [includeStatus] to `false` + /// Default is `true`. + /// + /// To omit `type` field from metadata, set [includeType] to `false` + /// Default is `true`. + /// /// You can limit number of returned user object using [limit] parameter /// Default is 100, which is also the maximum value. /// @@ -50,6 +56,8 @@ class ObjectsDx { String? start, String? end, bool includeCount = true, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -60,6 +68,12 @@ class ObjectsDx { if (includeCustomFields != null && includeCustomFields) { include.add('custom'); } + if (includeStatus) { + include.add('status'); + } + if (includeType) { + include.add('type'); + } var params = GetAllUuidMetadataParams(keyset, include: include, @@ -82,22 +96,37 @@ class ObjectsDx { /// To include `custom` property fields in response, set [includeCustomFields] to `true` /// Omit this parameter if you don't want to retrieve additional metadata. /// + /// To omit `status` field from metadata, set [includeStatus] to `false` + /// Default is `true`. + /// + /// To omit `type` field from metadata, set [includeType] to `false` + /// Default is `true`. + /// /// `uuid` is Unique identifier of an end-user. It may contain up to 92 UTF-8 byte sequences. /// Prohibited characters are ,, /, \, *, :, channel, non-printable ASCII control characters, and Unicode zero. /// * If `uuid` not provided then it picks `uuid` from `keyset` or PubNub instance's `uuid` /// * If no `uuid` is set in PubNub instance default keyset, `keyset` does not hold uuid /// and `uuid`not provided in argument then it throws InvariantException - Future getUUIDMetadata( - {String? uuid, - Keyset? keyset, - String? using, - bool? includeCustomFields}) async { + Future getUUIDMetadata({ + String? uuid, + Keyset? keyset, + String? using, + bool? includeCustomFields, + bool includeStatus = true, + bool includeType = true, + }) async { keyset ??= _core.keysets[using]; var include = {}; if (includeCustomFields != null && includeCustomFields) { include.add('custom'); } + if (includeStatus) { + include.add('status'); + } + if (includeType) { + include.add('type'); + } var params = GetUuidMetadataParams(keyset, uuid: uuid, include: include); return defaultFlow( @@ -118,6 +147,12 @@ class ObjectsDx { /// To include `custom` property fields in response, set [includeCustomFields] to `true` /// Omit this parameter if you don't want to retrieve additional metadata. /// + /// To omit `status` field from metadata, set [includeStatus] to `false` + /// Default is `true`. + /// + /// To omit `type` field from metadata, set [includeType] to `false` + /// Default is `true`. + /// /// `uuid` is Unique identifier of an end-user. It may contain up to 92 UTF-8 byte sequences. /// Prohibited characters are ,, /, \, *, :, channel, non-printable ASCII control characters, and Unicode zero. /// * If `uuid` parameter is provied then it sets metadata for given uuid. @@ -128,6 +163,8 @@ class ObjectsDx { UuidMetadataInput uuidMetadataInput, {String? uuid, bool? includeCustomFields, + bool includeStatus = true, + bool includeType = true, Keyset? keyset, String? using}) async { keyset ??= _core.keysets[using]; @@ -137,6 +174,12 @@ class ObjectsDx { if (includeCustomFields != null && includeCustomFields) { include.add('custom'); } + if (includeStatus) { + include.add('status'); + } + if (includeType) { + include.add('type'); + } var payload = await _core.parser.encode(uuidMetadataInput); var params = @@ -184,6 +227,12 @@ class ObjectsDx { /// To omit `totalCount` field from paginated list, set [includeCount] to `false` /// Default is `true`. /// + /// To omit `status` field from metadata, set [includeStatus] to `false` + /// Default is `true`. + /// + /// To omit `type` field from metadata, set [includeType] to `false` + /// Default is `true`. + /// /// [filter] is Expression used to filter the results. /// Only objects whose properties satisfy the given expression are returned. /// @@ -196,6 +245,8 @@ class ObjectsDx { String? end, bool? includeCustomFields, bool? includeCount = true, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -206,6 +257,12 @@ class ObjectsDx { if (includeCustomFields != null && includeCustomFields) { include.add('custom'); } + if (includeStatus) { + include.add('status'); + } + if (includeType) { + include.add('type'); + } var params = GetAllChannelMetadataParams(keyset, include: include, @@ -230,10 +287,22 @@ class ObjectsDx { /// To include `custom` property fields in response, set [includeCustomFields] to `true` /// Omit this parameter if you don't want to retrieve additional metadata. /// + /// To omit `status` field from metadata, set [includeStatus] to `false` + /// Default is `true`. + /// + /// To omit `type` field from metadata, set [includeType] to `false` + /// Default is `true`. + /// /// `channelId` is Channel identifier. Must not be empty, and may contain up to 92 UTF-8 byte sequences. /// Prohibited characters are ,, /, \, *, :, channel, non-printable ASCII control characters, and Unicode zero. - Future getChannelMetadata(String channelId, - {Keyset? keyset, String? using, bool? includeCustomFields}) async { + Future getChannelMetadata( + String channelId, { + Keyset? keyset, + String? using, + bool? includeCustomFields, + bool includeStatus = true, + bool includeType = true, + }) async { keyset ??= _core.keysets[using]; Ensure(channelId).isNotEmpty('channelIds'); @@ -241,6 +310,12 @@ class ObjectsDx { if (includeCustomFields != null && includeCustomFields) { include.add('custom'); } + if (includeStatus) { + include.add('status'); + } + if (includeType) { + include.add('type'); + } var params = GetChannelMetadataParams(keyset, channelId, include: include); @@ -261,11 +336,21 @@ class ObjectsDx { /// * 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 omit `status` field from metadata, set [includeStatus] to `false` + /// Default is `true`. + /// + /// To omit `type` field from metadata, set [includeType] to `false` + /// Default is `true`. + /// /// To include `custom` property fields in response, set [includeCustomFields] to `true` /// Omit this parameter if you don't want to retrieve additional metadata. Future setChannelMetadata( String channelId, ChannelMetadataInput channelMetadataInput, - {bool? includeCustomFields, Keyset? keyset, String? using}) async { + {bool? includeCustomFields, + bool includeStatus = true, + bool includeType = true, + Keyset? keyset, + String? using}) async { keyset ??= _core.keysets[using]; Ensure(channelId).isNotNull('channelId'); @@ -277,6 +362,12 @@ class ObjectsDx { if (includeCustomFields != null && includeCustomFields) { include.add('custom'); } + if (includeStatus) { + include.add('status'); + } + if (includeType) { + include.add('type'); + } var params = SetChannelMetadataParams(keyset, channelId, payload, include: include); @@ -330,6 +421,18 @@ class ObjectsDx { /// 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`. /// @@ -344,6 +447,10 @@ class ObjectsDx { bool? includeCustomFields, bool? includeChannelFields, bool? includeChannelCustomFields, + bool includeChannelStatus = false, + bool includeChannelType = false, + bool includeStatus = true, + bool includeType = true, bool? includeCount = true, String? filter, Set? sort, @@ -361,6 +468,18 @@ class ObjectsDx { 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, @@ -400,6 +519,18 @@ class ObjectsDx { /// 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. /// @@ -425,6 +556,10 @@ class ObjectsDx { bool? includeChannelFields, bool? includeChannelCustomFields, bool? includeCount = true, + bool includeChannelStatus = false, + bool includeChannelType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -449,6 +584,18 @@ class ObjectsDx { 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, @@ -487,6 +634,18 @@ class ObjectsDx { /// 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` /// + /// 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. /// @@ -512,6 +671,10 @@ class ObjectsDx { bool? includeChannelFields, bool? includeChannelCustomFields, bool? includeCount = true, + bool includeChannelStatus = false, + bool includeChannelType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -533,6 +696,18 @@ class ObjectsDx { 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, @@ -562,6 +737,18 @@ class ObjectsDx { /// 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` /// + /// 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`. + /// /// * 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 `uuid`not provided in argument then it throws InvariantException @@ -590,6 +777,10 @@ class ObjectsDx { bool? includeChannelFields, bool? includeChannelCustomFields, bool? includeCount = true, + bool includeChannelStatus = false, + bool includeChannelType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -614,6 +805,18 @@ class ObjectsDx { 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, @@ -640,6 +843,18 @@ class ObjectsDx { /// 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. /// @@ -663,6 +878,10 @@ class ObjectsDx { bool? includeUUIDFields, bool? includeUUIDCustomFields, bool? includeCount = true, + bool includeUUIDStatus = false, + bool includeUUIDType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -681,6 +900,18 @@ class ObjectsDx { 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 = GetChannelMembersParams(keyset, channelId, limit: limit, @@ -709,6 +940,18 @@ class ObjectsDx { /// 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. /// @@ -735,6 +978,10 @@ class ObjectsDx { bool? includeUUIDFields, bool? includeUUIDCustomFields, bool? includeCount = true, + bool includeUUIDStatus = false, + bool includeUUIDType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -761,6 +1008,18 @@ class ObjectsDx { 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, @@ -788,6 +1047,18 @@ class ObjectsDx { /// 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. /// @@ -812,6 +1083,10 @@ class ObjectsDx { bool? includeUUIDFields, bool? includeUUIDCustomFields, bool? includeCount = true, + bool includeUUIDStatus = false, + bool includeUUIDType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -835,6 +1110,18 @@ class ObjectsDx { 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, @@ -862,6 +1149,18 @@ class ObjectsDx { /// 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. /// @@ -886,6 +1185,10 @@ class ObjectsDx { bool? includeUUIDFields, bool? includeUUIDCustomFields, bool? includeCount = true, + bool includeUUIDStatus = false, + bool includeUUIDType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort, Keyset? keyset, @@ -911,6 +1214,18 @@ class ObjectsDx { 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, diff --git a/pubnub/lib/src/dx/objects/schema.dart b/pubnub/lib/src/dx/objects/schema.dart index b63fc105..ad201c80 100644 --- a/pubnub/lib/src/dx/objects/schema.dart +++ b/pubnub/lib/src/dx/objects/schema.dart @@ -7,9 +7,17 @@ class UuidMetadataInput { dynamic custom; String? externalId; String? profileUrl; + String? status; + String? type; UuidMetadataInput( - {this.name, this.email, this.externalId, this.profileUrl, this.custom}); + {this.name, + this.email, + this.externalId, + this.profileUrl, + this.custom, + this.status, + this.type}); Map toJson() => { 'name': name, @@ -17,6 +25,8 @@ class UuidMetadataInput { 'custom': custom, 'externalId': externalId, 'profileUrl': profileUrl, + 'status': status, + 'type': type, }; } @@ -27,13 +37,18 @@ class ChannelMetadataInput { String? name; String? description; dynamic custom; + String? status; + String? type; - ChannelMetadataInput({this.name, this.description, this.custom}); + ChannelMetadataInput( + {this.name, this.description, this.custom, this.status, this.type}); Map toJson() => { 'name': name, 'description': description, 'custom': custom, + 'status': status, + 'type': type, }; } @@ -43,12 +58,16 @@ class ChannelMetadataInput { class ChannelMemberMetadataInput { String uuid; Map? custom; + String? status; + String? type; - ChannelMemberMetadataInput(this.uuid, {this.custom}); + ChannelMemberMetadataInput(this.uuid, {this.custom, this.status, this.type}); Map toJson() => { 'uuid': {'id': uuid}, 'custom': custom, + 'status': status, + 'type': type, }; } @@ -58,12 +77,17 @@ class ChannelMemberMetadataInput { class MembershipMetadataInput { String channelId; Map? custom; + String? status; + String? type; - MembershipMetadataInput(this.channelId, {this.custom}); + MembershipMetadataInput(this.channelId, + {this.custom, this.status, this.type}); Map toJson() => { 'channel': {'id': channelId}, 'custom': custom, + 'status': status, + 'type': type, }; } diff --git a/pubnub/lib/src/dx/objects/uuid_metadata.dart b/pubnub/lib/src/dx/objects/uuid_metadata.dart index 27c9d4ed..f47b37f4 100644 --- a/pubnub/lib/src/dx/objects/uuid_metadata.dart +++ b/pubnub/lib/src/dx/objects/uuid_metadata.dart @@ -16,6 +16,18 @@ class UUIDMetadata { /// 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` /// + /// 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. /// @@ -40,6 +52,10 @@ class UUIDMetadata { bool? includeChannelFields, bool? includeChannelCustomFields, bool? includeCount, + bool includeChannelStatus = false, + bool includeChannelType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort}) => _objects.setMemberships(membershipMetadata, @@ -52,6 +68,10 @@ class UUIDMetadata { includeChannelFields: includeChannelFields, includeChannelCustomFields: includeChannelCustomFields, includeCount: includeCount, + includeChannelStatus: includeChannelStatus, + includeChannelType: includeChannelType, + includeStatus: includeStatus, + includeType: includeType, filter: filter, sort: sort); @@ -61,6 +81,18 @@ class UUIDMetadata { /// 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` /// + /// 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. /// @@ -84,6 +116,10 @@ class UUIDMetadata { bool? includeChannelFields, bool? includeChannelCustomFields, bool? includeCount, + bool includeChannelStatus = false, + bool includeChannelType = false, + bool includeStatus = true, + bool includeType = true, String? filter, Set? sort}) => _objects.getMemberships( @@ -95,6 +131,10 @@ class UUIDMetadata { includeChannelFields: includeChannelFields, includeChannelCustomFields: includeChannelCustomFields, includeCount: includeCount, + includeChannelStatus: includeChannelStatus, + includeChannelType: includeChannelType, + includeStatus: includeStatus, + includeType: includeType, filter: filter, sort: sort, keyset: _keyset); diff --git a/pubnub/lib/src/dx/pam/resource.dart b/pubnub/lib/src/dx/pam/resource.dart index 6151c869..18dc1ddd 100644 --- a/pubnub/lib/src/dx/pam/resource.dart +++ b/pubnub/lib/src/dx/pam/resource.dart @@ -17,8 +17,6 @@ extension ResourceTypeExtension on ResourceType { return 'channels'; case ResourceType.channelGroup: return 'groups'; - default: - throw Exception('invalid state'); } } } diff --git a/pubnub/pubspec.yaml b/pubnub/pubspec.yaml index 0bd785bb..09e6f9dd 100644 --- a/pubnub/pubspec.yaml +++ b/pubnub/pubspec.yaml @@ -1,6 +1,6 @@ name: pubnub description: PubNub SDK v5 for Dart lang (with Flutter support) that allows you to create real-time applications -version: 5.0.0 +version: 5.1.0 homepage: https://www.pubnub.com/docs/sdks/dart environment: