Added Contact Model (#34)
This commit is contained in:
parent
b597e4a504
commit
e2351db722
4 changed files with 134 additions and 0 deletions
18
src/structures/BusinessContact.js
Normal file
18
src/structures/BusinessContact.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
const Contact = require('./Contact');
|
||||
|
||||
/**
|
||||
* Represents a Business Contact on WhatsApp
|
||||
* @extends {Contact}
|
||||
*/
|
||||
class BusinessContact extends Contact {
|
||||
_patch(data) {
|
||||
this.businessProfile = data.businessProfile;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = BusinessContact;
|
||||
35
src/structures/Contact.js
Normal file
35
src/structures/Contact.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a Contact on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Contact extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if(data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
this.id = data.id;
|
||||
this.isBusiness = data.isBusiness;
|
||||
this.isEnterprise = data.isEnterprise;
|
||||
this.labels = data.labels;
|
||||
this.name = data.name;
|
||||
this.pushname = data.pushname;
|
||||
this.sectionHeader = data.sectionHeader;
|
||||
this.shortName = data.shortName;
|
||||
this.statusMute = data.statusMute;
|
||||
this.type = data.type;
|
||||
this.verifiedLevel = data.verifiedLevel;
|
||||
this.verifiedName = data.verifiedName;
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Contact;
|
||||
|
|
@ -41,6 +41,13 @@ class Message extends Base {
|
|||
return this.client.getChatById(this._getChatId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Contact this message was sent from
|
||||
*/
|
||||
getContact() {
|
||||
return this.client.getContactById(this._getChatId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quoted message, if any
|
||||
*/
|
||||
|
|
|
|||
13
src/structures/PrivateContact.js
Normal file
13
src/structures/PrivateContact.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
const Contact = require('./Contact');
|
||||
|
||||
/**
|
||||
* Represents a Private Contact on WhatsApp
|
||||
* @extends {Contact}
|
||||
*/
|
||||
class PrivateContact extends Contact {
|
||||
|
||||
}
|
||||
|
||||
module.exports = PrivateContact;
|
||||
Loading…
Reference in a new issue