diff --git a/packages/restapi/src/lib/channels/getSubscribers.ts b/packages/restapi/src/lib/channels/getSubscribers.ts index 74884f686..7ce083061 100644 --- a/packages/restapi/src/lib/channels/getSubscribers.ts +++ b/packages/restapi/src/lib/channels/getSubscribers.ts @@ -19,6 +19,7 @@ export type GetChannelSubscribersOptionsType = { page?: number, limit?: number, category?: number, + setting?: boolean, env?: ENV } @@ -29,7 +30,8 @@ export const getSubscribers = async ( channel, page = 1, limit = 10, - category, + category = null, + setting = false, env = Constants.ENV.PROD, } = options || {}; @@ -51,7 +53,7 @@ export const getSubscribers = async ( } const _channel = await getCAIPAddress(env, channel, 'Channel'); const API_BASE_URL = getAPIBaseUrls(env); - let apiEndpoint = `${API_BASE_URL}/v1/channels/${_channel}/subscribers?page=${page}&limit=${limit}`; + let apiEndpoint = `${API_BASE_URL}/v1/channels/${_channel}/subscribers?page=${page}&limit=${limit}&setting=${setting}`; if(category){ apiEndpoint = apiEndpoint+`&category=${category}` } diff --git a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts index e7956414e..f8d9febd8 100644 --- a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts +++ b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts @@ -11,7 +11,8 @@ export type ChannelInfoOptions = { channel?: string; page?: number; limit?: number; - category?: number + category?: number; + setting?: boolean; }; export type SubscribeUnsubscribeOptions = { diff --git a/packages/restapi/src/lib/pushNotification/channel.ts b/packages/restapi/src/lib/pushNotification/channel.ts index 9d01033b9..d77a48f59 100644 --- a/packages/restapi/src/lib/pushNotification/channel.ts +++ b/packages/restapi/src/lib/pushNotification/channel.ts @@ -99,6 +99,7 @@ export class Channel extends PushNotificationBaseClass { env: this.env, page: options.page, limit: options.limit ?? 10, + setting: options.setting?? false, category: options.category }); } else { diff --git a/packages/restapi/tests/lib/notification/channel.test.ts b/packages/restapi/tests/lib/notification/channel.test.ts index f52fbf0bd..604b778ee 100644 --- a/packages/restapi/tests/lib/notification/channel.test.ts +++ b/packages/restapi/tests/lib/notification/channel.test.ts @@ -126,8 +126,30 @@ describe('PushAPI.channel functionality', () => { expect(res).not.null; }); - it('Without signer and account : Should return response without passing the options', async () => { - const res = await userKate.channel.subscribers({page:1, limit:10, category:2}); + it('With signer and account : Should return response without passing the options', async () => { + const res = await userKate.channel.subscribers({ page: 1, limit: 10 }); + // console.log(res) + expect(res).not.null; + }); + + it('With signer and account : Should return response with settings', async () => { + const res = await userKate.channel.subscribers({ + page: 1, + limit: 10, + setting: true, + }); + // console.log(res) + expect(res).not.null; + }); + + it('With signer and account : Should return response without settings', async () => { + const res = await userKate.channel.subscribers({ + page: 1, + limit: 10, + setting: false, + category: 1, + }); + // console.log(res) expect(res).not.null; });