/
GroupProfile.ts
57 lines (45 loc) · 1.18 KB
/
GroupProfile.ts
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
import type { MachinatProfile } from '@machinat/core/base/Profiler';
import type { MarshallableInstance } from '@machinat/core/base/Marshaler';
import { LINE } from './constant';
export type LineGroupData = {
groupId: string;
groupName: string;
pictureUrl: string;
};
type GroupProfileValue = {
data: LineGroupData;
};
class LineGroupProfile
implements MachinatProfile, MarshallableInstance<GroupProfileValue>
{
static typeName = 'LineGroupProfile';
static fromJSONValue({ data }: GroupProfileValue): LineGroupProfile {
return new LineGroupProfile(data);
}
data: LineGroupData;
platform = LINE;
firstName = undefined;
lastName = undefined;
languageCode = undefined;
timeZone = undefined;
constructor(data: LineGroupData) {
this.data = data;
}
get id(): string {
return this.data.groupId;
}
get name(): string {
return this.data.groupName;
}
get avatarUrl(): undefined | string {
return this.data.pictureUrl;
}
toJSONValue(): GroupProfileValue {
return { data: this.data };
}
// eslint-disable-next-line class-methods-use-this
typeName(): string {
return LineGroupProfile.typeName;
}
}
export default LineGroupProfile;