@another-trial/whatsapp-web.js 1.34.1 → 1.34.5-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +2 -2
- package/CODE_OF_CONDUCT.md +133 -133
- package/LICENSE +201 -201
- package/README.md +155 -185
- package/example.js +706 -690
- package/index.d.ts +2259 -2202
- package/index.js +35 -35
- package/package.json +59 -59
- package/shell.js +36 -36
- package/src/Client.js +2533 -2361
- package/src/authStrategies/BaseAuthStrategy.js +26 -26
- package/src/authStrategies/LocalAuth.js +58 -58
- package/src/authStrategies/NoAuth.js +11 -11
- package/src/authStrategies/RemoteAuth.js +210 -210
- package/src/factories/ChatFactory.js +21 -21
- package/src/factories/ContactFactory.js +15 -15
- package/src/structures/Base.js +21 -21
- package/src/structures/Broadcast.js +69 -69
- package/src/structures/BusinessContact.js +20 -20
- package/src/structures/Buttons.js +81 -81
- package/src/structures/Call.js +75 -75
- package/src/structures/Channel.js +382 -382
- package/src/structures/Chat.js +329 -299
- package/src/structures/ClientInfo.js +70 -70
- package/src/structures/Contact.js +215 -208
- package/src/structures/GroupChat.js +485 -485
- package/src/structures/GroupNotification.js +104 -104
- package/src/structures/Label.js +49 -49
- package/src/structures/List.js +79 -79
- package/src/structures/Location.js +61 -61
- package/src/structures/Message.js +787 -747
- package/src/structures/MessageMedia.js +111 -111
- package/src/structures/Order.js +51 -51
- package/src/structures/Payment.js +79 -79
- package/src/structures/Poll.js +44 -44
- package/src/structures/PollVote.js +75 -75
- package/src/structures/PrivateChat.js +12 -12
- package/src/structures/PrivateContact.js +12 -12
- package/src/structures/Product.js +67 -67
- package/src/structures/ProductMetadata.js +24 -24
- package/src/structures/Reaction.js +68 -68
- package/src/structures/ScheduledEvent.js +71 -71
- package/src/structures/index.js +27 -27
- package/src/util/Constants.js +186 -183
- package/src/util/Injected/AuthStore/AuthStore.js +16 -16
- package/src/util/Injected/AuthStore/LegacyAuthStore.js +21 -21
- package/src/util/Injected/LegacyStore.js +145 -145
- package/src/util/Injected/Store.js +263 -233
- package/src/util/Injected/Utils.js +1221 -1169
- package/src/util/InterfaceController.js +126 -126
- package/src/util/Puppeteer.js +23 -23
- package/src/util/Util.js +186 -186
- package/src/webCache/LocalWebCache.js +40 -40
- package/src/webCache/RemoteWebCache.js +39 -39
- package/src/webCache/WebCache.js +13 -13
- package/src/webCache/WebCacheFactory.js +19 -19
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const mime = require('mime');
|
|
6
|
-
const fetch = require('node-fetch');
|
|
7
|
-
const { URL } = require('url');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Media attached to a message
|
|
11
|
-
* @param {string} mimetype MIME type of the attachment
|
|
12
|
-
* @param {string} data Base64-encoded data of the file
|
|
13
|
-
* @param {?string} filename Document file name. Value can be null
|
|
14
|
-
* @param {?number} filesize Document file size in bytes. Value can be null
|
|
15
|
-
*/
|
|
16
|
-
class MessageMedia {
|
|
17
|
-
constructor(mimetype, data, filename, filesize) {
|
|
18
|
-
/**
|
|
19
|
-
* MIME type of the attachment
|
|
20
|
-
* @type {string}
|
|
21
|
-
*/
|
|
22
|
-
this.mimetype = mimetype;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Base64 encoded data that represents the file
|
|
26
|
-
* @type {string}
|
|
27
|
-
*/
|
|
28
|
-
this.data = data;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Document file name. Value can be null
|
|
32
|
-
* @type {?string}
|
|
33
|
-
*/
|
|
34
|
-
this.filename = filename;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Document file size in bytes. Value can be null
|
|
38
|
-
* @type {?number}
|
|
39
|
-
*/
|
|
40
|
-
this.filesize = filesize;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Creates a MessageMedia instance from a local file path
|
|
45
|
-
* @param {string} filePath
|
|
46
|
-
* @returns {MessageMedia}
|
|
47
|
-
*/
|
|
48
|
-
static fromFilePath(filePath) {
|
|
49
|
-
const b64data = fs.readFileSync(filePath, {encoding: 'base64'});
|
|
50
|
-
const mimetype = mime.getType(filePath);
|
|
51
|
-
const filename = path.basename(filePath);
|
|
52
|
-
|
|
53
|
-
return new MessageMedia(mimetype, b64data, filename);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Creates a MessageMedia instance from a URL
|
|
58
|
-
* @param {string} url
|
|
59
|
-
* @param {Object} [options]
|
|
60
|
-
* @param {boolean} [options.unsafeMime=false]
|
|
61
|
-
* @param {string} [options.filename]
|
|
62
|
-
* @param {object} [options.client]
|
|
63
|
-
* @param {object} [options.reqOptions]
|
|
64
|
-
* @param {number} [options.reqOptions.size=0]
|
|
65
|
-
* @returns {Promise<MessageMedia>}
|
|
66
|
-
*/
|
|
67
|
-
static async fromUrl(url, options = {}) {
|
|
68
|
-
const pUrl = new URL(url);
|
|
69
|
-
let mimetype = mime.getType(pUrl.pathname);
|
|
70
|
-
|
|
71
|
-
if (!mimetype && !options.unsafeMime)
|
|
72
|
-
throw new Error('Unable to determine MIME type using URL. Set unsafeMime to true to download it anyway.');
|
|
73
|
-
|
|
74
|
-
async function fetchData (url, options) {
|
|
75
|
-
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
|
76
|
-
const response = await fetch(url, reqOptions);
|
|
77
|
-
const mime = response.headers.get('Content-Type');
|
|
78
|
-
const size = response.headers.get('Content-Length');
|
|
79
|
-
|
|
80
|
-
const contentDisposition = response.headers.get('Content-Disposition');
|
|
81
|
-
const name = contentDisposition ? contentDisposition.match(/((?<=filename=")(.*)(?="))/) : null;
|
|
82
|
-
|
|
83
|
-
let data = '';
|
|
84
|
-
if (response.buffer) {
|
|
85
|
-
data = (await response.buffer()).toString('base64');
|
|
86
|
-
} else {
|
|
87
|
-
const bArray = new Uint8Array(await response.arrayBuffer());
|
|
88
|
-
bArray.forEach((b) => {
|
|
89
|
-
data += String.fromCharCode(b);
|
|
90
|
-
});
|
|
91
|
-
data = btoa(data);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return { data, mime, name, size };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const res = options.client
|
|
98
|
-
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
|
99
|
-
: (await fetchData(url, options.reqOptions));
|
|
100
|
-
|
|
101
|
-
const filename = options.filename ||
|
|
102
|
-
(res.name ? res.name[0] : (pUrl.pathname.split('/').pop() || 'file'));
|
|
103
|
-
|
|
104
|
-
if (!mimetype)
|
|
105
|
-
mimetype = res.mime;
|
|
106
|
-
|
|
107
|
-
return new MessageMedia(mimetype, res.data, filename, res.size || null);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
module.exports = MessageMedia;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const mime = require('mime');
|
|
6
|
+
const fetch = require('node-fetch');
|
|
7
|
+
const { URL } = require('url');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Media attached to a message
|
|
11
|
+
* @param {string} mimetype MIME type of the attachment
|
|
12
|
+
* @param {string} data Base64-encoded data of the file
|
|
13
|
+
* @param {?string} filename Document file name. Value can be null
|
|
14
|
+
* @param {?number} filesize Document file size in bytes. Value can be null
|
|
15
|
+
*/
|
|
16
|
+
class MessageMedia {
|
|
17
|
+
constructor(mimetype, data, filename, filesize) {
|
|
18
|
+
/**
|
|
19
|
+
* MIME type of the attachment
|
|
20
|
+
* @type {string}
|
|
21
|
+
*/
|
|
22
|
+
this.mimetype = mimetype;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Base64 encoded data that represents the file
|
|
26
|
+
* @type {string}
|
|
27
|
+
*/
|
|
28
|
+
this.data = data;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Document file name. Value can be null
|
|
32
|
+
* @type {?string}
|
|
33
|
+
*/
|
|
34
|
+
this.filename = filename;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Document file size in bytes. Value can be null
|
|
38
|
+
* @type {?number}
|
|
39
|
+
*/
|
|
40
|
+
this.filesize = filesize;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Creates a MessageMedia instance from a local file path
|
|
45
|
+
* @param {string} filePath
|
|
46
|
+
* @returns {MessageMedia}
|
|
47
|
+
*/
|
|
48
|
+
static fromFilePath(filePath) {
|
|
49
|
+
const b64data = fs.readFileSync(filePath, {encoding: 'base64'});
|
|
50
|
+
const mimetype = mime.getType(filePath);
|
|
51
|
+
const filename = path.basename(filePath);
|
|
52
|
+
|
|
53
|
+
return new MessageMedia(mimetype, b64data, filename);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Creates a MessageMedia instance from a URL
|
|
58
|
+
* @param {string} url
|
|
59
|
+
* @param {Object} [options]
|
|
60
|
+
* @param {boolean} [options.unsafeMime=false]
|
|
61
|
+
* @param {string} [options.filename]
|
|
62
|
+
* @param {object} [options.client]
|
|
63
|
+
* @param {object} [options.reqOptions]
|
|
64
|
+
* @param {number} [options.reqOptions.size=0]
|
|
65
|
+
* @returns {Promise<MessageMedia>}
|
|
66
|
+
*/
|
|
67
|
+
static async fromUrl(url, options = {}) {
|
|
68
|
+
const pUrl = new URL(url);
|
|
69
|
+
let mimetype = mime.getType(pUrl.pathname);
|
|
70
|
+
|
|
71
|
+
if (!mimetype && !options.unsafeMime)
|
|
72
|
+
throw new Error('Unable to determine MIME type using URL. Set unsafeMime to true to download it anyway.');
|
|
73
|
+
|
|
74
|
+
async function fetchData (url, options) {
|
|
75
|
+
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
|
76
|
+
const response = await fetch(url, reqOptions);
|
|
77
|
+
const mime = response.headers.get('Content-Type');
|
|
78
|
+
const size = response.headers.get('Content-Length');
|
|
79
|
+
|
|
80
|
+
const contentDisposition = response.headers.get('Content-Disposition');
|
|
81
|
+
const name = contentDisposition ? contentDisposition.match(/((?<=filename=")(.*)(?="))/) : null;
|
|
82
|
+
|
|
83
|
+
let data = '';
|
|
84
|
+
if (response.buffer) {
|
|
85
|
+
data = (await response.buffer()).toString('base64');
|
|
86
|
+
} else {
|
|
87
|
+
const bArray = new Uint8Array(await response.arrayBuffer());
|
|
88
|
+
bArray.forEach((b) => {
|
|
89
|
+
data += String.fromCharCode(b);
|
|
90
|
+
});
|
|
91
|
+
data = btoa(data);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return { data, mime, name, size };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const res = options.client
|
|
98
|
+
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
|
|
99
|
+
: (await fetchData(url, options.reqOptions));
|
|
100
|
+
|
|
101
|
+
const filename = options.filename ||
|
|
102
|
+
(res.name ? res.name[0] : (pUrl.pathname.split('/').pop() || 'file'));
|
|
103
|
+
|
|
104
|
+
if (!mimetype)
|
|
105
|
+
mimetype = res.mime;
|
|
106
|
+
|
|
107
|
+
return new MessageMedia(mimetype, res.data, filename, res.size || null);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module.exports = MessageMedia;
|
package/src/structures/Order.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const Base = require('./Base');
|
|
4
|
-
const Product = require('./Product');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Represents a Order on WhatsApp
|
|
8
|
-
* @extends {Base}
|
|
9
|
-
*/
|
|
10
|
-
class Order extends Base {
|
|
11
|
-
constructor(client, data) {
|
|
12
|
-
super(client);
|
|
13
|
-
|
|
14
|
-
if (data) this._patch(data);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
_patch(data) {
|
|
18
|
-
/**
|
|
19
|
-
* List of products
|
|
20
|
-
* @type {Array<Product>}
|
|
21
|
-
*/
|
|
22
|
-
if (data.products) {
|
|
23
|
-
this.products = data.products.map(product => new Product(this.client, product));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Order Subtotal
|
|
27
|
-
* @type {string}
|
|
28
|
-
*/
|
|
29
|
-
this.subtotal = data.subtotal;
|
|
30
|
-
/**
|
|
31
|
-
* Order Total
|
|
32
|
-
* @type {string}
|
|
33
|
-
*/
|
|
34
|
-
this.total = data.total;
|
|
35
|
-
/**
|
|
36
|
-
* Order Currency
|
|
37
|
-
* @type {string}
|
|
38
|
-
*/
|
|
39
|
-
this.currency = data.currency;
|
|
40
|
-
/**
|
|
41
|
-
* Order Created At
|
|
42
|
-
* @type {number}
|
|
43
|
-
*/
|
|
44
|
-
this.createdAt = data.createdAt;
|
|
45
|
-
|
|
46
|
-
return super._patch(data);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Base = require('./Base');
|
|
4
|
+
const Product = require('./Product');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a Order on WhatsApp
|
|
8
|
+
* @extends {Base}
|
|
9
|
+
*/
|
|
10
|
+
class Order extends Base {
|
|
11
|
+
constructor(client, data) {
|
|
12
|
+
super(client);
|
|
13
|
+
|
|
14
|
+
if (data) this._patch(data);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_patch(data) {
|
|
18
|
+
/**
|
|
19
|
+
* List of products
|
|
20
|
+
* @type {Array<Product>}
|
|
21
|
+
*/
|
|
22
|
+
if (data.products) {
|
|
23
|
+
this.products = data.products.map(product => new Product(this.client, product));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Order Subtotal
|
|
27
|
+
* @type {string}
|
|
28
|
+
*/
|
|
29
|
+
this.subtotal = data.subtotal;
|
|
30
|
+
/**
|
|
31
|
+
* Order Total
|
|
32
|
+
* @type {string}
|
|
33
|
+
*/
|
|
34
|
+
this.total = data.total;
|
|
35
|
+
/**
|
|
36
|
+
* Order Currency
|
|
37
|
+
* @type {string}
|
|
38
|
+
*/
|
|
39
|
+
this.currency = data.currency;
|
|
40
|
+
/**
|
|
41
|
+
* Order Created At
|
|
42
|
+
* @type {number}
|
|
43
|
+
*/
|
|
44
|
+
this.createdAt = data.createdAt;
|
|
45
|
+
|
|
46
|
+
return super._patch(data);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
52
|
module.exports = Order;
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
const Base = require('./Base');
|
|
2
|
-
|
|
3
|
-
class Payment extends Base {
|
|
4
|
-
constructor(client, data) {
|
|
5
|
-
super(client);
|
|
6
|
-
|
|
7
|
-
if (data) this._patch(data);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
_patch(data) {
|
|
11
|
-
/**
|
|
12
|
-
* The payment Id
|
|
13
|
-
* @type {object}
|
|
14
|
-
*/
|
|
15
|
-
this.id = data.id;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The payment currency
|
|
19
|
-
* @type {string}
|
|
20
|
-
*/
|
|
21
|
-
this.paymentCurrency = data.paymentCurrency;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The payment ammount ( R$ 1.00 = 1000 )
|
|
25
|
-
* @type {number}
|
|
26
|
-
*/
|
|
27
|
-
this.paymentAmount1000 = data.paymentAmount1000;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The payment receiver
|
|
31
|
-
* @type {object}
|
|
32
|
-
*/
|
|
33
|
-
this.paymentMessageReceiverJid = data.paymentMessageReceiverJid;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The payment transaction timestamp
|
|
37
|
-
* @type {number}
|
|
38
|
-
*/
|
|
39
|
-
this.paymentTransactionTimestamp = data.paymentTransactionTimestamp;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The paymentStatus
|
|
43
|
-
*
|
|
44
|
-
* Possible Status
|
|
45
|
-
* 0:UNKNOWN_STATUS
|
|
46
|
-
* 1:PROCESSING
|
|
47
|
-
* 2:SENT
|
|
48
|
-
* 3:NEED_TO_ACCEPT
|
|
49
|
-
* 4:COMPLETE
|
|
50
|
-
* 5:COULD_NOT_COMPLETE
|
|
51
|
-
* 6:REFUNDED
|
|
52
|
-
* 7:EXPIRED
|
|
53
|
-
* 8:REJECTED
|
|
54
|
-
* 9:CANCELLED
|
|
55
|
-
* 10:WAITING_FOR_PAYER
|
|
56
|
-
* 11:WAITING
|
|
57
|
-
*
|
|
58
|
-
* @type {number}
|
|
59
|
-
*/
|
|
60
|
-
this.paymentStatus = data.paymentStatus;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Integer that represents the payment Text
|
|
64
|
-
* @type {number}
|
|
65
|
-
*/
|
|
66
|
-
this.paymentTxnStatus = data.paymentTxnStatus;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The note sent with the payment
|
|
70
|
-
* @type {string}
|
|
71
|
-
*/
|
|
72
|
-
this.paymentNote = !data.paymentNoteMsg ? undefined : data.paymentNoteMsg.body ? data.paymentNoteMsg.body : undefined ;
|
|
73
|
-
|
|
74
|
-
return super._patch(data);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
module.exports = Payment;
|
|
1
|
+
const Base = require('./Base');
|
|
2
|
+
|
|
3
|
+
class Payment extends Base {
|
|
4
|
+
constructor(client, data) {
|
|
5
|
+
super(client);
|
|
6
|
+
|
|
7
|
+
if (data) this._patch(data);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
_patch(data) {
|
|
11
|
+
/**
|
|
12
|
+
* The payment Id
|
|
13
|
+
* @type {object}
|
|
14
|
+
*/
|
|
15
|
+
this.id = data.id;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The payment currency
|
|
19
|
+
* @type {string}
|
|
20
|
+
*/
|
|
21
|
+
this.paymentCurrency = data.paymentCurrency;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The payment ammount ( R$ 1.00 = 1000 )
|
|
25
|
+
* @type {number}
|
|
26
|
+
*/
|
|
27
|
+
this.paymentAmount1000 = data.paymentAmount1000;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The payment receiver
|
|
31
|
+
* @type {object}
|
|
32
|
+
*/
|
|
33
|
+
this.paymentMessageReceiverJid = data.paymentMessageReceiverJid;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The payment transaction timestamp
|
|
37
|
+
* @type {number}
|
|
38
|
+
*/
|
|
39
|
+
this.paymentTransactionTimestamp = data.paymentTransactionTimestamp;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The paymentStatus
|
|
43
|
+
*
|
|
44
|
+
* Possible Status
|
|
45
|
+
* 0:UNKNOWN_STATUS
|
|
46
|
+
* 1:PROCESSING
|
|
47
|
+
* 2:SENT
|
|
48
|
+
* 3:NEED_TO_ACCEPT
|
|
49
|
+
* 4:COMPLETE
|
|
50
|
+
* 5:COULD_NOT_COMPLETE
|
|
51
|
+
* 6:REFUNDED
|
|
52
|
+
* 7:EXPIRED
|
|
53
|
+
* 8:REJECTED
|
|
54
|
+
* 9:CANCELLED
|
|
55
|
+
* 10:WAITING_FOR_PAYER
|
|
56
|
+
* 11:WAITING
|
|
57
|
+
*
|
|
58
|
+
* @type {number}
|
|
59
|
+
*/
|
|
60
|
+
this.paymentStatus = data.paymentStatus;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Integer that represents the payment Text
|
|
64
|
+
* @type {number}
|
|
65
|
+
*/
|
|
66
|
+
this.paymentTxnStatus = data.paymentTxnStatus;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The note sent with the payment
|
|
70
|
+
* @type {string}
|
|
71
|
+
*/
|
|
72
|
+
this.paymentNote = !data.paymentNoteMsg ? undefined : data.paymentNoteMsg.body ? data.paymentNoteMsg.body : undefined ;
|
|
73
|
+
|
|
74
|
+
return super._patch(data);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = Payment;
|
package/src/structures/Poll.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Poll send options
|
|
5
|
-
* @typedef {Object} PollSendOptions
|
|
6
|
-
* @property {boolean} [allowMultipleAnswers=false] If false it is a single choice poll, otherwise it is a multiple choice poll (false by default)
|
|
7
|
-
* @property {?Array<number>} messageSecret The custom message secret, can be used as a poll ID. NOTE: it has to be a unique vector with a length of 32
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/** Represents a Poll on WhatsApp */
|
|
11
|
-
class Poll {
|
|
12
|
-
/**
|
|
13
|
-
* @param {string} pollName
|
|
14
|
-
* @param {Array<string>} pollOptions
|
|
15
|
-
* @param {PollSendOptions} options
|
|
16
|
-
*/
|
|
17
|
-
constructor(pollName, pollOptions, options = {}) {
|
|
18
|
-
/**
|
|
19
|
-
* The name of the poll
|
|
20
|
-
* @type {string}
|
|
21
|
-
*/
|
|
22
|
-
this.pollName = pollName.trim();
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The array of poll options
|
|
26
|
-
* @type {Array.<{name: string, localId: number}>}
|
|
27
|
-
*/
|
|
28
|
-
this.pollOptions = pollOptions.map((option, index) => ({
|
|
29
|
-
name: option.trim(),
|
|
30
|
-
localId: index
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The send options for the poll
|
|
35
|
-
* @type {PollSendOptions}
|
|
36
|
-
*/
|
|
37
|
-
this.options = {
|
|
38
|
-
allowMultipleAnswers: options.allowMultipleAnswers === true,
|
|
39
|
-
messageSecret: options.messageSecret
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
module.exports = Poll;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Poll send options
|
|
5
|
+
* @typedef {Object} PollSendOptions
|
|
6
|
+
* @property {boolean} [allowMultipleAnswers=false] If false it is a single choice poll, otherwise it is a multiple choice poll (false by default)
|
|
7
|
+
* @property {?Array<number>} messageSecret The custom message secret, can be used as a poll ID. NOTE: it has to be a unique vector with a length of 32
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Represents a Poll on WhatsApp */
|
|
11
|
+
class Poll {
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} pollName
|
|
14
|
+
* @param {Array<string>} pollOptions
|
|
15
|
+
* @param {PollSendOptions} options
|
|
16
|
+
*/
|
|
17
|
+
constructor(pollName, pollOptions, options = {}) {
|
|
18
|
+
/**
|
|
19
|
+
* The name of the poll
|
|
20
|
+
* @type {string}
|
|
21
|
+
*/
|
|
22
|
+
this.pollName = pollName.trim();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The array of poll options
|
|
26
|
+
* @type {Array.<{name: string, localId: number}>}
|
|
27
|
+
*/
|
|
28
|
+
this.pollOptions = pollOptions.map((option, index) => ({
|
|
29
|
+
name: option.trim(),
|
|
30
|
+
localId: index
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The send options for the poll
|
|
35
|
+
* @type {PollSendOptions}
|
|
36
|
+
*/
|
|
37
|
+
this.options = {
|
|
38
|
+
allowMultipleAnswers: options.allowMultipleAnswers === true,
|
|
39
|
+
messageSecret: options.messageSecret
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = Poll;
|