Reference / @getenginex/sdk / NotificationsApi
NotificationsApi
The player's notifications (history over REST) and channel preferences. All methods require login. The real-time notice is another channel (realtime's coreTopics.notification()): show the toast with it and call NotificationsApi.list to refresh the list.
Methods
getPreferences()
getPreferences(
params?,options?):Promise<NotificationPreferences>
The player's channel preferences.
Parameters
params?
options?
Returns
Promise<NotificationPreferences>
Example
const { email, push } = await enginex.notifications.getPreferences()Throws
UNAUTHENTICATED without a session; VALIDATION_ERROR in strict with an unexpected format.
list()
list(
input?,options?):Promise<NotificationsPage>
Lists the notifications, newest to oldest (gateway order), with the unread counter. The gateway only reports the total: the SDK computes totalPages (0 when there is nothing) and returns items: [] for a page beyond the end.
Parameters
input?
options?
Returns
Promise<NotificationsPage>
Example
const { items, unreadCount, totalPages } = await enginex.notifications.list({ perPage: 20 })Throws
CONFIGURATION_ERROR (without a request) for a page that is not an integer ≥ 1, a perPage outside 1–100 or not an integer, or an unreadOnly that is not a boolean; UNAUTHENTICATED without a session; VALIDATION_ERROR with validation: 'strict' if a notification type is unknown or a date is not a date.
markAsRead()
markAsRead(
input,options?):Promise<void>
Marks a notification as read.
Parameters
input
notificationId
string
options?
Returns
Promise<void>
Example
await enginex.notifications.markAsRead({ notificationId: notification.id })Throws
CONFIGURATION_ERROR (without a request) for an empty notificationId or one that is not text; INVALID_ARGUMENT (without a request) for ./..; UNAUTHENTICATED without a session; NOT_FOUND if the notification does not exist, according to the service.
updatePreferences()
updatePreferences(
input,options?):Promise<NotificationPreferences>
Updates preferences. Only the fields present are sent; returns the complete preferences as the gateway stored them.
Parameters
input
Partial<NotificationPreferences>
options?
Returns
Promise<NotificationPreferences>
Example
const prefs = await enginex.notifications.updatePreferences({ marketing: false })Throws
CONFIGURATION_ERROR (without a request) if the input is not an object, carries no field or a field is not a boolean; UNAUTHENTICATED without a session.