1 | import {cached, defineAssoc} from "./decorators.js";
|
2 | import {lib, Collection, RallyBase} from "./rally-tools.js";
|
3 |
|
4 | class 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 |
|
18 | defineAssoc(User, "id", "data.id");
|
19 | defineAssoc(User, "name", "data.attributes.name");
|
20 | defineAssoc(User, "email", "data.attributes.email");
|
21 | defineAssoc(User, "remote", "meta.remote");
|
22 | User.endpoint = "users"
|
23 |
|
24 | export default User;
|