import { Injectable } from '@angular/core' ; import { ApiCallService , ApiService , httpObserveOptions } from '../../services/api-call.service' ; import { Right , SecurityLevel } from '../models/right' ; import { Observable } from 'rxjs' ; import { map } from 'rxjs/operators' ; import { HttpParams , HttpResponse } from '@angular/common/http' ; import { APIGetMultiResponse , APIGetSingleResponse } from '../../services/models/api-response' ; import { CollectionParameters } from '../../services/models/api-parameter' ; @ Injectable ( { providedIn : 'root' } ) export class RightService < T = Right > implements ApiService { public readonly servicePrefix : string = 'rights' ; constructor ( private api ) { } param params public getRights ( params = { filter : undefined , limit : 10 , sort : 'name' , order : 1 , page : 1 } ) { const options = httpObserveOptions ; let httpParams = new HttpParams ( ) ; if ( params . filter !== undefined ) { httpParams = httpParams . set ( 'filter' , params . filter ) ; } httpParams = httpParams . set ( 'limit' , params . limit . toString ( ) ) ; httpParams = httpParams . set ( 'sort' , params . sort ) ; httpParams = httpParams . set ( 'order' , params . order . toString ( ) ) ; httpParams = httpParams . set ( 'page' , params . page . toString ( ) ) ; options . params = httpParams ; return this . api . callGet < T > ( `${ this . servicePrefix }/` , options ) . pipe ( map ( ( apiResponse ) => { return apiResponse . body ; } ) ) ; } param name public getRight ( name ) { const options = httpObserveOptions ; options . params = new HttpParams ( ) ; return this . api . callGet < T > ( `${ this . servicePrefix }/${ name }` , options ) . pipe ( map ( ( apiResponse ) => { return apiResponse . body . result as T ; } ) ) ; } /**
     * Get security levels from backend.
     * Should be the same as the SecurityLevel Enum.
     */ public getLevels ( ) { const options = httpObserveOptions ; options . params = new HttpParams ( ) ; return this . api . callGet < T > ( `${ this . servicePrefix }/levels` , options ) . pipe ( map ( ( apiResponse ) => { return apiResponse . body . result as SecurityLevel ; } ) ) ; } }