-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.js
48 lines (40 loc) · 863 Bytes
/
User.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
let TR = require('./TR');
//object User represents each user
//async User.scrape(): read User data
class User {
constructor (username) {
this._username = username;
this._contacts = [];
this._created;
}
get username () {
return this._username;
}
get created () {
return this._created;
}
get id () {
return this._id;
}
get contacts () {
let contacts = [];
for(let contact of this._contacts) {
contacts.push({
username: contact.username,
id: contact.id,
created: contact.created
});
}
return contacts;
}
//async
async scrape () {
let user = await TR.user(this._username);
let contacts = await TR.contacts(user.id);
this._id = user.id;
this._created = user.created
this._contacts = contacts;
}
}
module.exports = User;