Skip to content

Commit

Permalink
CLEN-1924: pagination params listChannels api for push devices (#366)
Browse files Browse the repository at this point in the history
* added `start` and `count` to listChannels api for push devices

* PubNub SDK v7.6.2 release.

* Update .pubnub.yml

Co-authored-by: Karolina Rymer <karolina.zydek@pubnub.com>

---------

Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com>
Co-authored-by: Karolina Rymer <karolina.zydek@pubnub.com>
  • Loading branch information
3 people authored Mar 28, 2024
1 parent a551a84 commit 8d9d8c2
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 13 deletions.
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2024-03-28
version: v7.6.2
changes:
- type: feature
text: "Added support for pagination params for listChannels API of push notification devices."
- date: 2024-02-26
version: v7.6.1
changes:
Expand Down Expand Up @@ -948,7 +953,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '7.6.1'
version: '7.6.2'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -964,7 +969,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v7.6.1.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v7.6.2.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1635,7 +1640,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v7.6.1/pubnub.7.6.1.js
location: https://github.com/pubnub/javascript/releases/download/v7.6.2/pubnub.7.6.2.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v7.6.2
March 28 2024

#### Added
- Added support for pagination params for listChannels api of push notification devices.

## v7.6.1
February 26 2024

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.6.1.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.6.1.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.6.2.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.7.6.2.min.js
2. Configure your keys:
Expand Down
8 changes: 6 additions & 2 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@
return this;
};
default_1.prototype.getVersion = function () {
return '7.6.1';
return '7.6.2';
};
default_1.prototype._setRetryConfiguration = function (configuration) {
if (configuration.minimumdelay < 2) {
Expand Down Expand Up @@ -3893,12 +3893,16 @@
return true;
}
function prepareParams$l(modules, incomingParams) {
var pushGateway = incomingParams.pushGateway, _a = incomingParams.environment, environment = _a === void 0 ? 'development' : _a, topic = incomingParams.topic;
var pushGateway = incomingParams.pushGateway, _a = incomingParams.environment, environment = _a === void 0 ? 'development' : _a, topic = incomingParams.topic, start = incomingParams.start, count = incomingParams.count;
var parameters = { type: pushGateway };
if (pushGateway === 'apns2') {
parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic });
delete parameters.type;
}
if (start)
parameters.start = start;
if (count && count > 0)
parameters.count = count;
return parameters;
}
function handleResponse$l(modules, serverResponse) {
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/components/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ var default_1 = /** @class */ (function () {
return this;
};
default_1.prototype.getVersion = function () {
return '7.6.1';
return '7.6.2';
};
default_1.prototype._setRetryConfiguration = function (configuration) {
if (configuration.minimumdelay < 2) {
Expand Down
6 changes: 5 additions & 1 deletion lib/core/endpoints/push/list_push_channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ function isAuthSupported() {
}
exports.isAuthSupported = isAuthSupported;
function prepareParams(modules, incomingParams) {
var pushGateway = incomingParams.pushGateway, _a = incomingParams.environment, environment = _a === void 0 ? 'development' : _a, topic = incomingParams.topic;
var pushGateway = incomingParams.pushGateway, _a = incomingParams.environment, environment = _a === void 0 ? 'development' : _a, topic = incomingParams.topic, start = incomingParams.start, count = incomingParams.count;
var parameters = { type: pushGateway };
if (pushGateway === 'apns2') {
parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic });
delete parameters.type;
}
if (start)
parameters.start = start;
if (count && count > 0)
parameters.count = count;
return parameters;
}
exports.prepareParams = prepareParams;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pubnub",
"version": "7.6.1",
"version": "7.6.2",
"author": "PubNub <support@pubnub.com>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export default class {
}

getVersion() {
return '7.6.1';
return '7.6.2';
}

_setRetryConfiguration(configuration) {
Expand Down
5 changes: 4 additions & 1 deletion src/core/endpoints/push/list_push_channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ export function isAuthSupported() {
}

export function prepareParams(modules, incomingParams) {
const { pushGateway, environment = 'development', topic } = incomingParams;
const { pushGateway, environment = 'development', topic, start, count } = incomingParams;
let parameters = { type: pushGateway };

if (pushGateway === 'apns2') {
parameters = { ...parameters, environment, topic };
delete parameters.type;
}

if (start) parameters.start = start;
if (count && count > 0) parameters.count = count;

return parameters;
}

Expand Down
55 changes: 55 additions & 0 deletions test/integration/endpoints/push.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,61 @@ describe('push endpoints', () => {
);
});

it('supports channel listing with start and count params', async () => {
const scope = utils
.createNock()
.get('/v1/push/sub-key/mySubKey/devices/coolDevice')
.query({
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
type: 'apns',
uuid: 'myUUID',
start: 'ch1',
count: 10,
})
.reply(200, '["ch1", "ch2", "ch3"]');

var res = await pubnub.push.listChannels(
{ device: 'coolDevice', pushGateway: 'apns', start: 'ch1', count: 10 },
(status, response) => {
assert.equal(status.error, false);
assert.deepEqual(response.channels, ['ch1', 'ch2', 'ch3']);
assert.equal(scope.isDone(), true);
done();
},
);
});

it('supports channel listing with(APNS2) start and count params', async () => {
const scope = utils
.createNock()
.get('/v2/push/sub-key/mySubKey/devices-apns2/coolDevice')
.query({
pnsdk: `PubNub-JS-Nodejs/${pubnub.getVersion()}`,
environment: 'production',
topic: 'com.test.apns',
uuid: 'myUUID',
start: 'ch1',
count: 10,
})
.reply(200, '["ch1", "ch2", "ch3"]');
pubnub.push.listChannels(
{
device: 'coolDevice',
pushGateway: 'apns2',
environment: 'production',
topic: 'com.test.apns',
start: 'ch1',
count: 10,
},
(status, response) => {
assert.equal(status.error, false);
assert.deepEqual(response.channels, ['ch1', 'ch2', 'ch3']);
assert.equal(scope.isDone(), true);
done();
},
);
});

it('should add push disable for channels API telemetry information', (done) => {
let scope = utils.createNock().get('/v1/push/sub-key/mySubKey/devices/niceDevice').query(true);
const delays = [100, 200, 300, 400];
Expand Down

0 comments on commit 8d9d8c2

Please sign in to comment.