diff --git a/packages/restapi/src/lib/channels/search.ts b/packages/restapi/src/lib/channels/search.ts index bef8f4037..77b9d433e 100644 --- a/packages/restapi/src/lib/channels/search.ts +++ b/packages/restapi/src/lib/channels/search.ts @@ -14,6 +14,7 @@ export type SearchChannelOptionsType = { page?: number; limit?: number; filter?: number; + tag?: string; // temp fix to support both new and old format oldFormat?: boolean; }; @@ -25,6 +26,7 @@ export const search = async (options: SearchChannelOptionsType) => { page = Constants.PAGINATION.INITIAL_PAGE, limit = Constants.PAGINATION.LIMIT, filter, + tag, oldFormat = true, } = options || {}; @@ -35,6 +37,7 @@ export const search = async (options: SearchChannelOptionsType) => { page, limit: getLimit(limit), query, + ...(tag && { tag }), ...(filter && { filter }), }; const requestUrl = `${apiEndpoint}?${getQueryParams(queryObj)}`; diff --git a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts index a061adfae..79407f65e 100644 --- a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts +++ b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts @@ -56,6 +56,7 @@ export type ChannelSearchOptions = { filter?: number; // temp fix to support both new and old format oldFormat?: boolean; + tag?: string; }; // Types related to notification diff --git a/packages/restapi/src/lib/pushNotification/channel.ts b/packages/restapi/src/lib/pushNotification/channel.ts index 349d5a686..0b93273bf 100644 --- a/packages/restapi/src/lib/pushNotification/channel.ts +++ b/packages/restapi/src/lib/pushNotification/channel.ts @@ -78,6 +78,7 @@ export class Channel extends PushNotificationBaseClass { page = Constants.PAGINATION.INITIAL_PAGE, limit = Constants.PAGINATION.LIMIT, filter, + tag, oldFormat = true } = options || {}; return await PUSH_CHANNEL.search({ @@ -85,6 +86,7 @@ export class Channel extends PushNotificationBaseClass { page: page, limit: limit, filter: filter, + tag: tag, env: this.env, oldFormat }); diff --git a/packages/restapi/tests/lib/channel/search.test.ts b/packages/restapi/tests/lib/channel/search.test.ts index d82c002ad..59df81a5e 100644 --- a/packages/restapi/tests/lib/channel/search.test.ts +++ b/packages/restapi/tests/lib/channel/search.test.ts @@ -12,7 +12,7 @@ describe('PUSH_CHANNELS.search', () => { console.log(res); }); - it.only('Should fetch channels based on the filter in new format', async () => { + it('Should fetch channels based on the filter in new format', async () => { const res = await search({ filter: 80002, env: ENV.DEV, @@ -21,4 +21,14 @@ describe('PUSH_CHANNELS.search', () => { }); console.log(res); }); + + it('Should fetch channels based on the filter in new format', async () => { + const res = await search({ + env: ENV.DEV, + query: "Channel", + oldFormat: false, + tag: "Infrastructure" + }); + console.log(res); + }); });