UNPKG

@trycourier/courier-react-native

Version:

Inbox, Push Notifications, and Preferences for React Native

116 lines (105 loc) 4.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InboxClient = void 0; var _Modules = require("../Modules"); class InboxClient { constructor(clientId) { this.clientId = clientId; } /** * Retrieves messages from the inbox. * @param props - The properties for getting messages. * @param props.paginationLimit - Optional. The number of messages to retrieve per page. Defaults to 24. * @param props.startCursor - Optional. The cursor to start retrieving messages from. * @returns A promise that resolves with the CourierGetInboxMessagesResponse containing the messages. */ async getMessages(props) { const json = await _Modules.Modules.Client.getMessages(this.clientId, props.paginationLimit ?? 24, props.startCursor); return JSON.parse(json); } /** * Retrieves archived messages from the inbox. * @param props - The properties for getting archived messages. * @param props.paginationLimit - Optional. The number of messages to retrieve per page. Defaults to 24. * @param props.startCursor - Optional. The cursor to start retrieving messages from. * @returns A promise that resolves with the CourierGetInboxMessagesResponse containing the archived messages. */ async getArchivedMessages(props) { const json = await _Modules.Modules.Client.getArchivedMessages(this.clientId, props.paginationLimit ?? 24, props.startCursor); return JSON.parse(json); } /** * Retrieves a specific message by its ID. * @param props - The properties for getting the message. * @param props.messageId - The ID of the message to retrieve. * @returns A promise that resolves with the CourierGetInboxMessageResponse containing the message. */ async getMessageById(props) { const json = await _Modules.Modules.Client.getMessageById(this.clientId, props.messageId); return JSON.parse(json); } /** * Retrieves the count of unread messages in the inbox. * @returns A promise that resolves with the number of unread messages. */ async getUnreadMessageCount() { return await _Modules.Modules.Client.getUnreadMessageCount(this.clientId); } /** * Marks a message as opened. * @param props - The properties for opening the message. * @param props.messageId - The ID of the message to mark as opened. * @returns A promise that resolves with a number indicating the operation result. */ async open(props) { return await _Modules.Modules.Client.openMessage(this.clientId, props.messageId); } /** * Marks a message as read. * @param props - The properties for reading the message. * @param props.messageId - The ID of the message to mark as read. * @returns A promise that resolves with a number indicating the operation result. */ async read(props) { return await _Modules.Modules.Client.readMessage(this.clientId, props.messageId); } /** * Marks a message as unread. * @param props - The properties for marking the message as unread. * @param props.messageId - The ID of the message to mark as unread. * @returns A promise that resolves with a number indicating the operation result. */ async unread(props) { return await _Modules.Modules.Client.unreadMessage(this.clientId, props.messageId); } /** * Records a click event for a message. * @param props - The properties for clicking the message. * @param props.messageId - The ID of the message that was clicked. * @param props.trackingId - The tracking ID associated with the click event. * @returns A promise that resolves with a number indicating the operation result. */ async click(props) { return await _Modules.Modules.Client.clickMessage(this.clientId, props.messageId, props.trackingId); } /** * Archives a message. * @param props - The properties for archiving the message. * @param props.messageId - The ID of the message to archive. * @returns A promise that resolves with a number indicating the operation result. */ async archive(props) { return await _Modules.Modules.Client.archiveMessage(this.clientId, props.messageId); } /** * Marks all messages as read. * @returns A promise that resolves with a number indicating the operation result. */ async readAll() { return await _Modules.Modules.Client.readAllMessages(this.clientId); } } exports.InboxClient = InboxClient; //# sourceMappingURL=InboxClient.js.map