Skip to content

Commit 1710123

Browse files
fix: channel api changes (#1430)
1 parent 5b12693 commit 1710123

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

packages/restapi/src/lib/channels/getChannels.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type getChannelsOptionsType = {
1616
order?: string;
1717
filter?: number;
1818
tag?: string;
19+
user_subscribed?: string;
1920
};
2021

2122
export const getChannels = async (options: getChannelsOptionsType) => {
@@ -27,13 +28,16 @@ export const getChannels = async (options: getChannelsOptionsType) => {
2728
order = CONSTANTS.FILTER.CHANNEL_LIST.ORDER.DESCENDING,
2829
filter,
2930
tag,
31+
user_subscribed,
3032
} = options || {};
3133

3234
const API_BASE_URL = getAPIBaseUrls(env);
3335
const apiEndpoint = `${API_BASE_URL}/v1/channels`;
3436
const requestUrl = `${apiEndpoint}?page=${page}&limit=${limit}&sort=${sort}&order=${order}${
35-
filter ? '&filter=' + filter : ''
36-
}${tag ? '&tag=' + tag : ''}`;
37+
filter ? `&filter=${filter}` : ''
38+
}${tag ? `&tag=${tag}` : ''}${
39+
user_subscribed ? `&user_subscribed=${user_subscribed}` : ''
40+
}`;
3741
return await axiosGet(requestUrl)
3842
.then((response) => {
3943
return response.data;

packages/restapi/src/lib/channels/search.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type SearchChannelOptionsType = {
1717
tag?: string;
1818
// temp fix to support both new and old format
1919
oldFormat?: boolean;
20+
user_subscribed?: string;
2021
};
2122

2223
export const search = async (options: SearchChannelOptionsType) => {
@@ -27,6 +28,7 @@ export const search = async (options: SearchChannelOptionsType) => {
2728
limit = Constants.PAGINATION.LIMIT,
2829
filter,
2930
tag,
31+
user_subscribed,
3032
oldFormat = true,
3133
} = options || {};
3234

@@ -39,6 +41,7 @@ export const search = async (options: SearchChannelOptionsType) => {
3941
query,
4042
...(tag && { tag }),
4143
...(filter && { filter }),
44+
...(user_subscribed && { user_subscribed }),
4245
};
4346
const requestUrl = `${apiEndpoint}?${getQueryParams(queryObj)}`;
4447
return axiosGet(requestUrl)

packages/restapi/src/lib/pushNotification/PushNotificationTypes.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type AliasOptions = Omit<GetAliasInfoOptionsType, 'env'>;
3434
export type AliasInfoOptions = {
3535
raw?: boolean;
3636
version?: number;
37-
}
37+
};
3838

3939
export enum FeedType {
4040
INBOX = 'INBOX',
@@ -57,6 +57,7 @@ export type ChannelSearchOptions = {
5757
// temp fix to support both new and old format
5858
oldFormat?: boolean;
5959
tag?: string;
60+
user_subscribed?: string;
6061
};
6162

6263
// Types related to notification
@@ -137,8 +138,6 @@ export type ChannelOptions = {
137138
raw: boolean;
138139
};
139140

140-
141-
142141
export enum ChannelListType {
143142
ALL = 'all',
144143
VERIFIED = 'verified',
@@ -149,27 +148,24 @@ export enum ChannelListSortType {
149148
SUBSCRIBER = 'subscribers',
150149
}
151150

152-
153-
154151
export type ChannelListOptions = {
155152
page?: number;
156153
limit?: number;
157154
sort?: ChannelListSortType;
158155
order?: ChannelListOrderType;
159156
filter?: number;
160157
tag?: string;
158+
user_subscribed?: string;
161159
};
162160

163161
export type TagListOptions = {
164162
page?: number;
165163
limit?: number;
166164
order?: ChannelListOrderType;
167-
filter?: "PUSH" | "USER" | "*";
168-
}
169-
170-
165+
filter?: 'PUSH' | 'USER' | '*';
166+
};
171167

172168
export enum ChannelListOrderType {
173169
ASCENDING = 'asc',
174170
DESCENDING = 'desc',
175-
};
171+
}

packages/restapi/src/lib/pushNotification/channel.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export class Channel extends PushNotificationBaseClass {
8484
limit = Constants.PAGINATION.LIMIT,
8585
filter,
8686
tag,
87+
user_subscribed,
8788
oldFormat = true,
8889
} = options || {};
8990
return await PUSH_CHANNEL.search({
@@ -92,6 +93,7 @@ export class Channel extends PushNotificationBaseClass {
9293
limit: limit,
9394
filter: filter,
9495
tag: tag,
96+
user_subscribed: user_subscribed,
9597
env: this.env,
9698
oldFormat,
9799
});
@@ -489,6 +491,7 @@ export class Channel extends PushNotificationBaseClass {
489491
order = ChannelListOrderType.DESCENDING,
490492
filter,
491493
tag,
494+
user_subscribed,
492495
} = options || {};
493496

494497
return await PUSH_CHANNEL.getChannels({
@@ -499,6 +502,7 @@ export class Channel extends PushNotificationBaseClass {
499502
order,
500503
filter,
501504
tag,
505+
user_subscribed,
502506
});
503507
} catch (error) {
504508
throw new Error(`Push SDK Error: Contract : channel::list : ${error}`);

0 commit comments

Comments
 (0)