@@ -8,6 +8,8 @@ import { BaseService } from '../base';
88import type {
99 NotificationGetAllOptions ,
1010 NotificationGetResponse ,
11+ NotificationMarkAllReadResponse ,
12+ NotificationUpdateReadResponse ,
1113} from '../../models/notification/notifications.types' ;
1214import type {
1315 NotificationServiceModel ,
@@ -34,9 +36,8 @@ import { PaginationType } from '../../utils/pagination/internal-types';
3436/**
3537 * Service for interacting with the UiPath Notification inbox.
3638 *
37- * Provides list operations against the current user's notifications (the
38- * `/odata/v1/NotificationEntry` API). Further inbox operations (mark-read,
39- * delete) land in follow-up PRs.
39+ * Provides inbox operations against the current user's notifications (the
40+ * `/odata/v1/NotificationEntry` API).
4041 *
4142 * Every public method takes the acting tenant GUID as the first argument — the
4243 * notification API identifies the tenant via the `X-UIPATH-Internal-TenantId`
@@ -125,4 +126,76 @@ export class NotificationService extends BaseService implements NotificationServ
125126 : NonPaginatedResponse < NotificationGetResponse >
126127 > ;
127128 }
129+
130+ /**
131+ * Marks the given notifications as read.
132+ *
133+ * @param tenantId - Tenant GUID
134+ * @param notificationIds - GUIDs of notifications to mark read
135+ * @returns Operation result echoing the affected IDs and new read state
136+ * {@link NotificationUpdateReadResponse}
137+ *
138+ * @example
139+ * ```typescript
140+ * await notifications.markAsRead('<tenantId>', ['<notificationId-1>', '<notificationId-2>']);
141+ * ```
142+ * @internal
143+ */
144+ @track ( 'Notifications.MarkAsRead' )
145+ async markAsRead ( tenantId : string , notificationIds : string [ ] ) : Promise < NotificationUpdateReadResponse > {
146+ return this . updateRead ( tenantId , notificationIds , true ) ;
147+ }
148+
149+ /**
150+ * Marks the given notifications as unread.
151+ *
152+ * @param tenantId - Tenant GUID
153+ * @param notificationIds - GUIDs of notifications to mark unread
154+ * @returns Operation result echoing the affected IDs and new read state
155+ * {@link NotificationUpdateReadResponse}
156+ *
157+ * @example
158+ * ```typescript
159+ * await notifications.markAsUnread('<tenantId>', ['<notificationId>']);
160+ * ```
161+ * @internal
162+ */
163+ @track ( 'Notifications.MarkAsUnread' )
164+ async markAsUnread ( tenantId : string , notificationIds : string [ ] ) : Promise < NotificationUpdateReadResponse > {
165+ return this . updateRead ( tenantId , notificationIds , false ) ;
166+ }
167+
168+ /**
169+ * Marks all notifications in the current user's inbox as read.
170+ *
171+ * @param tenantId - Tenant GUID
172+ * @returns Operation result confirming the bulk update
173+ * {@link NotificationMarkAllReadResponse}
174+ *
175+ * @example
176+ * ```typescript
177+ * await notifications.markAllAsRead('<tenantId>');
178+ * ```
179+ * @internal
180+ */
181+ @track ( 'Notifications.MarkAllAsRead' )
182+ async markAllAsRead ( tenantId : string ) : Promise < NotificationMarkAllReadResponse > {
183+ await this . post ( NOTIFICATION_ENDPOINTS . UPDATE_READ , {
184+ notifications : [ ] ,
185+ forceAllRead : true ,
186+ } , { headers : createHeaders ( { [ TENANT_ID ] : tenantId } ) } ) ;
187+ return { success : true , data : { all : true , read : true } } ;
188+ }
189+
190+ private async updateRead (
191+ tenantId : string ,
192+ notificationIds : string [ ] ,
193+ read : boolean
194+ ) : Promise < NotificationUpdateReadResponse > {
195+ await this . post ( NOTIFICATION_ENDPOINTS . UPDATE_READ , {
196+ notifications : notificationIds . map ( ( notificationId ) => ( { notificationId, read } ) ) ,
197+ forceAllRead : false ,
198+ } , { headers : createHeaders ( { [ TENANT_ID ] : tenantId } ) } ) ;
199+ return { success : true , data : { notificationIds, read } } ;
200+ }
128201}
0 commit comments