Skip to content

Commit

Permalink
fix: added recursion property to list files request (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ authored Jun 16, 2020
1 parent 6ac1948 commit 7fe231c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@crowdin/crowdin-api-client",
"version": "1.8.5",
"version": "1.8.6",
"description": "JavaScript library for Crowdin API v2.",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand Down
41 changes: 36 additions & 5 deletions src/sourceFiles/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CrowdinApi, ResponseList, ResponseObject, PatchRequest, DownloadLink } from '../core';
import { CrowdinApi, DownloadLink, PatchRequest, ResponseList, ResponseObject } from '../core';

export class SourceFiles extends CrowdinApi {
/**
Expand Down Expand Up @@ -130,26 +130,49 @@ export class SourceFiles extends CrowdinApi {
return this.patch(url, request, this.defaultConfig());
}

listProjectFiles(
projectId: number,
request: SourceFilesModel.ListProjectFilesRequest,
): Promise<ResponseList<SourceFilesModel.File>>;

/**
*
* @param projectId project identifier
* @param branchId list branch files (Note! You can either list files for the specified branch (branchId) in the same request)
* @param directoryId list directory files (Note! You can either list files for the specified directory (directoryId) in the same request)
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @param recursion use to list files recursively
*/
listProjectFiles(
projectId: number,
branchId?: number,
directoryId?: number,
limit?: number,
offset?: number,
recursion?: any,
): Promise<ResponseList<SourceFilesModel.File>>;

listProjectFiles(
projectId: number,
branchIdOrRequest?: number | SourceFilesModel.ListProjectFilesRequest,
directoryId?: number,
limit?: number,
offset?: number,
recursion?: any,
): Promise<ResponseList<SourceFilesModel.File>> {
let url = `${this.url}/projects/${projectId}/files`;
url = this.addQueryParam(url, 'branchId', branchId);
url = this.addQueryParam(url, 'directoryId', directoryId);
url = this.addQueryParam(url, 'limit', limit);
url = this.addQueryParam(url, 'offset', offset);
let request: SourceFilesModel.ListProjectFilesRequest;
if (branchIdOrRequest && typeof branchIdOrRequest === 'object') {
request = branchIdOrRequest;
} else {
request = { branchId: branchIdOrRequest, directoryId, limit, offset, recursion };
}
url = this.addQueryParam(url, 'branchId', request.branchId);
url = this.addQueryParam(url, 'directoryId', request.directoryId);
url = this.addQueryParam(url, 'limit', request.limit);
url = this.addQueryParam(url, 'offset', request.offset);
url = this.addQueryParam(url, 'recursion', request.recursion);
return this.get(url, this.defaultConfig());
}

Expand Down Expand Up @@ -300,6 +323,14 @@ export namespace SourceFilesModel {
priority?: Priority;
}

export interface ListProjectFilesRequest {
branchId?: number;
directoryId?: number;
limit?: number;
offset?: number;
recursion?: any;
}

export interface File {
id: number;
projectId: number;
Expand Down

0 comments on commit 7fe231c

Please sign in to comment.