user.model.ts
980 Bytes
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
/**
* Created by tuukka on 15/02/17.
*/
// vim magic: %s/^\s*\w\+\s\+\(\w\+\)\s\+\(\w\+\)\s*.*;$/ \2: \L\1;/
import gql from 'graphql-tag';
export enum UserGender {
MALE,
FEMALE,
UNSPECIFIED
}
export class User {
static fragments = gql`
fragment userPrimitives on User {
address
allergiesFreetext
birthday
email
firstnames
gender
id:
lastname
login
nick
phone
town
shirtSize
town
zip
}
`;
nick: string;
login: string;
id: number;
firstname: string;
lastname: string;
password: string;
birthday: Date;
gender: UserGender;
phone: string;
email: string;
streetAddress: string;
zip: string;
town: string;
public isAnonymous(): boolean {
return !this.login || this.login === "anonymous";
}
public static NewUser(user) {
if(user === null)
return new User();
return Object.assign(new User(), user);
}
}