Skip to content

Commit

Permalink
feat: api updates (#404)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
  • Loading branch information
yevheniyJ authored Jul 7, 2024
1 parent 2ebbc05 commit 2235b81
Show file tree
Hide file tree
Showing 30 changed files with 351 additions and 259 deletions.
1 change: 1 addition & 0 deletions src/clients/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export namespace ClientsModel {
name: string;
description: string;
status: 'pending' | 'confirmed' | 'rejected';
webUrl: string;
}
}
19 changes: 2 additions & 17 deletions src/distributions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,34 +119,19 @@ export class Distributions extends CrowdinApi {
export namespace DistributionsModel {
export interface Distribution {
hash: string;
exportMode: ExportMode;
name: string;
fileIds: number[];
bundleIds: number[];
format: string;
exportPattern: string;
labelIds: number[];
createdAt: string;
updatedAt: string;
exportMode: ExportMode;
fileIds: number[];
}

export interface CreateDistributionRequest {
exportMode?: ExportMode;
name: string;
fileIds?: number[];
bundleIds?: number[];
/**
* @deprecated This property is deprecated. Use bundleIds instead
*/
format?: string;
/**
* @deprecated This property is deprecated. Use bundleIds instead
*/
exportPattern?: string;
/**
* @deprecated This property is deprecated. Use bundleIds instead
*/
labelIds?: number[];
}

export interface CreateDistributionStringsBasedRequest {
Expand Down
2 changes: 1 addition & 1 deletion src/fields/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ export namespace FieldsModel {
type: Type;
description?: string;
entities: Entity[];
config: Config;
config?: Config;
}
}
42 changes: 34 additions & 8 deletions src/glossaries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class Glossaries extends CrowdinApi {
}
let url = `${this.url}/glossaries`;
url = this.addQueryParam(url, 'groupId', options.groupId);
url = this.addQueryParam(url, 'orderBy', options.orderBy);
url = this.addQueryParam(url, 'userId', options.userId);
return this.getList(url, options.limit, options.offset);
}

Expand Down Expand Up @@ -194,6 +196,7 @@ export class Glossaries extends CrowdinApi {
url = this.addQueryParam(url, 'languageId', options.languageId);
url = this.addQueryParam(url, 'translationOfTermId', options.translationOfTermId);
url = this.addQueryParam(url, 'conceptId', options.conceptId);
url = this.addQueryParam(url, 'orderBy', options.orderBy);
return this.getList(url, options.limit, options.offset);
}

Expand Down Expand Up @@ -293,8 +296,12 @@ export class Glossaries extends CrowdinApi {
* @param options optional parameters for the request
* @see https://developer.crowdin.com/api/v2/#operation/api.glossaries.concepts.getMany
*/
listConcepts(glossaryId: number, options?: PaginationOptions): Promise<ResponseList<GlossariesModel.Concept>> {
const url = `${this.url}/glossaries/${glossaryId}/concepts`;
listConcepts(
glossaryId: number,
options?: { orderBy?: string } & PaginationOptions,
): Promise<ResponseList<GlossariesModel.Concept>> {
let url = `${this.url}/glossaries/${glossaryId}/concepts`;
url = this.addQueryParam(url, 'orderBy', options?.orderBy);
return this.getList(url, options?.limit, options?.offset);
}

Expand Down Expand Up @@ -356,9 +363,9 @@ export namespace GlossariesModel {
terms: number;
languageId: string;
languageIds: string[];
defaultProjectId: number;
defaultProjectIds: number[];
projectIds: number[];
webUrl: string;
createdAt: string;
}

Expand All @@ -368,7 +375,20 @@ export namespace GlossariesModel {
groupId?: number;
}

export type ExportField = 'term' | 'description' | 'partOfSpeech' | 'type' | 'status' | 'gender' | 'note' | 'url';
export type ExportField =
| 'term'
| 'description'
| 'partOfSpeech'
| 'type'
| 'status'
| 'gender'
| 'note'
| 'url'
| 'conceptDefinition'
| 'conceptSubject'
| 'conceptNote'
| 'conceptUrl'
| 'conceptFigure';

export interface ExportGlossaryRequest {
format?: GlossaryFormat;
Expand All @@ -377,6 +397,7 @@ export namespace GlossariesModel {

export interface GlossaryExportStatusAttribute {
format: string;
exportFields: ExportField[];
}

export interface GlossaryImportStatusAttribute {
Expand All @@ -395,6 +416,7 @@ export namespace GlossariesModel {
userId?: number;
languageId?: string;
conceptId?: number;
orderBy?: string;
/**
* @deprecated
*/
Expand Down Expand Up @@ -425,16 +447,16 @@ export namespace GlossariesModel {
text: string;
description?: string;
partOfSpeech?: PartOfSpeech;
/**
* @deprecated
*/
translationOfTermId?: number;
status?: Status;
type?: Type;
gender?: Gender;
note?: string;
url?: string;
conceptId?: number;
/**
* @deprecated
*/
translationOfTermId?: number;
}

export interface ConcordanceSearchRequest extends PaginationOptions {
Expand Down Expand Up @@ -485,6 +507,8 @@ export namespace GlossariesModel {

export interface ListGlossariesOptions extends PaginationOptions {
groupId?: number;
userId?: number;
orderBy?: string;
}

export interface ClearGlossaryOptions {
Expand All @@ -502,6 +526,7 @@ export namespace GlossariesModel {
glossaryId: number;
subject: string;
definition: string;
translatable: boolean;
note: string;
url: string;
figure: string;
Expand All @@ -522,6 +547,7 @@ export namespace GlossariesModel {
export interface UpdateConceptRequest {
subject?: string;
definition?: string;
translatable?: boolean;
note?: string;
url?: string;
figure?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/issues/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CrowdinApi, isOptionalNumber, PaginationOptions, PatchRequest, Response
*/
export class Issues extends CrowdinApi {
/**
* @deprecated
* @param projectId project identifier
* @param options optional parameters for listing reported issues
* @see https://developer.crowdin.com/api/v2/#operation/api.projects.issues.getMany
Expand Down Expand Up @@ -52,6 +53,7 @@ export class Issues extends CrowdinApi {
}

/**
* @deprecated
* @param projectId project identifier
* @param issueId issue identifier
* @param request request body
Expand Down
5 changes: 2 additions & 3 deletions src/labels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Labels extends CrowdinApi {
options = { limit: options, offset: deprecatedOffset };
}
let url = `${this.url}/projects/${projectId}/labels`;
url = this.addQueryParam(url, 'isSystem', options.isSystem);
url = this.addQueryParam(url, 'orderBy', options.orderBy);
return this.getList(url, options.limit, options.offset);
}

Expand Down Expand Up @@ -136,13 +136,12 @@ export class Labels extends CrowdinApi {

export namespace LabelsModel {
export interface ListLabelsParams extends PaginationOptions {
isSystem?: number;
orderBy?: string;
}

export interface Label {
id: number;
title: string;
isSystem: boolean;
}

export interface AddLabelRequest {
Expand Down
6 changes: 3 additions & 3 deletions src/languages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ export namespace LanguagesModel {

export interface AddLanguageRequest {
name: string;
dialectOf?: string;
code: string;
localeCode: string;
twoLettersCode?: string;
threeLettersCode: string;
textDirection: TextDirection;
pluralCategoryNames: string[];
threeLettersCode: string;
twoLettersCode?: string;
dialectOf?: string;
}

export type TextDirection = 'ltr' | 'rtl';
Expand Down
3 changes: 2 additions & 1 deletion src/machineTranslation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ export namespace MachineTranslationModel {
| { apiKey: string }
| { credentials: string }
| { model: string; apiKey: string }
| { isSystemCredentials: boolean; apiKey: string }
| { endpoint: string; apiKey: string }
| { url: string }
| { accessKey: string; secretKey: string };

export interface CreateMachineTranslationRequest {
name: string;
groupId?: number;
type: string;
credentials: Credentials;
groupId?: number;
enabledLanguageIds?: string[];
enabledProjectIds?: number[];
isEnabled?: boolean;
Expand Down
25 changes: 21 additions & 4 deletions src/organizationWebhooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class OrganizationWebhooks extends CrowdinApi {
* @param options optional pagination parameters for the request
* @see https://developer.crowdin.com/api/v2/#operation/api.webhooks.getMany
*/
listWebhooks(options?: PaginationOptions): Promise<ResponseList<WebhooksModel.Webhook>> {
listWebhooks(options?: PaginationOptions): Promise<ResponseList<OrganizationWebhooksModel.OrganizationWebhook>> {
const url = `${this.url}/webhooks`;
return this.getList(url, options?.limit, options?.offset);
}
Expand All @@ -20,7 +20,9 @@ export class OrganizationWebhooks extends CrowdinApi {
* @param request request body
* @see https://developer.crowdin.com/api/v2/#operation/api.webhooks.post
*/
addWebhook(request: WebhooksModel.AddWebhookRequest): Promise<ResponseObject<WebhooksModel.Webhook>> {
addWebhook(
request: OrganizationWebhooksModel.AddOrganizationWebhookRequest,
): Promise<ResponseObject<OrganizationWebhooksModel.OrganizationWebhook>> {
const url = `${this.url}/webhooks`;
return this.post(url, request, this.defaultConfig());
}
Expand All @@ -29,7 +31,7 @@ export class OrganizationWebhooks extends CrowdinApi {
* @param webhookId webhook identifier
* @see https://developer.crowdin.com/api/v2/#operation/api.webhooks.get
*/
getWebhook(webhookId: number): Promise<ResponseObject<WebhooksModel.Webhook>> {
getWebhook(webhookId: number): Promise<ResponseObject<OrganizationWebhooksModel.OrganizationWebhook>> {
const url = `${this.url}/webhooks/${webhookId}`;
return this.get(url, this.defaultConfig());
}
Expand All @@ -48,8 +50,23 @@ export class OrganizationWebhooks extends CrowdinApi {
* @param request request body
* @see https://developer.crowdin.com/api/v2/#operation/api.webhooks.patch
*/
editWebhook(webhookId: number, request: PatchRequest[]): Promise<ResponseObject<WebhooksModel.Webhook>> {
editWebhook(
webhookId: number,
request: PatchRequest[],
): Promise<ResponseObject<OrganizationWebhooksModel.OrganizationWebhook>> {
const url = `${this.url}/webhooks/${webhookId}`;
return this.patch(url, request, this.defaultConfig());
}
}

export namespace OrganizationWebhooksModel {
export type OrganizationWebhook = Omit<WebhooksModel.Webhook, 'projectId' | 'events'> & {
events: Event[];
};

export type AddOrganizationWebhookRequest = Omit<WebhooksModel.AddWebhookRequest, 'events'> & {
events: Event[];
};

export type Event = 'group.created' | 'group.deleted' | 'project.created' | 'project.deleted';
}
Loading

0 comments on commit 2235b81

Please sign in to comment.