import { Injectable } from '@angular/core' ; import { ApiCallService , httpFileOptions } from '../services/api-call.service' ; import { map } from 'rxjs/operators' ; import { HttpParams } from '@angular/common/http' ; import { CollectionParameters } from '../services/models/api-parameter' ; @ Injectable ( { providedIn : 'root' } ) export class FileService { private servicePrefix : string = 'exporter' ; constructor ( private api ) { } public callFileFormatRoute ( ) { return this . api . callGet < any > ( this . servicePrefix + '/extensions' ) . pipe ( map ( ( apiResponse ) => { return apiResponse . body ; } ) ) ; } public callExportRoute ( params , view = 'native' ) { const options = httpFileOptions ; let httpParams = new HttpParams ( ) ; if ( params . filter !== undefined ) { httpParams = httpParams . set ( 'filter' , JSON . stringify ( params . filter ) ) ; } if ( params . optional !== undefined ) { const { classname , zip , metadata } = ( params . optional as any ) ; httpParams = httpParams . set ( 'classname' , classname ) ; httpParams = httpParams . set ( 'zip' , zip ) ; httpParams = httpParams . set ( 'metadata' , JSON . stringify ( metadata ) ) ; } httpParams = httpParams . set ( 'sort' , params . sort ) ; httpParams = httpParams . set ( 'order' , params . order . toString ( ) ) ; httpParams = httpParams . set ( 'view' , view ) ; options . params = httpParams ; return this . api . callGet < any > ( this . servicePrefix + '/' , options ) ; } public getTypeFile ( ) { return this . api . callPost < any > ( 'export/type/' , null , httpFileOptions ) ; } public callExportTypeRoute ( route ) { return this . api . callPost < any > ( route , null , httpFileOptions ) ; } }