This version (v0.7) has not been published to npm yet.
Skip to content

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? ​

NoParams

options? ​

CallOptions

Returns ​

Promise<NotificationPreferences>

Example ​

ts
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? ​

ListNotificationsInput

options? ​

CallOptions

Returns ​

Promise<NotificationsPage>

Example ​

ts
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? ​

CallOptions

Returns ​

Promise<void>

Example ​

ts
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? ​

CallOptions

Returns ​

Promise<NotificationPreferences>

Example ​

ts
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.