import { API } from "./API" ; import { APIUtils } from "./APIUtils" ; import { ILanguageConfig } from "./LanguageConfigsAPI" ; export interface IExportConfigRelationships { language_configs : { data : { id : string ; type : "language_config" ; } [ ] ; } ; } export interface IExportConfig { id : string ; type : string ; attributes : { id : string ; name : string ; file_format : string ; file_path : string ; default_language_file_path : string ; } ; relationships : IExportConfigRelationships ; } export interface IGetExportConfigsResponse { data : IExportConfig [ ] ; included : ILanguageConfig [ ] ; meta : { total : number ; } ; } export interface IGetExportConfigsOptions { search ? : string ; page ? : number ; perPage ? : number ; } const ExportConfigsAPI = { getExportConfigs : async ( options ) : Promise < IGetExportConfigsResponse > => { return API . getRequest ( `projects/${ options . projectId }/export_configs` , true , { search : options . options && options . options . search , page : options . options && options . options . page , per_page : options . options && options . options . perPage } ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } , createExportConfig : async ( options ) => { return API . postRequest ( `projects/${ options . projectId }/export_configs` , true , { name : options . name , language_id : options . projectId , file_format : options . fileFormat , file_path : options . filePath , default_language_file_path : options . defaultLanguageFilePath } ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } , updateExportConfig : async ( options ) => { return API . putRequest ( `projects/${ options . projectId }/export_configs/${ options . exportConfigId }` , true , { name : options . name , language_id : options . projectId , file_format : options . fileFormat , file_path : options . filePath , default_language_file_path : options . defaultLanguageFilePath } ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } , deleteExportConfig : async ( options ) => { return API . deleteRequest ( `projects/${ options . projectId }/export_configs/${ options . exportConfigId }` , true ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } , deleteExportConfigs : async ( options ) => { return API . deleteRequest ( `projects/${ options . projectId }/export_configs` , true , { export_configs : options . exportConfigIds } ) . then ( APIUtils . handleErrors ) . catch ( APIUtils . handleErrors ) ; } } ; export { ExportConfigsAPI } ;