import { HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { FileFormat } from '@app/core/model/file/file-format.model'; import { BaseService } from '@common/base/base.service'; import { Guid } from '@common/types/guid'; import { Observable, throwError } from 'rxjs'; import { catchError } from 'rxjs/operators'; import { ConfigurationService } from '../configuration/configuration.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service'; @Injectable() export class FileTransformerHttpService extends BaseService { private headers = new HttpHeaders(); constructor( private http: BaseHttpV2Service, private configurationService: ConfigurationService ) { super(); } private get apiBase(): string { return `${this.configurationService.server}file-transformer`; } getAvailableConfigurations(): Observable { const url = `${this.apiBase}/available`; return this.http.get(url).pipe(catchError((error: any) => throwError(error))); } exportDmp(dmpId: Guid, format: string): Observable { //TODO: implement const url = `${this.apiBase}/export-dmp`; return this.http.post(url, {id: dmpId, format: format}, {responseType: 'blob', observe: 'response'}).pipe(catchError((error: any) => throwError(error))); } exportDescription(id: Guid, format: string): Observable { //TODO: implement const url = `${this.apiBase}/export-description`; return this.http.post(url, {id: id, format: format}, {responseType: 'blob', observe: 'response'}).pipe(catchError((error: any) => throwError(error))); } }