-
Notifications
You must be signed in to change notification settings - Fork 181
/
WhatsAppImage.ts
44 lines (42 loc) · 1.14 KB
/
WhatsAppImage.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
import { AbstractImageMessage } from '../AbstractImageMessage';
import { WhatsAppImageParams, WhatsAppContext } from '../../types';
/**
* Represents an image message for WhatsApp.
*
* @group WhatsApp
*/
export class WhatsAppImage
extends AbstractImageMessage
implements WhatsAppImageParams
{
public channel: 'whatsapp';
public context?: WhatsAppContext;
/**
* Sends an image message to a WhatsApp user.
*
* @param {WhatsAppImageParams} params - The parameters for creating a WhatsApp image message.
* @example
* ```ts
* import { WhatsAppImage } from '@vonage/messages';
*
* const { messageUUID } = await messagesClient.send(new WhatsAppImage({
* to: TO_NUMBER,
* from: FROM_NUMBER,
* image: {
* url: 'https://example.com/image.jpg',
* caption: 'This is an image message',
* },
* clientRef: 'my-personal-reference',
* }));
*
* console.log(`Message sent successfully with UUID ${messageUUID}`);
* ```
*/
public constructor(params: WhatsAppImageParams) {
super(params);
this.channel = 'whatsapp';
if (params.context) {
this.context = params.context;
}
}
}