UNPKG

@cranberry-money/shared-services

Version:

Platform-agnostic API services with pure functions and dependency injection. Includes auth, portfolios, assets, countries, sectors, and more.

59 lines 2.03 kB
import { DEVICE_TOKEN_ENDPOINTS, NOTIFICATION_ENDPOINTS, NOTIFICATION_PREFERENCES_ENDPOINTS, } from '@cranberry-money/shared-constants'; /** * Register a device push token for the current user. */ export const registerDeviceToken = (apiClient, data) => { return apiClient.post(DEVICE_TOKEN_ENDPOINTS.REGISTER, data); }; /** * Unregister a device push token. */ export const unregisterDeviceToken = (apiClient, data) => { return apiClient.post(DEVICE_TOKEN_ENDPOINTS.UNREGISTER, data); }; /** * Get the current user's notification preferences. */ export const getNotificationPreferences = (apiClient) => { return apiClient.get(NOTIFICATION_PREFERENCES_ENDPOINTS.BASE); }; /** * Update the current user's notification preferences. */ export const updateNotificationPreferences = (apiClient, data) => { return apiClient.post(NOTIFICATION_PREFERENCES_ENDPOINTS.BASE, data); }; // ===================================================== // IN-APP NOTIFICATIONS // ===================================================== /** * Get paginated list of in-app notifications for the current user. */ export const getNotifications = (apiClient) => { return apiClient.get(NOTIFICATION_ENDPOINTS.BASE); }; /** * Get unread notification count for the current user. */ export const getUnreadNotificationCount = (apiClient) => { return apiClient.get(NOTIFICATION_ENDPOINTS.UNREAD_COUNT); }; /** * Mark a single notification as read. */ export const markNotificationRead = (apiClient, uuid) => { return apiClient.patch(NOTIFICATION_ENDPOINTS.DETAIL(uuid), { is_read: true }); }; /** * Archive a single notification (removes it from the inbox). */ export const archiveNotification = (apiClient, uuid) => { return apiClient.patch(NOTIFICATION_ENDPOINTS.DETAIL(uuid), { is_archived: true }); }; /** * Mark all unread notifications as read. */ export const markAllNotificationsRead = (apiClient) => { return apiClient.post(NOTIFICATION_ENDPOINTS.MARK_ALL_READ); }; //# sourceMappingURL=notifications.js.map