From 9b2fbe8f226d80d6afd389fcc73cb15ef36bdbf5 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 27 Mar 2024 19:33:34 +0530 Subject: [PATCH 1/7] added support for pagination params for listPushChannels --- pubnub/lib/src/dx/_endpoints/push.dart | 8 ++++++-- pubnub/lib/src/dx/push/push.dart | 6 +++++- pubnub/test/unit/dx/push_test.dart | 27 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/pubnub/lib/src/dx/_endpoints/push.dart b/pubnub/lib/src/dx/_endpoints/push.dart index 07f8fc93..280d8c22 100644 --- a/pubnub/lib/src/dx/_endpoints/push.dart +++ b/pubnub/lib/src/dx/_endpoints/push.dart @@ -56,9 +56,11 @@ class ListPushChannelsParams extends Parameters { PushGateway pushGateway; Environment? environment; String? topic; + String? start; + int? count; ListPushChannelsParams(this.keyset, this.deviceId, this.pushGateway, - {this.topic, this.environment}); + {this.topic, this.environment, this.start, this.count}); @override Request toRequest() { @@ -74,7 +76,9 @@ class ListPushChannelsParams extends Parameters { var queryParameters = { if (keyset.authKey != null) 'auth': '${keyset.authKey}', 'uuid': '${keyset.uuid}', - 'type': pushGateway.value() + 'type': pushGateway.value(), + if (start != null && start!.isNotEmpty) 'start': start!, + if (count != null) 'count': '$count' }; if (pushGateway == PushGateway.apns2) { queryParameters['environment'] = diff --git a/pubnub/lib/src/dx/push/push.dart b/pubnub/lib/src/dx/push/push.dart index 938c9d1b..d5ae26c3 100644 --- a/pubnub/lib/src/dx/push/push.dart +++ b/pubnub/lib/src/dx/push/push.dart @@ -19,12 +19,16 @@ mixin PushNotificationDx on Core { /// If [gateway] is [PushGateway.apns2] then [topic] is mandatory to provide. /// [topic] is bundle id of the mobile application. /// [environment] denoting the environment of the mobile application for [PushGateway.apns2], it can be either: + /// [start] Starting channel for pagination. Use the last channel from the previous page request. + /// [count] Number of channels to return for pagination. Max of 1000 tokens at a time. Defaults to 500. /// * [Environment.development] (which is the default value). /// * [Environment.production]. Future listPushChannels( String deviceId, PushGateway gateway, {String? topic, Environment? environment, + String? start, + int? count, Keyset? keyset, String? using}) async { keyset ??= keysets[using]; @@ -33,7 +37,7 @@ mixin PushNotificationDx on Core { if (gateway == PushGateway.apns2) Ensure(topic).isNotNull('topic'); var params = ListPushChannelsParams(keyset, deviceId, gateway, - topic: topic, environment: environment); + topic: topic, environment: environment, start: start, count: count); return defaultFlow( keyset: keyset, core: this, diff --git a/pubnub/test/unit/dx/push_test.dart b/pubnub/test/unit/dx/push_test.dart index c090ac18..9a3ea8e5 100644 --- a/pubnub/test/unit/dx/push_test.dart +++ b/pubnub/test/unit/dx/push_test.dart @@ -189,6 +189,33 @@ void main() { #environment: null })); }); + + test('listPushChannels delegate supported arguments', () async { + fakePubnub.returnWhen( + #listPushChannels, + Future.value( + ListPushChannelsResult.fromJson(['ch1', 'ch2', 'ch3']))); + + await fakePubnub.listPushChannels('A332C23D', PushGateway.mpns, + start: 'ch2', count: 10); + + var invocation = fakePubnub.invocations[0]; + + expect(invocation.isMethod, equals(true)); + expect(invocation.memberName, equals(#listPushChannels)); + expect(invocation.positionalArguments, + equals(['A332C23D', PushGateway.mpns])); + expect( + invocation.namedArguments, + equals({ + #keyset: null, + #using: null, + #topic: null, + #environment: null, + #start: 'ch2', + #count: 10 + })); + }); }); }); } From d145f55e49e868ceb51f915c9d427c148054746a Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 27 Mar 2024 20:53:18 +0530 Subject: [PATCH 2/7] fix == oprator implementation for CipherKey --- pubnub/lib/src/core/crypto/cipher_key.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubnub/lib/src/core/crypto/cipher_key.dart b/pubnub/lib/src/core/crypto/cipher_key.dart index 7588c95b..f5b44b15 100644 --- a/pubnub/lib/src/core/crypto/cipher_key.dart +++ b/pubnub/lib/src/core/crypto/cipher_key.dart @@ -23,12 +23,12 @@ class CipherKey { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (other == null) { return false; } if (runtimeType == other.runtimeType) { - return utf8.decode(data) == utf8.decode(other!.data); + return utf8.decode(data) == utf8.decode((other as CipherKey).data); } return false; } From 4f599fc0184d362489f73151b0cb69be0925f20b Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 27 Mar 2024 20:55:36 +0530 Subject: [PATCH 3/7] fix equal operator. take -2 --- pubnub/lib/src/core/crypto/cipher_key.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/pubnub/lib/src/core/crypto/cipher_key.dart b/pubnub/lib/src/core/crypto/cipher_key.dart index f5b44b15..9c50ad8b 100644 --- a/pubnub/lib/src/core/crypto/cipher_key.dart +++ b/pubnub/lib/src/core/crypto/cipher_key.dart @@ -24,9 +24,6 @@ class CipherKey { @override bool operator ==(Object other) { - if (other == null) { - return false; - } if (runtimeType == other.runtimeType) { return utf8.decode(data) == utf8.decode((other as CipherKey).data); } From 1b475c1e94fa8f35703b18fd3b6d30958e54c531 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 27 Mar 2024 20:59:40 +0530 Subject: [PATCH 4/7] fix warnings for equal operator --- pubnub/lib/src/core/timetoken.dart | 2 +- pubnub/lib/src/core/user_id.dart | 2 +- pubnub/lib/src/core/uuid.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pubnub/lib/src/core/timetoken.dart b/pubnub/lib/src/core/timetoken.dart index 83745da6..ec68a73c 100644 --- a/pubnub/lib/src/core/timetoken.dart +++ b/pubnub/lib/src/core/timetoken.dart @@ -15,7 +15,7 @@ class Timetoken implements Result { /// Timetokens are compared based on their [value]. @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (other is Timetoken) { return value == other.value; } else { diff --git a/pubnub/lib/src/core/user_id.dart b/pubnub/lib/src/core/user_id.dart index 547f8950..2201d9b9 100644 --- a/pubnub/lib/src/core/user_id.dart +++ b/pubnub/lib/src/core/user_id.dart @@ -11,7 +11,7 @@ class UserId { String toString() => '$value'; @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (other is UserId) { return value == other.value; } diff --git a/pubnub/lib/src/core/uuid.dart b/pubnub/lib/src/core/uuid.dart index 2c51e15c..798bcfbe 100644 --- a/pubnub/lib/src/core/uuid.dart +++ b/pubnub/lib/src/core/uuid.dart @@ -11,7 +11,7 @@ class UUID { String toString() => '$value'; @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { if (other is UUID) { return value == other.value; } From 690b280ed7ab84ed1d6eb0454c2efc32639b069a Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 28 Mar 2024 15:37:56 +0530 Subject: [PATCH 5/7] formatting --- pubnub/lib/src/dx/_endpoints/push.dart | 11 +++++++++-- pubnub/lib/src/dx/push/push.dart | 11 +++++++++-- pubnub/test/unit/dx/push_test.dart | 16 ++++++++++------ pubnub/test/unit/dx/utils_test.dart | 4 +++- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/pubnub/lib/src/dx/_endpoints/push.dart b/pubnub/lib/src/dx/_endpoints/push.dart index 280d8c22..417d9710 100644 --- a/pubnub/lib/src/dx/_endpoints/push.dart +++ b/pubnub/lib/src/dx/_endpoints/push.dart @@ -59,8 +59,15 @@ class ListPushChannelsParams extends Parameters { String? start; int? count; - ListPushChannelsParams(this.keyset, this.deviceId, this.pushGateway, - {this.topic, this.environment, this.start, this.count}); + ListPushChannelsParams( + this.keyset, + this.deviceId, + this.pushGateway, { + this.topic, + this.environment, + this.start, + this.count, + }); @override Request toRequest() { diff --git a/pubnub/lib/src/dx/push/push.dart b/pubnub/lib/src/dx/push/push.dart index d5ae26c3..d381f04f 100644 --- a/pubnub/lib/src/dx/push/push.dart +++ b/pubnub/lib/src/dx/push/push.dart @@ -36,8 +36,15 @@ mixin PushNotificationDx on Core { Ensure(deviceId).isNotEmpty('deviceId'); if (gateway == PushGateway.apns2) Ensure(topic).isNotNull('topic'); - var params = ListPushChannelsParams(keyset, deviceId, gateway, - topic: topic, environment: environment, start: start, count: count); + var params = ListPushChannelsParams( + keyset, + deviceId, + gateway, + topic: topic, + environment: environment, + start: start, + count: count, + ); return defaultFlow( keyset: keyset, core: this, diff --git a/pubnub/test/unit/dx/push_test.dart b/pubnub/test/unit/dx/push_test.dart index 9a3ea8e5..124b6a5d 100644 --- a/pubnub/test/unit/dx/push_test.dart +++ b/pubnub/test/unit/dx/push_test.dart @@ -192,12 +192,16 @@ void main() { test('listPushChannels delegate supported arguments', () async { fakePubnub.returnWhen( - #listPushChannels, - Future.value( - ListPushChannelsResult.fromJson(['ch1', 'ch2', 'ch3']))); + #listPushChannels, + Future.value(ListPushChannelsResult.fromJson(['ch1', 'ch2', 'ch3'])), + ); - await fakePubnub.listPushChannels('A332C23D', PushGateway.mpns, - start: 'ch2', count: 10); + await fakePubnub.listPushChannels( + 'A332C23D', + PushGateway.mpns, + start: 'ch2', + count: 10, + ); var invocation = fakePubnub.invocations[0]; @@ -213,7 +217,7 @@ void main() { #topic: null, #environment: null, #start: 'ch2', - #count: 10 + #count: 10, })); }); }); diff --git a/pubnub/test/unit/dx/utils_test.dart b/pubnub/test/unit/dx/utils_test.dart index abd44265..f56c2af0 100644 --- a/pubnub/test/unit/dx/utils_test.dart +++ b/pubnub/test/unit/dx/utils_test.dart @@ -44,7 +44,9 @@ void main() { computeV2Signature(keyset, requestType, path, queryParams, body); expect(response, equals(expectedSign)); }); - test('computeV2Signature should return valid signature when special characters included', () { + test( + 'computeV2Signature should return valid signature when special characters included', + () { PubNub.version = '1.0.0'; Core.version = '1.0.0'; Time.mock(DateTime.fromMillisecondsSinceEpoch(1234567890000)); From f2bef4dbd5732bc1d86696abcdad13b76e2f9ab6 Mon Sep 17 00:00:00 2001 From: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Date: Thu, 28 Mar 2024 10:09:40 +0000 Subject: [PATCH 6/7] PubNub SDK v4.3.3 release. --- .pubnub.yml | 7 ++++++- pubnub/CHANGELOG.md | 6 ++++++ pubnub/README.md | 2 +- pubnub/lib/src/core/core.dart | 2 +- pubnub/pubspec.yaml | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index 59a84afa..f2d166b7 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,5 +1,10 @@ --- changelog: + - date: 2024-03-28 + version: v4.3.3 + changes: + - type: feature + text: "Added support for pagination params for listChannels api of push notification devices." - date: 2024-01-22 version: v4.3.2 changes: @@ -442,7 +447,7 @@ supported-platforms: platforms: - "Dart SDK >=2.6.0 <3.0.0" version: "PubNub Dart SDK" -version: "4.3.2" +version: "4.3.3" sdks: - full-name: PubNub Dart SDK diff --git a/pubnub/CHANGELOG.md b/pubnub/CHANGELOG.md index 0568a024..cfd6621e 100644 --- a/pubnub/CHANGELOG.md +++ b/pubnub/CHANGELOG.md @@ -1,3 +1,9 @@ +## v4.3.3 +March 28 2024 + +#### Added +- Added support for pagination params for listChannels api of push notification devices. + ## v4.3.2 January 22 2024 diff --git a/pubnub/README.md b/pubnub/README.md index 47d3a3e4..a05902d1 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: ^4.3.2 + pubnub: ^4.3.3 ``` 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 e2459e02..4e61b252 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 = '4.3.2'; + static String version = '4.3.3'; Core( {Keyset? defaultKeyset, diff --git a/pubnub/pubspec.yaml b/pubnub/pubspec.yaml index bb48377b..7f7b44a7 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: 4.3.2 +version: 4.3.3 homepage: https://www.pubnub.com/docs/sdks/dart environment: From 25a3867ac599c1f91fad268b3d2d5852353bdaa9 Mon Sep 17 00:00:00 2001 From: Mohit Tejani <60129002+mohitpubnub@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:44:13 +0530 Subject: [PATCH 7/7] Update .pubnub.yml Co-authored-by: Karolina Rymer --- .pubnub.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pubnub.yml b/.pubnub.yml index f2d166b7..45cfc832 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -4,7 +4,7 @@ changelog: version: v4.3.3 changes: - type: feature - text: "Added support for pagination params for listChannels api of push notification devices." + text: "Added support for pagination params for listChannels API of push notification devices." - date: 2024-01-22 version: v4.3.2 changes: