/** * Api Documentation * Api Documentation * * OpenAPI spec version: 1.0 * * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. *//* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent } from '@angular/common/http'; import { CustomHttpUrlEncodingCodec } from '../encoder'; import { Observable } from 'rxjs'; import { FileIds } from '../model/fileIds'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; @Injectable() export class FileUploadControllerService { protected basePath = ''; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { if (basePath) { this.basePath = basePath; } if (configuration) { this.configuration = configuration; this.basePath = basePath || configuration.basePath || this.basePath; } } /** * @param consumes string[] mime-types * @return true: consumes contains 'multipart/form-data', false: otherwise */ private canConsumeForm(consumes: string[]): boolean { const form = 'multipart/form-data'; for (const consume of consumes) { if (form === consume) { return true; } } return false; } /** * Deletes a file for a given projectId and FileId * None * @param projectId projectId * @param fileId fileId * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public deleteFile(projectId: string, fileId: string, observe?: 'body', reportProgress?: boolean): Observable; public deleteFile(projectId: string, fileId: string, observe?: 'response', reportProgress?: boolean): Observable>; public deleteFile(projectId: string, fileId: string, observe?: 'events', reportProgress?: boolean): Observable>; public deleteFile(projectId: string, fileId: string, observe: any = 'body', reportProgress: boolean = false ): Observable { if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling deleteFile.'); } if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling deleteFile.'); } let headers = this.defaultHeaders; // authentication (GIN-OAUTH) required if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header let httpHeaderAccepts: string[] = [ ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ ]; return this.httpClient.request('delete',`${this.basePath}/redaction-gateway-v1/delete/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Returns a downloadable byte stream of the annotated file with the specified fileId * Use the optional \"inline\" request parameter to select, if this downloadAnnotated will be opened in the browser. * @param fileId fileId * @param inline inline * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public downloadAnnotatedFile(fileId: string, inline?: boolean, observe?: 'body', reportProgress?: boolean): Observable; public downloadAnnotatedFile(fileId: string, inline?: boolean, observe?: 'response', reportProgress?: boolean): Observable>; public downloadAnnotatedFile(fileId: string, inline?: boolean, observe?: 'events', reportProgress?: boolean): Observable>; public downloadAnnotatedFile(fileId: string, inline?: boolean, observe: any = 'body', reportProgress: boolean = false ): Observable { if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling downloadAnnotatedFile.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (inline !== undefined && inline !== null) { queryParameters = queryParameters.set('inline', inline); } let headers = this.defaultHeaders; // authentication (GIN-OAUTH) required if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/octet-stream' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ ]; return this.httpClient.request('get',`${this.basePath}/redaction-gateway-v1/download/annotated/${encodeURIComponent(String(fileId))}`, { params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Returns a downloadable byte stream of the original file with the specified fileId * Use the optional \"inline\" request parameter to select, if this downloadAnnotated will be opened in the browser. * @param fileId fileId * @param inline inline * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public downloadOriginalFile(fileId: string, inline?: boolean, observe?: 'body', reportProgress?: boolean): Observable; public downloadOriginalFile(fileId: string, inline?: boolean, observe?: 'response', reportProgress?: boolean): Observable>; public downloadOriginalFile(fileId: string, inline?: boolean, observe?: 'events', reportProgress?: boolean): Observable>; public downloadOriginalFile(fileId: string, inline?: boolean, observe: any = 'body', reportProgress: boolean = false ): Observable { if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling downloadOriginalFile.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (inline !== undefined && inline !== null) { queryParameters = queryParameters.set('inline', inline); } let headers = this.defaultHeaders; // authentication (GIN-OAUTH) required if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/octet-stream' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ ]; return this.httpClient.request('get',`${this.basePath}/redaction-gateway-v1/download/original/${encodeURIComponent(String(fileId))}`, { params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Returns a downloadable byte stream of the redacted file with the specified fileId * Use the optional \"inline\" request parameter to select, if this downloadAnnotated will be opened in the browser. * @param fileId fileId * @param inline inline * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public downloadRedactedFile(fileId: string, inline?: boolean, observe?: 'body', reportProgress?: boolean): Observable; public downloadRedactedFile(fileId: string, inline?: boolean, observe?: 'response', reportProgress?: boolean): Observable>; public downloadRedactedFile(fileId: string, inline?: boolean, observe?: 'events', reportProgress?: boolean): Observable>; public downloadRedactedFile(fileId: string, inline?: boolean, observe: any = 'body', reportProgress: boolean = false ): Observable { if (fileId === null || fileId === undefined) { throw new Error('Required parameter fileId was null or undefined when calling downloadRedactedFile.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (inline !== undefined && inline !== null) { queryParameters = queryParameters.set('inline', inline); } let headers = this.defaultHeaders; // authentication (GIN-OAUTH) required if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/octet-stream' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ ]; return this.httpClient.request('get',`${this.basePath}/redaction-gateway-v1/download/redacted/${encodeURIComponent(String(fileId))}`, { params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Returns a downloadable byte stream of the redaction report file for the specified fileIds * Use the optional \"inline\" request parameter to select, if this report will be opened in the browser. * @param body fileIds * @param inline inline * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public downloadRedactionReport(body: FileIds, inline?: boolean, observe?: 'body', reportProgress?: boolean): Observable; public downloadRedactionReport(body: FileIds, inline?: boolean, observe?: 'response', reportProgress?: boolean): Observable>; public downloadRedactionReport(body: FileIds, inline?: boolean, observe?: 'events', reportProgress?: boolean): Observable>; public downloadRedactionReport(body: FileIds, inline?: boolean, observe: any = 'body', reportProgress: boolean = false ): Observable { if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling downloadRedactionReport.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (inline !== undefined && inline !== null) { queryParameters = queryParameters.set('inline', inline); } let headers = this.defaultHeaders; // authentication (GIN-OAUTH) required if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/octet-stream' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ 'application/json' ]; const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected != undefined) { headers = headers.set('Content-Type', httpContentTypeSelected); } return this.httpClient.request('post',`${this.basePath}/redaction-gateway-v1/download/report`, { body: body, params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Returns a downloadable byte stream of the redaction report file for the specified project * Use the optional \"inline\" request parameter to select, if this report will be opened in the browser. * @param projectId The projectId * @param inline inline * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public downloadRedactionReportForProject(projectId: string, inline?: boolean, observe?: 'body', reportProgress?: boolean): Observable; public downloadRedactionReportForProject(projectId: string, inline?: boolean, observe?: 'response', reportProgress?: boolean): Observable>; public downloadRedactionReportForProject(projectId: string, inline?: boolean, observe?: 'events', reportProgress?: boolean): Observable>; public downloadRedactionReportForProject(projectId: string, inline?: boolean, observe: any = 'body', reportProgress: boolean = false ): Observable { if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling downloadRedactionReportForProject.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (inline !== undefined && inline !== null) { queryParameters = queryParameters.set('inline', inline); } let headers = this.defaultHeaders; // authentication (GIN-OAUTH) required if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/octet-stream' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ ]; return this.httpClient.request('get',`${this.basePath}/redaction-gateway-v1/download/report/${encodeURIComponent(String(projectId))}`, { params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Receives an uploaded file and returns its fileId. * None * @param file * @param projectId The projectId, the file belongs to * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public uploadFileForm(file: Blob, projectId: string, observe?: 'body', reportProgress?: boolean): Observable; public uploadFileForm(file: Blob, projectId: string, observe?: 'response', reportProgress?: boolean): Observable>; public uploadFileForm(file: Blob, projectId: string, observe?: 'events', reportProgress?: boolean): Observable>; public uploadFileForm(file: Blob, projectId: string, observe: any = 'body', reportProgress: boolean = false ): Observable { if (file === null || file === undefined) { throw new Error('Required parameter file was null or undefined when calling uploadFile.'); } if (projectId === null || projectId === undefined) { throw new Error('Required parameter projectId was null or undefined when calling uploadFile.'); } let headers = this.defaultHeaders; // authentication (GIN-OAUTH) required if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken; headers = headers.set('Authorization', 'Bearer ' + accessToken); } // to determine the Accept header let httpHeaderAccepts: string[] = [ '*/*' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ 'multipart/form-data' ]; const canConsumeForm = this.canConsumeForm(consumes); let formParams: { append(param: string, value: any): void; }; let useForm = false; let convertFormParamsToString = false; // use FormData to transmit files using content-type "multipart/form-data" // see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data useForm = canConsumeForm; if (useForm) { formParams = new FormData(); } else { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); } if (file !== undefined) { formParams = formParams.append('file', file) as any || formParams; } return this.httpClient.request('post',`${this.basePath}/redaction-gateway-v1/upload/${encodeURIComponent(String(projectId))}`, { body: convertFormParamsToString ? formParams.toString() : formParams, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } }