Skip to content

Commit 9ac0ae1

Browse files
authored
Updated client according to API (#22)
* Updated APIs
1 parent a025596 commit 9ac0ae1

File tree

15 files changed

+388
-274
lines changed

15 files changed

+388
-274
lines changed

package-lock.json

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
],
2525
"license": "MIT",
2626
"devDependencies": {
27+
"@types/node": "^12.0.10",
2728
"@types/jest": "^24.0.15",
2829
"@types/nock": "^10.0.3",
2930
"@typescript-eslint/eslint-plugin": "^2.3.1",
@@ -42,7 +43,6 @@
4243
"jest-junit": "^8.0.0"
4344
},
4445
"dependencies": {
45-
"@types/node": "^12.0.10",
4646
"axios": "^0.19.0"
4747
},
4848
"husky": {

src/glossaries/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@ export class Glossaries extends CrowdinApi {
130130
return this.post(url, request, this.defaultConfig());
131131
}
132132

133+
/**
134+
* @param glossaryId glossary identifier
135+
* @param languageId languageId identifier
136+
* @param translationOfTermId term translation identifier
137+
*/
138+
clearGlossary(
139+
glossaryId: number,
140+
languageId?: number,
141+
translationOfTermId?: number,
142+
): Promise<ResponseObject<GlossariesModel.Term>> {
143+
let url = `${this.url}/glossaries/${glossaryId}/terms`;
144+
url = this.addQueryParam(url, 'languageId', languageId);
145+
url = this.addQueryParam(url, 'translationOfTermId', translationOfTermId);
146+
return this.delete(url, this.defaultConfig());
147+
}
148+
133149
/**
134150
* @param glossaryId glossary identifier
135151
* @param termId term identifier

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { Tasks } from './tasks';
1313
import { TranslationMemory } from './translationMemory';
1414
import { Webhooks } from './webhooks';
1515
import { MachineTranslation } from './machineTranslation';
16-
import { Notifications } from './notifications';
1716

1817
export * from './core';
1918
export * from './sourceFiles';
@@ -30,7 +29,6 @@ export * from './tasks';
3029
export * from './translationMemory';
3130
export * from './webhooks';
3231
export * from './machineTranslation';
33-
export * from './notifications';
3432

3533
export default class Client {
3634
readonly sourceFilesApi: SourceFiles;
@@ -47,7 +45,6 @@ export default class Client {
4745
readonly translationMemoryApi: TranslationMemory;
4846
readonly webhooksApi: Webhooks;
4947
readonly machineTranslationApi: MachineTranslation;
50-
readonly notificationsApi: Notifications;
5148

5249
constructor(credentials: Credentials, config?: ClientConfig) {
5350
this.sourceFilesApi = new SourceFiles(credentials, config);
@@ -64,6 +61,5 @@ export default class Client {
6461
this.translationMemoryApi = new TranslationMemory(credentials, config);
6562
this.webhooksApi = new Webhooks(credentials, config);
6663
this.machineTranslationApi = new MachineTranslation(credentials, config);
67-
this.notificationsApi = new Notifications(credentials, config);
6864
}
6965
}

src/languages/index.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CrowdinApi, ResponseList, ResponseObject } from '../core';
1+
import { CrowdinApi, ResponseList, ResponseObject, PatchRequest } from '../core';
22

33
export class Languages extends CrowdinApi {
44
/**
@@ -12,13 +12,38 @@ export class Languages extends CrowdinApi {
1212
return this.get(url, this.defaultConfig());
1313
}
1414

15+
/**
16+
* @param request request body
17+
*/
18+
addCustomLanguage(request: LanguagesModel.AddLanguageRequest): Promise<ResponseObject<LanguagesModel.Language>> {
19+
const url = `${this.url}/languages`;
20+
return this.post(url, request, this.defaultConfig());
21+
}
22+
1523
/**
1624
* @param languageId language identifier
1725
*/
1826
getLanguage(languageId: number): Promise<ResponseObject<LanguagesModel.Language>> {
1927
const url = `${this.url}/languages/${languageId}`;
2028
return this.get(url, this.defaultConfig());
2129
}
30+
31+
/**
32+
* @param languageId language identifier
33+
*/
34+
deleteCustomLanguage(languageId: number): Promise<void> {
35+
const url = `${this.url}/languages/${languageId}`;
36+
return this.delete(url, this.defaultConfig());
37+
}
38+
39+
/**
40+
* @param languageId language identifier
41+
* @param request request body
42+
*/
43+
editCustomLanguage(languageId: number, request: PatchRequest[]): Promise<ResponseObject<LanguagesModel.Language>> {
44+
const url = `${this.url}/languages/${languageId}`;
45+
return this.patch(url, request, this.defaultConfig());
46+
}
2247
}
2348

2449
export namespace LanguagesModel {
@@ -45,6 +70,17 @@ export namespace LanguagesModel {
4570
osxLocale: string;
4671
}
4772

73+
export interface AddLanguageRequest {
74+
name: string;
75+
dialectOf?: number;
76+
code: string;
77+
localeCode: string;
78+
twoLettersCode?: string;
79+
threeLettersCode: string;
80+
textDirection: TextDirection;
81+
pluralCategoryNames: string[];
82+
}
83+
4884
export enum TextDirection {
4985
LTR = 'ltr',
5086
RTL = 'rtl',

src/notifications/index.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)