-
Notifications
You must be signed in to change notification settings - Fork 4
/
Json.ts
55 lines (40 loc) Β· 1.7 KB
/
Json.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
import { AnyStringCommand, AwardsCommand, EducationCommand, LanguagesCommand, PublicationsCommand, SkillsCommand, VolunteerCommand, WorkCommand } from '../command';
import { TCommand } from '../command/types';
import { IProvider } from './types';
export class Json implements IProvider {
private data: any;
constructor(object: object) {
this.data = object;
}
getCommands(): Array<TCommand> {
let commands: Array<TCommand> = [];
if (this.data.name) {
commands.push(new AnyStringCommand('name', 'shows name', this.data.name));
}
if (this.data.bio) {
commands.push(new AnyStringCommand('bio', 'shows bio', this.data.bio));
}
if (this.data.education && this.data.education.length) {
commands.push(new EducationCommand(this.data.education));
}
if (this.data.work && this.data.work.length) {
commands.push(new WorkCommand(this.data.work));
}
if (this.data.volunteer && this.data.volunteer.length) {
commands.push(new VolunteerCommand(this.data.volunteer));
}
if (this.data.awards && this.data.awards.length) {
commands.push(new AwardsCommand(this.data.awards));
}
if (this.data.publications && this.data.publications.length) {
commands.push(new PublicationsCommand(this.data.publications));
}
if (this.data.skills && this.data.skills.length) {
commands.push(new SkillsCommand(this.data.skills));
}
if (this.data.languages && this.data.languages.length) {
commands.push(new LanguagesCommand(this.data.languages));
}
return commands;
}
}