@magicbell/core
Version:
Official MagicBell API wrapper
51 lines (50 loc) • 1.51 kB
TypeScript
import { NewNotification } from './NewNotification.js';
/**
* A notification.
*
* @example
* const notification = new Notification({ id })
* notification.fetch()
*/
export default class Notification {
id?: string | null;
title: string;
content: string | null;
category: string | null;
actionUrl?: string | null;
customAttributes: Record<string, any>;
readAt: number | null;
seenAt: number | null;
sentAt: number;
deletedAt: number | null;
private repo;
constructor(attrs?: {});
static create(notificationContent: NewNotification): Promise<any>;
get seenAtDate(): import("dayjs").Dayjs;
get sentAtDate(): import("dayjs").Dayjs;
get readAtDate(): import("dayjs").Dayjs;
get isRead(): boolean;
set isRead(isRead: boolean);
get isSeen(): boolean;
set isSeen(isSeen: boolean);
get sanitizedContent(): string;
/**
* Fetch the notification from the API server.
*/
fetch(): Promise<import("./IRemoteNotification.js").default>;
/**
* Delete a notification from the API server.
*/
delete(): Promise<boolean>;
/**
* Mark a notification as read. Sets the `readAt` attribute to the current unix
* timestamp. It also marks the notification as seen.
*/
markAsRead(): Promise<boolean>;
/**
* Mark a notification as unread. Sets the `readAt` attribute to null.
*/
markAsUnread(): Promise<boolean>;
set(json?: {}): void;
private transformCustomAttributes;
}