Skip to content

Commit e3b81f4

Browse files
committed
Added id support for stickers and videos
Videos also got caption support, even though it isn't mentioned in the official docs...
1 parent c120b7e commit e3b81f4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "whatsapp-api-js",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "A Whatsapp Official API helper for Node.js",
55
"main": "index.js",
66
"scripts": {

types/media.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Image extends Media {
7979
* Create a Image object for the API
8080
*
8181
* @param {String} image The image file's link or id
82-
* @param {Boolean} isItAnID Whether document is an id (true) or a link (false)
82+
* @param {Boolean} isItAnID Whether image is an id (true) or a link (false)
8383
* @param {String} [caption] Describes the specified image media
8484
*/
8585
constructor(image, isItAnID = false, caption) {
@@ -99,27 +99,32 @@ class Sticker extends Media {
9999
* Create a Sticker object for the API
100100
*
101101
* @param {String} sticker The sticker file's link
102+
* @param {Boolean} isItAnID Whether sticker is an id (true) or a link (false)
102103
*/
103-
constructor(sticker) {
104-
if (!sticker) throw new Error("Sticker must have a sticker link");
105-
super("sticker", sticker);
104+
constructor(sticker, isItAnID = false) {
105+
if (!sticker) throw new Error("Sticker must have a sticker link or id");
106+
super("sticker", sticker, isItAnID);
106107
}
107108
}
108109

109110
/**
110111
* Video API component
111112
*
112113
* @extends Media
114+
* @property {String} [caption] The file's caption
113115
*/
114116
class Video extends Media {
115117
/**
116118
* Create a Video object for the API
117119
*
118120
* @param {String} video The video file's link
121+
* @param {Boolean} isItAnID Whether video is an id (true) or a link (false)
122+
* @param {String} [caption] Describes the specified image media
119123
*/
120-
constructor(video) {
121-
if (!video) throw new Error("Video must have a video link");
122-
super("video", video);
124+
constructor(video, isItAnID = false, caption) {
125+
if (!video) throw new Error("Video must have a video link or id");
126+
super("video", video, isItAnID);
127+
if (caption) this.caption = caption;
123128
}
124129
}
125130

0 commit comments

Comments
 (0)