-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
184 lines (162 loc) · 4.74 KB
/
index.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import {IComments} from './api/i-comments';
import {IContributors} from './api/i-contributors';
import {IFiles} from './api/i-files';
import {IKeys} from './api/i-keys';
import {ILanguages} from './api/i-languages';
import {IProjects} from './api/i-projects';
import {IScreenshots} from './api/i-screenshots';
import {ISnapshots} from './api/i-snapshots';
import {ITasks} from './api/i-tasks';
import {ITeamUsers} from './api/i-team-users';
import {ITeams} from './api/i-teams';
import {ITranslations} from './api/i-translations';
import {IRequest} from './internal/i-request';
import {IOptions} from './params/i-options';
import {Comments} from './implementation/comments';
import {Contributors} from './implementation/contributors';
import {Files} from './implementation/files';
import {Keys} from './implementation/keys';
import {Languages} from './implementation/languages';
import {Projects} from './implementation/projects';
import {Screenshots} from './implementation/screenshots';
import {Snapshots} from './implementation/snapshots';
import {Tasks} from './implementation/tasks';
import {TeamUsers} from './implementation/team-users';
import {Teams} from './implementation/teams';
import {Translations} from './implementation/translations';
import {Request} from './internal/request';
export class LokaliseAPI {
private _comments: IComments;
private _contributors: IContributors;
private _files: IFiles;
private _keys: IKeys;
private _languages: ILanguages;
private _projects: IProjects;
private _screenshots: IScreenshots;
private _snapshots: ISnapshots;
private _tasks: ITasks;
private _teamUsers: ITeamUsers;
private _teams: ITeams;
private _translations: ITranslations;
private readonly BASE_URL: string = 'https://api.lokalise.co/api2';
private readonly TIMEOUT: number = 10000;
private readonly RETRY: number = 2;
private request: IRequest;
constructor(options: IOptions) {
this.request = new Request(this.parseOptions(options));
this._comments = new Comments(this.request);
this._contributors = new Contributors(this.request);
this._files = new Files(this.request);
this._keys = new Keys(this.request);
this._languages = new Languages(this.request);
this._projects = new Projects(this.request);
this._screenshots = new Screenshots(this.request);
this._snapshots = new Snapshots(this.request);
this._tasks = new Tasks(this.request);
this._teamUsers = new TeamUsers(this.request);
this._teams = new Teams(this.request);
this._translations = new Translations(this.request);
}
/**
* @readonly
* @returns <IComments>
* @memberof LokaliseAPI
*/
public get comments() {
return this._comments;
}
/**
* @readonly
* @returns <IContributors>
* @memberof LokaliseAPI
*/
public get contributors() {
return this._contributors;
}
/**
* @readonly
* @returns <IFiles>
* @memberof LokaliseAPI
*/
public get files() {
return this._files;
}
/**
* @readonly
* @returns <IKeys>
* @memberof LokaliseAPI
*/
public get keys() {
return this._keys;
}
/**
* @readonly
* @returns <ILanguages>
* @memberof LokaliseAPI
*/
public get languages() {
return this._languages;
}
/**
* @readonly
* @returns <IProjects>
* @memberof LokaliseAPI
*/
public get projects() {
return this._projects;
}
/**
* @readonly
* @returns <IScreenshots>
* @memberof LokaliseAPI
*/
public get screenshots() {
return this._screenshots;
}
/**
* @readonly
* @returns <ISnapshots>
* @memberof LokaliseAPI
*/
public get snapshots() {
return this._snapshots;
}
/**
* @readonly
* @returns <ITasks>
* @memberof LokaliseAPI
*/
public get tasks() {
return this._tasks;
}
/**
* @readonly
* @returns <ITeamUsers>
* @memberof LokaliseAPI
*/
public get teamUsers() {
return this._teamUsers;
}
/**
* @readonly
* @returns <ITeams>
* @memberof LokaliseAPI
*/
public get teams() {
return this._teams;
}
/**
* @readonly
* @returns <ITranslations>
* @memberof LokaliseAPI
*/
public get translations() {
return this._translations;
}
private parseOptions(options: IOptions): IOptions {
const baseUrl = options.baseUrl || this.BASE_URL;
const timeout = options.timeout || this.TIMEOUT;
const retry = options.retry || this.RETRY;
return <IOptions>{token: options.token, baseUrl, timeout, retry};
}
}