@magicbell/react-headless
Version:
Hooks to build a notification inbox
33 lines (32 loc) • 1.03 kB
TypeScript
import { QueryParams } from '../../types/INotificationsStoresCollection.js';
/**
* Class to represent a client that interacts with the MagicBell API.
*
* @example
* class NotificationRepo extends RemoteRepository<Notification, NotificationStore> {}
*/
export default abstract class RemoteRepository<Item, Collection> {
remotePathOrUrl: string;
constructor(remotePathOrUrl: string);
/**
* Get an element from the API server by ID.
*
* @example
* const notification = await repo.get('3df592eb-5f09dd6b');
*/
get(id: string | number): Promise<Item>;
/**
* Get elements that match params from the API server.
*
* @example
* const notifications = await repo.findBy({ read: false });
*/
findBy(queryParams?: QueryParams): Promise<Collection | void>;
/**
* Delete an element by ID from the API server.
*
* @example
* const deleted = await repo.delete('3df592eb-5f09dd6b');
*/
delete(id: string | number): Promise<boolean>;
}