diff --git a/packages/restapi/src/lib/channels/getChannels.ts b/packages/restapi/src/lib/channels/getChannels.ts index 4fb8528e9..5fe63d54d 100644 --- a/packages/restapi/src/lib/channels/getChannels.ts +++ b/packages/restapi/src/lib/channels/getChannels.ts @@ -15,22 +15,25 @@ type getChannelsOptionsType = { sort?: string; order?: string; filter?: number; -} + tag?: string; +}; export const getChannels = async (options: getChannelsOptionsType) => { - const { - env = CONSTANTS.ENV.PROD, - page = 1, - limit = 10, + const { + env = CONSTANTS.ENV.PROD, + page = 1, + limit = 10, sort = CONSTANTS.FILTER.CHANNEL_LIST.SORT.SUBSCRIBER, order = CONSTANTS.FILTER.CHANNEL_LIST.ORDER.DESCENDING, - filter + filter, + tag, } = options || {}; const API_BASE_URL = getAPIBaseUrls(env); const apiEndpoint = `${API_BASE_URL}/v1/channels`; - const requestUrl = `${apiEndpoint}?page=${page}&limit=${limit}&sort=${sort}&order=${order}${filter? '&filter=' + filter : ''}`; - + const requestUrl = `${apiEndpoint}?page=${page}&limit=${limit}&sort=${sort}&order=${order}${ + filter ? '&filter=' + filter : '' + }${tag ? '&tag=' + tag : ''}`; return await axiosGet(requestUrl) .then((response) => { return response.data; diff --git a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts index e8a6f5861..a061adfae 100644 --- a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts +++ b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts @@ -156,6 +156,7 @@ export type ChannelListOptions = { sort?: ChannelListSortType; order?: ChannelListOrderType; filter?: number; + tag?: string; }; export type TagListOptions = { diff --git a/packages/restapi/src/lib/pushNotification/channel.ts b/packages/restapi/src/lib/pushNotification/channel.ts index 0039a522c..349d5a686 100644 --- a/packages/restapi/src/lib/pushNotification/channel.ts +++ b/packages/restapi/src/lib/pushNotification/channel.ts @@ -477,6 +477,7 @@ export class Channel extends PushNotificationBaseClass { sort = ChannelListSortType.SUBSCRIBER, order = ChannelListOrderType.DESCENDING, filter, + tag, } = options || {}; return await PUSH_CHANNEL.getChannels({ @@ -485,7 +486,8 @@ export class Channel extends PushNotificationBaseClass { limit, sort, order, - filter + filter, + tag }); } catch (error) { throw new Error(`Push SDK Error: Contract : channel::list : ${error}`); diff --git a/packages/restapi/tests/lib/channel/getChannels.test.ts b/packages/restapi/tests/lib/channel/getChannels.test.ts index 1c97780d8..d3a0c3572 100644 --- a/packages/restapi/tests/lib/channel/getChannels.test.ts +++ b/packages/restapi/tests/lib/channel/getChannels.test.ts @@ -10,4 +10,12 @@ describe('PUSH_CHANNELS.getChannels', () => { }); console.log(res); }); + + it.only('Should fetch channels based on the filter and tags', async () => { + const res = await getChannels({ + env: ENV.DEV, + tag: 'Infrastructure' + }); + console.log(res.channels[0]); + }); });