mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-17 19:26:20 +00:00
* - Get products and orders * - Get products and orders * - Eslint fixes * - Eslint fixes * allow downloading media for products * products and orders work on normal accounts Co-authored-by: Renato Jop <renato.jop@consystec-corp.com> Co-authored-by: Pedro Lopez <pedroslopez@me.com> Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
52 lines
1.0 KiB
JavaScript
52 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const Base = require('./Base');
|
|
const Product = require('./Product');
|
|
|
|
/**
|
|
* Represents a Order on WhatsApp
|
|
* @extends {Base}
|
|
*/
|
|
class Order extends Base {
|
|
constructor(client, data) {
|
|
super(client);
|
|
|
|
if (data) this._patch(data);
|
|
}
|
|
|
|
_patch(data) {
|
|
/**
|
|
* List of products
|
|
* @type {Array<Product>}
|
|
*/
|
|
if (data.products) {
|
|
this.products = data.products.map(product => new Product(this.client, product));
|
|
}
|
|
/**
|
|
* Order Subtotal
|
|
* @type {string}
|
|
*/
|
|
this.subtotal = data.subtotal;
|
|
/**
|
|
* Order Total
|
|
* @type {string}
|
|
*/
|
|
this.total = data.total;
|
|
/**
|
|
* Order Currency
|
|
* @type {string}
|
|
*/
|
|
this.currency = data.currency;
|
|
/**
|
|
* Order Created At
|
|
* @type {number}
|
|
*/
|
|
this.createdAt = data.createdAt;
|
|
|
|
return super._patch(data);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
module.exports = Order; |