Skip to content

Commit 9ecff9b

Browse files
V 1.2.0
- Add category support
2 parents e38f480 + f8b208f commit 9ecff9b

31 files changed

+1133
-857
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
API_DOMAIN = https://api.sirenapp.io/
1+
API_DOMAIN = https://api.trysiren.io/

.prettierrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json.schemastore.org/prettierrc",
3+
"semi": true,
4+
"tabWidth": 2,
5+
"singleQuote": true,
6+
"printWidth": 100,
7+
"trailingComma": "none",
8+
"jsxSingleQuote": true,
9+
"bracketSpacing": true,
10+
"bracketSameLine": false,
11+
"arrowParens": "always",
12+
"useTabs": false,
13+
"quoteProps": "as-needed",
14+
"vueIndentScriptAndStyle": false,
15+
"braceStyle": "stroustrup"
16+
}

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ const { unviewedCount } = await sirenInstance.fetchUnviewedNotificationsCount()
114114
This method retrieves list of notifications in a paginated manner.
115115
116116
```bash
117-
const notifications = await sirenInstance.fetchAllNotifications({ page: 0, size: 15, start: '', end: '', isRead: false });
117+
const notifications = await sirenInstance.fetchAllNotifications({ page: 0, size: 15, start: '', end: '', isRead: false, category: 'posts' });
118118
```
119119
120+
Below are the accepted optional filters
120121
<table>
121122
<thead>
122123
<tr>
123124
<th>Argument</th>
124125
<th>Description</th>
125126
<th>Type</th>
126-
<th>Mandatory</th>
127127
<th>Default</th>
128128
</tr>
129129
</thead>
@@ -132,37 +132,38 @@ const notifications = await sirenInstance.fetchAllNotifications({ page: 0, size:
132132
<td>page</td>
133133
<td>Current page</td>
134134
<td>number</td>
135-
<td>false</td>
136135
<td>0</td>
137136
</tr>
138137
<tr>
139138
<td>size</td>
140139
<td>Number of items fetched </td>
141140
<td>number</td>
142-
<td>false</td>
143141
<td>10</td>
144142
</tr>
145143
<tr>
146144
<td>start</td>
147145
<td>Accepts an ISO date string to filter notifications created after the specified date. By default, only the first 20 notifications will be fetched <br />
148146
eg: 2024-02-19T06:37:33.792+00:00</td>
149147
<td>string</td>
150-
<td>false</td>
151148
<td>null</td>
152149
</tr>
153150
<tr>
154151
<td>end</td>
155152
<td>Accepts an ISO date string to filter notifications created before the specified date. By default, only the first 20 notifications will be fetched <br />
156153
eg: 2024-02-19T06:37:33.792+00:00</td>
157154
<td>string</td>
158-
<td>false</td>
159155
<td>null</td>
160156
</tr>
161157
<tr>
162158
<td>isRead</td>
163159
<td>Filter to fetch read or unread notifications. If not specified, it retrieves both read and unread notifications</td>
164160
<td>boolean</td>
165-
<td>false</td>
161+
<td>null</td>
162+
</tr>
163+
<tr>
164+
<td>category</td>
165+
<td>Filter to fetch notifications by category. If not specified, it retrieves all notifications</td>
166+
<td>string</td>
166167
<td>null</td>
167168
</tr>
168169
</tbody>
@@ -196,19 +197,19 @@ const notifications = await sirenInstance.fetchAllNotifications({ page: 0, size:
196197
By specifying the parameter eventType as either `NOTIFICATIONS` or `UNVIEWED_COUNT`, this method triggers the real-time retrieval of notifications or the count of unviewed notifications. If `NOTIFICATIONS` is selected, further parameters (`params`) can be provided for additional customization or filtering
197198
198199
```bash
199-
sirenInstance.startRealTimeFetch({ eventType: NOTIFICATIONS, params:{ page: 0, size: 15, start: '', end: '', isRead: false }});
200+
sirenInstance.startRealTimeFetch({ eventType: NOTIFICATIONS, params:{ page: 0, size: 15, start: '', end: '', isRead: false, category: 'posts' }});
200201

201202
sirenInstance.startRealTimeFetch({ eventType: UNVIEWED_COUNT });
202203
```
203204
204-
Below are the accepted filters for notifications
205+
Below are the accepted optional filters for `NOTIFICATIONS` event type
206+
205207
<table>
206208
<thead>
207209
<tr>
208210
<th>Argument</th>
209211
<th>Description</th>
210212
<th>Type</th>
211-
<th>Mandatory</th>
212213
<th>Default</th>
213214
</tr>
214215
</thead>
@@ -217,35 +218,36 @@ Below are the accepted filters for notifications
217218
<td>page</td>
218219
<td>Represents the current page</td>
219220
<td>number</td>
220-
<td>false</td>
221221
<td>0</td>
222222
</tr>
223223
<tr>
224224
<td>size</td>
225225
<td>The number of items to be fetched in a single call</td>
226226
<td>number</td>
227-
<td>false</td>
228227
<td>10</td>
229228
</tr>
230229
<tr>
231230
<td>start</td>
232231
<td>Accepts an ISO date string to filter notifications created after the specified date. By default, only the first 20 notifications will be fetched </td>
233232
<td>string</td>
234-
<td>false</td>
235233
<td>null</td>
236234
</tr>
237235
<tr>
238236
<td>end</td>
239237
<td>Accepts an ISO date string to filter notifications created before the specified date. By default, only the first 20 notifications will be fetched</td>
240238
<td>string</td>
241-
<td>false</td>
242239
<td>null</td>
243240
</tr>
244241
<tr>
245242
<td>isRead</td>
246243
<td>Filter to fetch read or unread notifications. If not specified, it retrieves both read and unread notifications</td>
247244
<td>number</td>
248-
<td>false</td>
245+
<td>null</td>
246+
</tr>
247+
<tr>
248+
<td>category</td>
249+
<td>Filter to fetch notifications by category. If not specified, it retrieves all notifications</td>
250+
<td>string</td>
249251
<td>null</td>
250252
</tr>
251253
</tbody>
@@ -273,10 +275,10 @@ await sirenInstance.markAsReadById("your-notification-id");
273275
### 7. markAsReadByDate
274276
275277
This method marks the notifications as read till the given date.<br />
276-
It accepts an ISO date string as an argument.
278+
It accepts a param object as an argument with keys startDate (ISO date string) and category(string).
277279
278280
```bash
279-
await sirenInstance.markAsReadByDate("2011-10-05T14:48:00.000Z");
281+
await sirenInstance.markAsReadByDate({startDate: "2011-10-05T14:48:00.000Z"});
280282
```
281283
282284
### 8. deleteById
@@ -290,10 +292,10 @@ await sirenInstance.deleteById("your-notification-id");
290292
### 9. deleteByDate
291293
292294
This method deletes the notifications till the given date.<br />
293-
It accepts an ISO date string as an argument
295+
It accepts a param object as an argument with keys startDate (ISO date string), isRead(boolean) and category(string).
294296
295297
```bash
296-
await sirenInstance.deleteByDate("2011-10-05T14:48:00.000Z");
298+
await sirenInstance.deleteByDate({startDate: "2011-10-05T14:48:00.000Z"});
297299
```
298300
299301
### 10. markAllAsViewed

examples/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ <h1>Logs</h1>
124124

125125
async function markAllAsRead() {
126126
if (sirenWeb) {
127-
const res= await sirenWeb.markAsReadByDate(new Date().toISOString());
127+
const res= await sirenWeb.markAsReadByDate({startDate: new Date().toISOString()});
128128
document.getElementById("output").innerHTML = 'Mark All as Read ' + JSON.stringify(res, null, 2);
129129
console.log('markAllNotificationsAsRead', res);
130130
}
@@ -140,7 +140,7 @@ <h1>Logs</h1>
140140

141141
async function clearAll() {
142142
if (sirenWeb) {
143-
const res = await sirenWeb.deleteByDate(new Date().toISOString());
143+
const res = await sirenWeb.deleteByDate({startDate: Date().toISOString(), isRead: true});
144144
document.getElementById("output").innerHTML = 'Delete All Notification ' + JSON.stringify(res, null, 2);
145145
console.log('clearAllNotifications', res);
146146
}

0 commit comments

Comments
 (0)