Basic Chat and Message model implementation

This commit is contained in:
Pedro Lopez 2019-02-17 21:14:31 -04:00
commit 6442469437

View file

@ -2,8 +2,6 @@
const Base = require('./Base');
// TODO
/**
* Represents a Chat on WhatsApp
* @extends {Base}
@ -12,7 +10,28 @@ class Chat extends Base {
constructor(client, data) {
super(client);
if(data) this._patch(data);
}
_patch(data) {
this.id = data.id;
this.isGroup = data.isGroup;
this.isReadOnly = data.isReadOnly;
this.name = data.name;
this.unreadCount = data.unreadCount;
this.timestamp = data.t;
}
sendMessage(message) {
return this.client.sendMessage(this.id._serialized, message);
}
static get extraFields() {
return [
'formattedTitle',
'isGroup'
];
}
}