generate references (#7882)
This commit is contained in:
@@ -36,15 +36,81 @@ export default MyNotificationProviderService
|
||||
|
||||
### constructor
|
||||
|
||||
The constructor allows you to access resources from the module's container using the first parameter,
|
||||
and the module's options using the second parameter.
|
||||
|
||||
If you're creating a client or establishing a connection with a third-party service, do it in the constructor.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
import { AbstractNotificationProviderService } from "@medusajs/utils"
|
||||
import { Logger } from "@medusajs/types"
|
||||
|
||||
type InjectedDependencies = {
|
||||
logger: Logger
|
||||
}
|
||||
|
||||
type Options = {
|
||||
apiKey: string
|
||||
}
|
||||
|
||||
class MyNotificationProviderService extends AbstractNotificationProviderService {
|
||||
protected logger_: Logger
|
||||
protected options_: Options
|
||||
// assuming you're initializing a client
|
||||
protected client
|
||||
|
||||
constructor (
|
||||
{ logger }: InjectedDependencies,
|
||||
options: Options
|
||||
) {
|
||||
super()
|
||||
|
||||
this.logger_ = logger
|
||||
this.options_ = options
|
||||
|
||||
// assuming you're initializing a client
|
||||
this.client = new Client(options)
|
||||
}
|
||||
}
|
||||
|
||||
export default MyNotificationProviderService
|
||||
```
|
||||
|
||||
### constructor
|
||||
|
||||
### send
|
||||
|
||||
This method is used to send a notification using the third-party provider or your custom logic.
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
class MyNotificationProviderService extends AbstractNotificationProviderService {
|
||||
// ...
|
||||
async send(
|
||||
notification: ProviderSendNotificationDTO
|
||||
): Promise<ProviderSendNotificationResultsDTO> {
|
||||
// TODO send the notification using a third-party
|
||||
// provider or custom logic.
|
||||
// for example:
|
||||
return this.client.send({
|
||||
email: notification.to,
|
||||
template: notification.template,
|
||||
template_data: notification.data
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
<TypeList types={[{"name":"notification","type":"`ProviderSendNotificationDTO`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="send"/>
|
||||
<TypeList types={[{"name":"notification","type":"[ProviderSendNotificationDTO](../../../types/NotificationTypes/interfaces/types.NotificationTypes.ProviderSendNotificationDTO/page.mdx)","description":"The details of the\nnotification to send.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"to","type":"`string`","description":"The recipient of the notification. It can be email, phone number, or username, depending on the channel.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"channel","type":"`string`","description":"The channel through which the notification is sent, such as 'email' or 'sms'","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"template","type":"`string`","description":"The template name in the provider's system.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"data","type":"`null` \\| `Record<string, unknown>`","description":"The data that gets passed over to the provider for rendering the notification.","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]} sectionTitle="send"/>
|
||||
|
||||
#### Returns
|
||||
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<ProviderSendNotificationResultsDTO>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"ProviderSendNotificationResultsDTO","type":"`ProviderSendNotificationResultsDTO`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]}]} sectionTitle="send"/>
|
||||
<TypeList types={[{"name":"Promise","type":"Promise<[ProviderSendNotificationResultsDTO](../../../types/NotificationTypes/interfaces/types.NotificationTypes.ProviderSendNotificationResultsDTO/page.mdx)>","optional":false,"defaultValue":"","description":"The result of sending\nthe notification.","expandable":false,"children":[{"name":"ProviderSendNotificationResultsDTO","type":"[ProviderSendNotificationResultsDTO](../../../types/NotificationTypes/interfaces/types.NotificationTypes.ProviderSendNotificationResultsDTO/page.mdx)","optional":false,"defaultValue":"","description":"","expandable":false,"children":[{"name":"id","type":"`string`","description":"The ID of the notification in the external system, if provided in the response","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} sectionTitle="send"/>
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user