/** * API Documentation for Redaction Gateway * Description for redaction * * 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, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http'; import { CustomHttpUrlEncodingCodec } from '../encoder'; import { Observable } from 'rxjs'; import { Colors } from '../model/colors'; import { Dictionary } from '../model/dictionary'; import { TypeResponse } from '../model/typeResponse'; import { TypeValue } from '../model/typeValue'; import { UpdateTypeValue } from '../model/updateTypeValue'; import { BASE_PATH } from '../variables'; import { Configuration } from '../configuration'; @Injectable() export class DictionaryControllerService { public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); protected basePath = ''; 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; } } /** * Add dictionary entries with entry type. * None * @param body entries * @param type type * @param ruleSetId ruleSetId * @param removeCurrent removeCurrent * @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 addEntry(body: Array, type: string, ruleSetId: string, removeCurrent?: boolean, observe?: 'body', reportProgress?: boolean): Observable; public addEntry( body: Array, type: string, ruleSetId: string, removeCurrent?: boolean, observe?: 'response', reportProgress?: boolean ): Observable>; public addEntry( body: Array, type: string, ruleSetId: string, removeCurrent?: boolean, observe?: 'events', reportProgress?: boolean ): Observable>; public addEntry( body: Array, type: string, ruleSetId: string, removeCurrent?: 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 addEntry.'); } if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling addEntry.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling addEntry.'); } let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() }); if (removeCurrent !== undefined && removeCurrent !== null) { queryParameters = queryParameters.set('removeCurrent', removeCurrent); } let headers = this.defaultHeaders; // authentication (RED-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 const 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[] = ['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}/dictionary/${encodeURIComponent(String(type))}/${encodeURIComponent(String(ruleSetId))}`, { body: body, params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Creates entry type with colors, hint and caseInsensitive * None * @param body typeValue * @param ruleSetId ruleSetId * @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 addType(body: TypeValue, observe?: 'body', reportProgress?: boolean): Observable; public addType(body: TypeValue, observe?: 'response', reportProgress?: boolean): Observable>; public addType(body: TypeValue, observe?: 'events', reportProgress?: boolean): Observable>; public addType(body: TypeValue, observe: any = 'body', reportProgress: boolean = false): Observable { if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling addType.'); } let headers = this.defaultHeaders; // authentication (RED-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 const 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[] = ['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}/dictionary/type`, { body: body, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress }); } /** * Delete dictionary entries with entry type. * None * @param body entries * @param type type * @param ruleSetId ruleSetId * @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 deleteEntries(body: Array, type: string, ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public deleteEntries(body: Array, type: string, ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public deleteEntries(body: Array, type: string, ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public deleteEntries(body: Array, type: string, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling deleteEntries.'); } if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling deleteEntries.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling deleteEntries.'); } let headers = this.defaultHeaders; // authentication (RED-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 const 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[] = ['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}/dictionary/delete/${encodeURIComponent(String(type))}/${encodeURIComponent(String(ruleSetId))}`, { body: body, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Delete dictionary entry with entry type. * None * @param type type * @param ruleSetId ruleSetId * @param entry entry * @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 deleteEntry(type: string, ruleSetId: string, entry: string, observe?: 'body', reportProgress?: boolean): Observable; public deleteEntry(type: string, ruleSetId: string, entry: string, observe?: 'response', reportProgress?: boolean): Observable>; public deleteEntry(type: string, ruleSetId: string, entry: string, observe?: 'events', reportProgress?: boolean): Observable>; public deleteEntry(type: string, ruleSetId: string, entry: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling deleteEntry.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling deleteEntry.'); } if (entry === null || entry === undefined) { throw new Error('Required parameter entry was null or undefined when calling deleteEntry.'); } let headers = this.defaultHeaders; // authentication (RED-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 const 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}/dictionary/${encodeURIComponent(String(type))}/${encodeURIComponent(String(ruleSetId))}/${encodeURIComponent(String(entry))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Deletes entry type * None * @param type type * @param ruleSetId ruleSetId * @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 deleteType(type: string, ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public deleteType(type: string, ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public deleteType(type: string, ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public deleteType(type: string, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling deleteType.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling deleteType.'); } let headers = this.defaultHeaders; // authentication (RED-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 const 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}/dictionary/type/${encodeURIComponent(String(type))}/${encodeURIComponent(String(ruleSetId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Returns file containing the the dictionary entries for given type.. * * @param type type * @param ruleSetId ruleSetId * @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 downloadDictionaryFile(type: string, ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public downloadDictionaryFile(type: string, ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public downloadDictionaryFile(type: string, ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public downloadDictionaryFile(type: string, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling downloadDictionaryFile.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling downloadDictionaryFile.'); } let headers = this.defaultHeaders; // authentication (RED-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 const 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( 'get', `${this.basePath}/dictionary/download/${encodeURIComponent(String(type))}/${encodeURIComponent(String(ruleSetId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Retrieve all entry types * None * @param ruleSetId ruleSetId * @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 getAllTypes(ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public getAllTypes(ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public getAllTypes(ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public getAllTypes(ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling getAllTypes.'); } let headers = this.defaultHeaders; // authentication (RED-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 const httpHeaderAccepts: string[] = ['application/json']; 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}/dictionary/type/${encodeURIComponent(String(ruleSetId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress }); } /** * Retrieves system colors for redaction. * None * @param ruleSetId ruleSetId * @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 getColors(ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public getColors(ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public getColors(ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public getColors(ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling getColors.'); } let headers = this.defaultHeaders; // authentication (RED-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 const httpHeaderAccepts: string[] = ['application/json']; 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}/color/${encodeURIComponent(String(ruleSetId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress }); } /** * Retrieves all dictionary entries of an entry type * None * @param type type * @param ruleSetId ruleSetId * @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 getDictionaryForType(type: string, ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public getDictionaryForType(type: string, ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public getDictionaryForType(type: string, ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public getDictionaryForType(type: string, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling getDictionaryForType.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling getDictionaryForType.'); } let headers = this.defaultHeaders; // authentication (RED-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 const httpHeaderAccepts: string[] = ['application/json']; 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}/dictionary/${encodeURIComponent(String(type))}/${encodeURIComponent(String(ruleSetId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Set system colors for redaction * * @param body colors * @param ruleSetId ruleSetId * @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 setColors(body: Colors, ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public setColors(body: Colors, ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public setColors(body: Colors, ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public setColors(body: Colors, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling setColors.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling setColors.'); } let headers = this.defaultHeaders; // authentication (RED-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 const 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[] = ['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}/color/${encodeURIComponent(String(ruleSetId))}`, { body: body, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress }); } /** * Updates colors, hint and caseInsensitive of an entry type. * None * @param body typeValue * @param type type * @param ruleSetId ruleSetId * @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 updateType(body: UpdateTypeValue, type: string, ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public updateType(body: UpdateTypeValue, type: string, ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public updateType(body: UpdateTypeValue, type: string, ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public updateType(body: UpdateTypeValue, type: string, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling updateType.'); } if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling updateType.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling updateType.'); } let headers = this.defaultHeaders; // authentication (RED-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 const 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[] = ['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}/dictionary/type/${encodeURIComponent(String(type))}/${encodeURIComponent(String(ruleSetId))}`, { body: body, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Takes object containing string or rules as argument, which will be used by the redaction service. * * @param file * @param type type * @param ruleSetId ruleSetId * @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 uploadDictionaryFileForm(file: Blob, type: string, ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable; public uploadDictionaryFileForm(file: Blob, type: string, ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public uploadDictionaryFileForm(file: Blob, type: string, ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public uploadDictionaryFileForm(file: Blob, type: string, ruleSetId: 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 uploadDictionaryFile.'); } if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling uploadDictionaryFile.'); } if (ruleSetId === null || ruleSetId === undefined) { throw new Error('Required parameter ruleSetId was null or undefined when calling uploadDictionaryFile.'); } let headers = this.defaultHeaders; // authentication (RED-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 const 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; const 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}/dictionary/upload/${encodeURIComponent(String(type))}/${encodeURIComponent(String(ruleSetId))}`, { body: convertFormParamsToString ? formParams.toString() : formParams, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * @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; } }