import { CrowdinApi , DownloadLink , PatchRequest , ResponseList , ResponseObject } from '../core' ; export class SourceFiles extends CrowdinApi { param projectId param name param limit param offset listProjectBranches ( projectId , name ? , limit ? , offset ? ) { let url = `${ this . url }/projects/${ projectId }/branches` ; url = this . addQueryParam ( url , 'name' , name ) ; return this . getList ( url , limit , offset ) ; } param projectId param request createBranch ( projectId , request ) { const url = `${ this . url }/projects/${ projectId }/branches` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } param projectId param branchId getBranch ( projectId , branchId ) { const url = `${ this . url }/projects/${ projectId }/branches/${ branchId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param branchId deleteBranch ( projectId , branchId ) { const url = `${ this . url }/projects/${ projectId }/branches/${ branchId }` ; return this . delete ( url , this . defaultConfig ( ) ) ; } param projectId param branchId param request editBranch ( projectId , branchId , request ) { const url = `${ this . url }/projects/${ projectId }/branches/${ branchId }` ; return this . patch ( url , request , this . defaultConfig ( ) ) ; } param projectId param branchId param directoryId param limit param offset param filter param recursion listProjectDirectories ( projectId , branchId ? , directoryId ? , limit ? , offset ? , filter ? , recursion ? ) ; listProjectDirectories ( projectId , branchIdOrRequest ? , directoryId ? , limit ? , offset ? , filter ? , recursion ? ) { let url = `${ this . url }/projects/${ projectId }/directories` ; let request ; if ( branchIdOrRequest && typeof branchIdOrRequest === 'object' ) { request = branchIdOrRequest ; } else { request = { branchId : branchIdOrRequest , directoryId , limit , offset , recursion , filter } ; } url = this . addQueryParam ( url , 'branchId' , request . branchId ) ; url = this . addQueryParam ( url , 'directoryId' , request . directoryId ) ; url = this . addQueryParam ( url , 'filter' , request . filter ) ; url = this . addQueryParam ( url , 'recursion' , request . recursion ) ; return this . getList ( url , request . limit , request . offset ) ; } param projectId param request createDirectory ( projectId , request ) { const url = `${ this . url }/projects/${ projectId }/directories` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } param projectId param directoryId getDirectory ( projectId , directoryId ) { const url = `${ this . url }/projects/${ projectId }/directories/${ directoryId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param directoryId deleteDirectory ( projectId , directoryId ) { const url = `${ this . url }/projects/${ projectId }/directories/${ directoryId }` ; return this . delete ( url , this . defaultConfig ( ) ) ; } param projectId param directoryId param request editDirectory ( projectId , directoryId , request ) { const url = `${ this . url }/projects/${ projectId }/directories/${ directoryId }` ; return this . patch ( url , request , this . defaultConfig ( ) ) ; } listProjectFiles ( projectId , request ) ; param projectId param branchId param directoryId param limit param offset param recursion param filter listProjectFiles ( projectId , branchId ? , directoryId ? , limit ? , offset ? , recursion ? , filter ? ) ; listProjectFiles ( projectId , branchIdOrRequest ? , directoryId ? , limit ? , offset ? , recursion ? , filter ? ) { let url = `${ this . url }/projects/${ projectId }/files` ; let request ; if ( branchIdOrRequest && typeof branchIdOrRequest === 'object' ) { request = branchIdOrRequest ; } else { request = { branchId : branchIdOrRequest , directoryId , limit , offset , recursion , filter } ; } url = this . addQueryParam ( url , 'branchId' , request . branchId ) ; url = this . addQueryParam ( url , 'directoryId' , request . directoryId ) ; url = this . addQueryParam ( url , 'recursion' , request . recursion ) ; url = this . addQueryParam ( url , 'filter' , request . filter ) ; return this . getList ( url , request . limit , request . offset ) ; } param projectId param request createFile ( projectId , request ) { const url = `${ this . url }/projects/${ projectId }/files` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } param projectId param fileId getFile ( projectId , fileId ) { const url = `${ this . url }/projects/${ projectId }/files/${ fileId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param fileId param request updateOrRestoreFile ( projectId , fileId , request ) { const url = `${ this . url }/projects/${ projectId }/files/${ fileId }` ; return this . put ( url , request , this . defaultConfig ( ) ) ; } param projectId param fileId deleteFile ( projectId , fileId ) { const url = `${ this . url }/projects/${ projectId }/files/${ fileId }` ; return this . delete ( url , this . defaultConfig ( ) ) ; } param projectId param fileId param request editFile ( projectId , fileId , request ) { const url = `${ this . url }/projects/${ projectId }/files/${ fileId }` ; return this . patch ( url , request , this . defaultConfig ( ) ) ; } param projectId param fileId downloadFile ( projectId , fileId ) { const url = `${ this . url }/projects/${ projectId }/files/${ fileId }/download` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param fileId param limit param offset listFileRevisions ( projectId , fileId , limit ? , offset ? ) { const url = `${ this . url }/projects/${ projectId }/files/${ fileId }/revisions` ; return this . getList ( url , limit , offset ) ; } param projectId param fileId param revisionId getFileRevision ( projectId , fileId , revisionId ) { const url = `${ this . url }/projects/${ projectId }/files/${ fileId }/revisions/${ revisionId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param branchId param limit param offset listReviewedSourceFilesBuild ( projectId , branchId ? , limit ? , offset ? ) { let url = `${ this . url }/projects/${ projectId }/strings/reviewed-builds` ; url = this . addQueryParam ( url , 'branchId' , branchId ) ; return this . getList ( url , limit , offset ) ; } param projectId param request buildReviewedSourceFiles ( projectId , request ) { const url = `${ this . url }/projects/${ projectId }/strings/reviewed-builds` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } param projectId param buildId checkReviewedSourceFilesBuildStatus ( projectId , buildId ) { const url = `${ this . url }/projects/${ projectId }/strings/reviewed-builds/${ buildId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param buildId downloadReviewedSourceFiles ( projectId , buildId ) { const url = `${ this . url }/projects/${ projectId }/strings/reviewed-builds/${ buildId }/download` ; return this . get ( url , this . defaultConfig ( ) ) ; } } export namespace SourceFilesModel { export interface Branch { id : number ; projectId : number ; name : string ; title : string ; exportPattern : string ; priority : Priority ; createdAt : string ; updatedAt : string ; } export interface CreateBranchRequest { name : string ; title ? : string ; exportPattern ? : string ; priority ? : Priority ; } export enum Priority { LOW = 'low' , NORMAL = 'normal' , HIGH = 'high' } export interface ListProjectDirectoriesRequest { branchId ? : number ; directoryId ? : number ; limit ? : number ; offset ? : number ; filter ? : string ; recursion ? : string ; } export interface Directory { id : number ; projectId : number ; branchId : number ; directoryId : number ; name : string ; title : string ; exportPattern : string ; priority : Priority ; createdAt : string ; updatedAt : string ; } export interface CreateDirectoryRequest { branchId ? : number ; directoryId ? : number ; name : string ; title ? : string ; exportPattern ? : string ; priority ? : Priority ; } export interface ListProjectFilesRequest { branchId ? : number ; directoryId ? : number ; limit ? : number ; offset ? : number ; recursion ? : any ; filter ? : string ; } export interface File { id : number ; projectId : number ; branchId : number ; directoryId : number ; name : string ; title : string ; type : string ; revisionId : number ; status : string ; priority : Priority ; path : string ; importOptions : SpreadsheetImportOptions | XmlImportOptions | OtherImportOptions ; exportOptions : GeneralExportOptions | PropertyExportOptions ; createdAt : string ; updatedAt : string ; excludedTargetLanguages : string [ ] ; } export interface CreateFileRequest { storageId : number ; name : string ; branchId ? : number ; directoryId ? : number ; title ? : string ; type ? : FileType ; importOptions ? : SpreadsheetImportOptions | XmlImportOptions | OtherImportOptions ; exportOptions ? : GeneralExportOptions | PropertyExportOptions ; attachLabelIds ? : number [ ] ; excludedTargetLanguages ? : string [ ] ; } export interface ReplaceFileFromStorageRequest { storageId : number ; updateOption ? : UpdateOption ; importOptions ? : SpreadsheetImportOptions | XmlImportOptions | OtherImportOptions ; exportOptions ? : GeneralExportOptions | PropertyExportOptions ; attachLabelIds ? : number [ ] ; detachLabelIds ? : number [ ] ; } export interface RestoreFile { revisionId : number ; } export interface FileRevision { id : number ; projectId : number ; fileId : number ; restoreToRevision : number ; info : FileRevisionInfo ; date : string ; } export interface FileRevisionInfo { added : FileRevisionInfoAttribute ; deleted : FileRevisionInfoAttribute ; updated : FileRevisionInfoAttribute ; } export interface FileRevisionInfoAttribute { strings : number ; words : number ; } export enum FileType { AUTO = 'auto' , ANDROID = 'android' , MACOSX = 'macosx' , RESX = 'resx' , PROPERTIES = 'properties' , GETTEXT = 'gettext' , YAML = 'yaml' , PHP = 'php' , JSON = 'json' , XML = 'xml' , INI = 'ini' , RC = 'rc' , RESW = 'resw' , RESJSON = 'resjson' , QTTS = 'qtts' , JOOMLA = 'joomla' , CHROME = 'chrome' , DTD = 'dtd' , DKLANG = 'dklang' , FLEX = 'flex' , NSH = 'nsh' , WXL = 'wxl' , XLIFF = 'xliff' , HTML = 'html' , HAML = 'haml' , TXT = 'txt' , CSV = 'csv' , MD = 'md' , FLSNP = 'flsnp' , FM_HTML = 'fm_html' , FM_MD = 'fm_md' , MEDIAWIKI = 'mediawiki' , DOCX = 'docx' , SBV = 'sbv' , VTT = 'vtt' , SRT = 'srt' } export interface SpreadsheetImportOptions { firstLineContainsHeader : boolean ; importTranslations : boolean ; scheme : Scheme ; } export interface Scheme { identifier : number ; sourcePhrase : number ; [ key ] : number ; } export interface XmlImportOptions { translateContent : boolean ; translateAttributes : boolean ; contentSegmentation : boolean ; translatableElements : string [ ] ; srxStorageId : number ; } export interface OtherImportOptions { contentSegmentation : boolean ; srxStorageId : number ; } export interface GeneralExportOptions { exportPattern : string ; } export interface PropertyExportOptions { escapeQuotes : EscapeQuotes ; exportPattern : string ; } export enum EscapeQuotes { ZERO = 0 , ONE = 1 , TWO = 2 , THREE = 3 } export enum UpdateOption { CLEAR_TRANSLATIONS_AND_APPROVALS = 'clear_translations_and_approvals' , KEEP_TRANSLATIONS = 'keep_translations' , KEEP_TRANSLATIONS_AND_APPROVALS = 'keep_translations_and_approvals' } export interface ReviewedSourceFilesBuild { id : number ; projectId : number ; status : string ; progress : number ; attributes : ReviewedSourceFilesBuildAttributes ; } export interface ReviewedSourceFilesBuildAttributes { branchId : number ; targetLanguageId : string ; } export interface BuildReviewedSourceFilesRequest { branchId : number ; } }