UNPKG

@agravity/public

Version:

The Agravity GlobalDAM API which allowes API key authenticated access the Agravity GlobalDAM Backend

194 lines (176 loc) 7.92 kB
/** * Agravity OpenAPI Documentation - Public Functions * * Contact: office@agravity.io * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * 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, HttpParameterCodec, HttpContext } from '@angular/common/http'; import { CustomHttpParameterCodec } from '../encoder'; import { Observable } from 'rxjs'; // @ts-ignore import { AgravityErrorResponse } from '../model/agravityErrorResponse.pub.agravity'; // @ts-ignore import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { AgravityPublicConfiguration } from '../configuration'; export interface HttpAssetGetViewForPortalRequestParams { /** The ID of the asset. */ assetId: string; /** If the request comes from portal this is the indicator. */ portalId: string; /** The name of the format (download format) or container. */ format: string; /** True if a direct download with file name should be started. */ download?: string; } @Injectable({ providedIn: 'root' }) export class PublicEndpointsService { protected basePath = 'http://localhost:7072/api'; public defaultHeaders = new HttpHeaders(); public configuration = new AgravityPublicConfiguration(); public encoder: HttpParameterCodec; constructor( protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string | string[], @Optional() configuration: AgravityPublicConfiguration ) { if (configuration) { this.configuration = configuration; } if (typeof this.configuration.basePath !== 'string') { const firstBasePath = Array.isArray(basePath) ? basePath[0] : undefined; if (firstBasePath != undefined) { basePath = firstBasePath; } if (typeof basePath !== 'string') { basePath = this.basePath; } this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } // @ts-ignore private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { if (typeof value === 'object' && value instanceof Date === false) { httpParams = this.addToHttpParamsRecursive(httpParams, value); } else { httpParams = this.addToHttpParamsRecursive(httpParams, value, key); } return httpParams; } private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { if (value == null) { return httpParams; } if (typeof value === 'object') { if (Array.isArray(value)) { (value as any[]).forEach((elem) => (httpParams = this.addToHttpParamsRecursive(httpParams, elem, key))); } else if (value instanceof Date) { if (key != null) { httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10)); } else { throw Error('key may not be null if value is Date'); } } else { Object.keys(value).forEach((k) => (httpParams = this.addToHttpParamsRecursive(httpParams, value[k], key != null ? `${key}.${k}` : k))); } } else if (key != null) { httpParams = httpParams.append(key, value); } else { throw Error('key may not be null if value is not object or array'); } return httpParams; } /** * This endpoint returns the content of an asset which is available in a specific portal (portal_id is \&quot;key\&quot;) and returns the blob directly. * @param requestParameters * @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 httpAssetGetViewForPortal( requestParameters?: HttpAssetGetViewForPortalRequestParams, observe?: 'body', reportProgress?: boolean, options?: { httpHeaderAccept?: 'application/octet-stream' | 'application/json'; context?: HttpContext; transferCache?: boolean } ): Observable<Blob>; public httpAssetGetViewForPortal( requestParameters?: HttpAssetGetViewForPortalRequestParams, observe?: 'response', reportProgress?: boolean, options?: { httpHeaderAccept?: 'application/octet-stream' | 'application/json'; context?: HttpContext; transferCache?: boolean } ): Observable<HttpResponse<Blob>>; public httpAssetGetViewForPortal( requestParameters?: HttpAssetGetViewForPortalRequestParams, observe?: 'events', reportProgress?: boolean, options?: { httpHeaderAccept?: 'application/octet-stream' | 'application/json'; context?: HttpContext; transferCache?: boolean } ): Observable<HttpEvent<Blob>>; public httpAssetGetViewForPortal( requestParameters?: HttpAssetGetViewForPortalRequestParams, observe: any = 'body', reportProgress: boolean = false, options?: { httpHeaderAccept?: 'application/octet-stream' | 'application/json'; context?: HttpContext; transferCache?: boolean } ): Observable<any> { const assetId = requestParameters?.assetId; if (assetId === null || assetId === undefined) { throw new Error('Required parameter assetId was null or undefined when calling httpAssetGetViewForPortal.'); } const portalId = requestParameters?.portalId; if (portalId === null || portalId === undefined) { throw new Error('Required parameter portalId was null or undefined when calling httpAssetGetViewForPortal.'); } const format = requestParameters?.format; if (format === null || format === undefined) { throw new Error('Required parameter format was null or undefined when calling httpAssetGetViewForPortal.'); } const download = requestParameters?.download; let localVarQueryParameters = new HttpParams({ encoder: this.encoder }); if (assetId !== undefined && assetId !== null) { localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, <any>assetId, 'asset_id'); } if (portalId !== undefined && portalId !== null) { localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, <any>portalId, 'portal_id'); } if (format !== undefined && format !== null) { localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, <any>format, 'format'); } if (download !== undefined && download !== null) { localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, <any>download, 'download'); } let localVarHeaders = this.defaultHeaders; let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header const httpHeaderAccepts: string[] = ['application/octet-stream', 'application/json']; localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); } if (localVarHttpHeaderAcceptSelected !== undefined) { localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); } let localVarHttpContext: HttpContext | undefined = options && options.context; if (localVarHttpContext === undefined) { localVarHttpContext = new HttpContext(); } let localVarTransferCache: boolean | undefined = options && options.transferCache; if (localVarTransferCache === undefined) { localVarTransferCache = true; } let localVarPath = `/public/view`; return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, params: localVarQueryParameters, responseType: 'blob', withCredentials: this.configuration.withCredentials, headers: localVarHeaders, observe: observe, transferCache: localVarTransferCache, reportProgress: reportProgress }); } }