From 30d65b97663dfc736f31d3f080b54f19b5b90e59 Mon Sep 17 00:00:00 2001 From: Mohammed S Date: Thu, 13 Feb 2025 13:14:10 +0530 Subject: [PATCH] fix: channel api changes --- packages/restapi/src/lib/channels/getChannels.ts | 8 ++++++-- packages/restapi/src/lib/channels/search.ts | 3 +++ .../pushNotification/PushNotificationTypes.ts | 16 ++++++---------- .../restapi/src/lib/pushNotification/channel.ts | 4 ++++ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/restapi/src/lib/channels/getChannels.ts b/packages/restapi/src/lib/channels/getChannels.ts index 5fe63d54d..3e0fd6a70 100644 --- a/packages/restapi/src/lib/channels/getChannels.ts +++ b/packages/restapi/src/lib/channels/getChannels.ts @@ -16,6 +16,7 @@ type getChannelsOptionsType = { order?: string; filter?: number; tag?: string; + user_subscribed?: string; }; export const getChannels = async (options: getChannelsOptionsType) => { @@ -27,13 +28,16 @@ export const getChannels = async (options: getChannelsOptionsType) => { order = CONSTANTS.FILTER.CHANNEL_LIST.ORDER.DESCENDING, filter, tag, + user_subscribed, } = 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 : '' - }${tag ? '&tag=' + tag : ''}`; + filter ? `&filter=${filter}` : '' + }${tag ? `&tag=${tag}` : ''}${ + user_subscribed ? `&user_subscribed=${user_subscribed}` : '' + }`; return await axiosGet(requestUrl) .then((response) => { return response.data; diff --git a/packages/restapi/src/lib/channels/search.ts b/packages/restapi/src/lib/channels/search.ts index 957906537..638e75f86 100644 --- a/packages/restapi/src/lib/channels/search.ts +++ b/packages/restapi/src/lib/channels/search.ts @@ -17,6 +17,7 @@ export type SearchChannelOptionsType = { tag?: string; // temp fix to support both new and old format oldFormat?: boolean; + user_subscribed?: string; }; export const search = async (options: SearchChannelOptionsType) => { @@ -27,6 +28,7 @@ export const search = async (options: SearchChannelOptionsType) => { limit = Constants.PAGINATION.LIMIT, filter, tag, + user_subscribed, oldFormat = true, } = options || {}; @@ -39,6 +41,7 @@ export const search = async (options: SearchChannelOptionsType) => { query, ...(tag && { tag }), ...(filter && { filter }), + ...(user_subscribed && { user_subscribed }), }; const requestUrl = `${apiEndpoint}?${getQueryParams(queryObj)}`; return axiosGet(requestUrl) diff --git a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts index 79407f65e..fc80610b8 100644 --- a/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts +++ b/packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts @@ -34,7 +34,7 @@ export type AliasOptions = Omit; export type AliasInfoOptions = { raw?: boolean; version?: number; -} +}; export enum FeedType { INBOX = 'INBOX', @@ -57,6 +57,7 @@ export type ChannelSearchOptions = { // temp fix to support both new and old format oldFormat?: boolean; tag?: string; + user_subscribed?: string; }; // Types related to notification @@ -137,8 +138,6 @@ export type ChannelOptions = { raw: boolean; }; - - export enum ChannelListType { ALL = 'all', VERIFIED = 'verified', @@ -149,8 +148,6 @@ export enum ChannelListSortType { SUBSCRIBER = 'subscribers', } - - export type ChannelListOptions = { page?: number; limit?: number; @@ -158,18 +155,17 @@ export type ChannelListOptions = { order?: ChannelListOrderType; filter?: number; tag?: string; + user_subscribed?: string; }; export type TagListOptions = { page?: number; limit?: number; order?: ChannelListOrderType; - filter?: "PUSH" | "USER" | "*"; -} - - + filter?: 'PUSH' | 'USER' | '*'; +}; export enum ChannelListOrderType { ASCENDING = 'asc', DESCENDING = 'desc', -}; \ No newline at end of file +} diff --git a/packages/restapi/src/lib/pushNotification/channel.ts b/packages/restapi/src/lib/pushNotification/channel.ts index 428dc597e..4eef43d93 100644 --- a/packages/restapi/src/lib/pushNotification/channel.ts +++ b/packages/restapi/src/lib/pushNotification/channel.ts @@ -84,6 +84,7 @@ export class Channel extends PushNotificationBaseClass { limit = Constants.PAGINATION.LIMIT, filter, tag, + user_subscribed, oldFormat = true, } = options || {}; return await PUSH_CHANNEL.search({ @@ -92,6 +93,7 @@ export class Channel extends PushNotificationBaseClass { limit: limit, filter: filter, tag: tag, + user_subscribed: user_subscribed, env: this.env, oldFormat, }); @@ -489,6 +491,7 @@ export class Channel extends PushNotificationBaseClass { order = ChannelListOrderType.DESCENDING, filter, tag, + user_subscribed, } = options || {}; return await PUSH_CHANNEL.getChannels({ @@ -499,6 +502,7 @@ export class Channel extends PushNotificationBaseClass { order, filter, tag, + user_subscribed, }); } catch (error) { throw new Error(`Push SDK Error: Contract : channel::list : ${error}`);