UNPKG

682 BJavaScriptView Raw
1import {cached, defineAssoc} from "./decorators.js";
2import {lib, Collection, RallyBase} from "./rally-tools.js";
3
4class User extends RallyBase{
5 constructor({data, remote}){
6 super();
7 this.data = data;
8 this.meta = {};
9 this.remote = remote;
10 }
11 chalkPrint(pad=false){
12 let id = String("U-" + this.id)
13 if(pad) id = id.padStart(7);
14 return chalk`{green ${id}}: {blue ${this.name}}`;
15 }
16}
17
18defineAssoc(User, "id", "data.id");
19defineAssoc(User, "name", "data.attributes.name");
20defineAssoc(User, "email", "data.attributes.email");
21defineAssoc(User, "remote", "meta.remote");
22User.endpoint = "users"
23
24export default User;