--- displayed_sidebar: servicesSidebar --- import ParameterTypes from "@site/src/components/ParameterTypes" # NotificationService ## constructor ### Parameters ___ ## Properties `","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="NotificationService"/> ___ ## Accessors ### activeManager\_ #### Returns ___ ## Methods ### withTransaction #### Parameters #### Returns ### shouldRetryTransaction\_ #### Parameters ` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/> #### Returns ### atomicPhase\_ Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created. #### Type Parameters #### Parameters Promise<TResult>","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise<void \\| TResult>","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise<void \\| TResult>","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/> #### Returns ### registerAttachmentGenerator Registers an attachment generator to the service. The generator can be used to generate on demand invoices or other documents. #### Parameters #### Returns ### registerInstalledProviders Takes a list of notification provider ids and persists them in the database. #### Parameters #### Returns ### list Retrieves a list of notifications. #### Parameters #### Returns ### listAndCount Retrieves a list of notifications and total count. #### Parameters #### Returns ### retrieve Retrieves a notification with a given id #### Parameters #### Returns ### subscribe Subscribes a given provider to an event. #### Parameters #### Returns ### retrieveProvider\_ Finds a provider with a given id. Will throw a NOT\_FOUND error if the resolution fails. #### Parameters #### Returns ;\n }> {\n throw new Error(\"Method not implemented.\")\n }\n resendNotification(\n notification: unknown,\n config: unknown,\n attachmentGenerator: unknown\n ): Promise<{\n to: string;\n status: string;\n data: Record;\n }> {\n throw new Error(\"Method not implemented.\")\n }\n\n}\n\nexport default EmailSenderService\n```\n\n---\n\n## Identifier Property\n\nThe `NotificationProvider` entity has 2 properties: `identifier` and `is_installed`. The value of the `identifier` property in the notification provider\nclass is used when the Notification Provider is created in the database.\n\nThe value of this property is also used later when you want to subscribe the Notification Provider to events in a [Loader](https://docs.medusajs.com/development/loaders/overview).\n\nFor example:\n\n```ts\nclass EmailSenderService extends AbstractNotificationService {\n static identifier = \"email-sender\"\n // ...\n}\n```\n\n---","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="retrieveProvider_"/> ### handleEvent Handles an event by relaying the event data to the subscribing providers. The result of the notification send will be persisted in the database in order to allow for resends. Will log any errors that are encountered. #### Parameters `","description":"the data the event was sent with","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="handleEvent"/> #### Returns ### send Sends a notification, by calling the given provider's sendNotification method. Persists the Notification in the database. #### Parameters `","description":"the data the event was sent with","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"providerId","type":"`string`","description":"the provider that should handle the event.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="send"/> #### Returns ### resend Resends a notification by retrieving a prior notification and calling the underlying provider's resendNotification method. #### Parameters #### Returns