-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUser.ts
More file actions
77 lines (67 loc) · 1.57 KB
/
User.ts
File metadata and controls
77 lines (67 loc) · 1.57 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
export class User {
private _name: string;
private _netId: string;
private _apiKey: string;
private _website: string;
private _github: string;
private _isAdmin: boolean;
private _email: string;
private _graceDays: number;
constructor(name: string, netId: string, apiKey: string, website: string, github: string, email: string, graceDays: number, isAdmin: boolean) {
this._netId = netId;
this._name = name;
this._apiKey = apiKey;
this._website = website;
this._github = github;
this._email = email;
this._graceDays = graceDays;
this._isAdmin = isAdmin;
}
get name(): string {
return this._name;
}
get netId(): string {
return this._netId;
}
get apiKey(): string {
return this._apiKey;
}
get isAdmin(): boolean {
return this._isAdmin;
}
get website(): string {
return this._website;
}
get github(): string {
return this._github;
}
get email(): string {
return this._email;
}
get graceDays(): number {
return this._graceDays;
}
static fromJson(json: JSON): User {
interface UserJson {
_name: string;
_netId: string;
_apiKey: string;
_website: string;
_github: string;
_email: string;
_graceDays: number;
_isAdmin: boolean;
}
const jsonObject: UserJson = json as unknown as UserJson;
return new User(
jsonObject._name,
jsonObject._netId,
jsonObject._apiKey,
jsonObject._website,
jsonObject._github,
jsonObject._email,
jsonObject._graceDays,
jsonObject._isAdmin
);
}
}