-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathgithub-user.model.ts
More file actions
82 lines (76 loc) · 1.74 KB
/
github-user.model.ts
File metadata and controls
82 lines (76 loc) · 1.74 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
78
79
80
81
82
import { Group } from './github/group.interface';
/**
* Represents raw data returned from the GitHub API about a user.
*/
export interface RawGithubUser {
avatar_url: string;
created_at: string;
html_url: string;
login: string;
name: string;
node_id: string;
two_factor_authentication: boolean;
site_admin: false;
type: string;
updated_at: string;
url: string;
}
/**
* Represents a GitHub user in WATcher, used for authentication
* of user as well as representing assignees for issues/PRs.
*/
export class GithubUser implements RawGithubUser, Group {
static NO_ASSIGNEE: GithubUser = new GithubUser({
avatar_url: '',
created_at: '',
html_url: '',
login: 'Unassigned',
name: '',
node_id: '',
two_factor_authentication: false,
site_admin: false,
type: '',
updated_at: '',
url: ''
});
avatar_url: string;
created_at: string;
html_url: string;
login: string;
name: string;
node_id: string;
two_factor_authentication: boolean;
site_admin: false;
type: string;
updated_at: string;
url: string;
constructor(rawData: RawGithubUser) {
Object.assign(this, rawData);
}
/*
This method is used to enable comparisons between
a Group and the filtering criteria, which is stored
as a string, in RepoItemsDataTable.ts
*/
static fromUsername(username: string) {
return new GithubUser({
login: username,
avatar_url: '',
created_at: '',
html_url: '',
name: '',
node_id: '',
two_factor_authentication: false,
site_admin: false,
type: '',
updated_at: '',
url: ''
});
}
equals(other: any) {
if (!(other instanceof GithubUser)) {
return false;
}
return this.login === other.login;
}
}