-
Notifications
You must be signed in to change notification settings - Fork 180
/
WhatsAppSticker.ts
71 lines (68 loc) · 1.8 KB
/
WhatsAppSticker.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { AbstractMessage } from '../AbstractMessage';
import {
WhatsAppStickerParams,
WhatsAppStickerIdType,
WhatsAppStickerUrlType,
WhatsAppContext,
} from '../../types';
/**
* Represents a sticker message for WhatsApp.
*
* @group WhatsApp
*/
export class WhatsAppSticker
extends AbstractMessage
implements WhatsAppStickerParams
{
public channel: 'whatsapp';
public messageType: 'sticker';
public sticker: WhatsAppStickerIdType | WhatsAppStickerUrlType;
public context?: WhatsAppContext;
/**
* Send a sticker message to a WhatsApp user.
*
* @param {WhatsAppStickerParams} params - The parameters for creating a WhatsApp sticker message.
* @example
* Send a sticker message with a sticker ID:
* ```ts
* import { WhatsAppSticker } from '@vonage/messages';
*
* const { messageUUID } = await messagesClient.send(new WhatsAppSticker({
* to: TO_NUMBER,
* from: FROM_NUMBER,
* sticker: {
* id: '0-0',
* },
* clientRef: 'my-personal-reference',
* }));
*
* console.log(`Message sent successfully with UUID ${messageUUID}`);
* ```
*
* @example
* Send a sticker message with a sticker URL:
* ```ts
* import { WhatsAppSticker } from '@vonage/messages';
*
* const { messageUUID } = await messagesClient.send(new WhatsAppSticker({
* to: TO_NUMBER,
* from: FROM_NUMBER,
* sticker: {
* url: 'https://example.com/sticker.png',
* },
* clientRef: 'my-personal-reference',
* }));
*
* console.log(`Message sent successfully with UUID ${messageUUID}`);
* ```
*/
public constructor(params: WhatsAppStickerParams) {
super(params);
this.sticker = params.sticker;
this.channel = 'whatsapp';
this.messageType = 'sticker';
if (params.context) {
this.context = params.context;
}
}
}