-
Notifications
You must be signed in to change notification settings - Fork 180
/
WhatsAppCustom.ts
56 lines (53 loc) · 1.33 KB
/
WhatsAppCustom.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { AbstractMessage } from '../AbstractMessage';
import {
WhatsAppCustomType,
WhatsAppCustomParams,
WhatsAppContext,
} from '../../types';
/**
* Represents a custom message for WhatsApp.
*
* @group WhatsApp
*/
export class WhatsAppCustom
extends AbstractMessage
implements WhatsAppCustomParams
{
public channel: 'whatsapp';
public messageType: 'custom';
public custom: WhatsAppCustomType;
public context?: WhatsAppContext;
/**
* Sends a custom message to a WhatsApp user.
*
* @param {WhatsAppCustomParams} params - The parameters for creating a WhatsApp custom message.
* @example
* ```ts
* import { WhatsAppCustom } from '@vonage/messages';
*
* const { messageUUID } = await messagesClient.send(new WhatsAppCustom({
* to: TO_NUMBER,
* from: FROM_NUMBER,
* custom: {
* type: 'template',
* template: {
* namespace: 'your-namespace',
* name: 'your-template-name',
* },
* }
* clientRef: 'my-personal-reference',
* }));
*
* console.log(`Message sent successfully with UUID ${messageUUID}`);
* ```
*/
public constructor(params: WhatsAppCustomParams) {
super(params);
this.custom = params.custom;
this.channel = 'whatsapp';
this.messageType = 'custom';
if (params.context) {
this.context = params.context;
}
}
}