Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/restapi/src/lib/channels/getChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type getChannelsOptionsType = {
order?: string;
filter?: number;
tag?: string;
user_subscribed?: string;
};

export const getChannels = async (options: getChannelsOptionsType) => {
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions packages/restapi/src/lib/channels/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -27,6 +28,7 @@ export const search = async (options: SearchChannelOptionsType) => {
limit = Constants.PAGINATION.LIMIT,
filter,
tag,
user_subscribed,
oldFormat = true,
} = options || {};

Expand All @@ -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)
Expand Down
16 changes: 6 additions & 10 deletions packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type AliasOptions = Omit<GetAliasInfoOptionsType, 'env'>;
export type AliasInfoOptions = {
raw?: boolean;
version?: number;
}
};

export enum FeedType {
INBOX = 'INBOX',
Expand All @@ -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
Expand Down Expand Up @@ -137,8 +138,6 @@ export type ChannelOptions = {
raw: boolean;
};



export enum ChannelListType {
ALL = 'all',
VERIFIED = 'verified',
Expand All @@ -149,27 +148,24 @@ export enum ChannelListSortType {
SUBSCRIBER = 'subscribers',
}



export type ChannelListOptions = {
page?: number;
limit?: number;
sort?: ChannelListSortType;
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',
};
}
4 changes: 4 additions & 0 deletions packages/restapi/src/lib/pushNotification/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -92,6 +93,7 @@ export class Channel extends PushNotificationBaseClass {
limit: limit,
filter: filter,
tag: tag,
user_subscribed: user_subscribed,
env: this.env,
oldFormat,
});
Expand Down Expand Up @@ -489,6 +491,7 @@ export class Channel extends PushNotificationBaseClass {
order = ChannelListOrderType.DESCENDING,
filter,
tag,
user_subscribed,
} = options || {};

return await PUSH_CHANNEL.getChannels({
Expand All @@ -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}`);
Expand Down
Loading