-
Notifications
You must be signed in to change notification settings - Fork 181
/
WhatsAppText.ts
41 lines (39 loc) · 1.03 KB
/
WhatsAppText.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { AbstractTextMessage } from '../AbstractTextMessage';
import { WhatsAppTextParams, WhatsAppContext } from '../../types';
/**
* Represents a text message for WhatsApp.
*
* @group WhatsApp
*/
export class WhatsAppText
extends AbstractTextMessage
implements WhatsAppTextParams
{
public channel: 'whatsapp';
public context?: WhatsAppContext;
/**
* Send a WhatsApp text message.
*
* @param {WhatsAppTextParams} params - The parameters for creating a WhatsApp text message.
* @example
* ```ts
* import { WhatsAppText } from '@vonage/messages';
*
* const { messageUUID } = await messagesClient.send(new WhatsAppText({
* to: TO_NUMBER,
* from: FROM_NUMBER,
* text: 'Hello world',
* clientRef: 'my-personal-reference',
* }));
*
* console.log(`Message sent successfully with UUID ${messageUUID}`);
* ```
*/
public constructor(params: WhatsAppTextParams) {
super(params);
this.channel = 'whatsapp';
if (params.context) {
this.context = params.context;
}
}
}