Skip to content

Commit f8b208f

Browse files
authored
fix: Append 'category' and 'isRead' as query params in bulk update API
1 parent 9eb85c5 commit f8b208f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Siren.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export class Siren {
242242
};
243243

244244
if(category) params.category = category;
245-
245+
246246
response = await notificationsBulkUpdates(
247247
this.token,
248248
this.recipientId,
@@ -299,6 +299,7 @@ export class Siren {
299299

300300
if (isRead !== undefined) params.isRead = isRead;
301301
if(category) params.category = category;
302+
302303
response = await notificationsBulkUpdates(
303304
this.token,
304305
this.recipientId,

src/api/notificationsBulkUpdates.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,29 @@ const notificationsBulkUpdates = (
1212
inAppRecipientId: string,
1313
data: {
1414
until: string;
15-
isRead?: boolean;
1615
operation: BulkUpdateType;
16+
category?: string,
17+
isRead?: boolean
1718
}
1819
): Promise<ActionResponse> => {
19-
const path = `api/v2/in-app/recipients/${inAppRecipientId}/notifications/bulk-update`;
20+
let path = `api/v2/in-app/recipients/${inAppRecipientId}/notifications/bulk-update`;
2021

22+
const { category, isRead, ...filteredData } = data;
23+
24+
if (category)
25+
path = `${path}?category=${category}`;
26+
27+
if (isRead)
28+
path = path.includes('?') ? `${path}&isRead=${isRead}` : `${path}?isRead=${isRead}`;
29+
2130
const resp: Promise<ActionResponse> = httpPost(
2231
{
2332
path,
2433
token,
2534
errorLevel: ErrorLevelType.ERROR,
2635
operation: operations[data.operation ?? BulkUpdateType.MARK_AS_READ]
2736
},
28-
data
37+
filteredData
2938
);
3039

3140
return resp;

0 commit comments

Comments
 (0)