import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { BaseService , HTTP_CLIENT__MAX_RETRIES , UniqueId } from '@fulls1z3/shared/util-store' ; import { ConfigService } from '@ngx-config/core' ; import { EMPTY , Observable , of as observableOf } from 'rxjs' ; import { delay , map , retry } from 'rxjs/operators' ; import { Airline } from './airline.model' ; @ Injectable ( { providedIn : 'root' } ) export class AirlineService extends BaseService < Airline > { private _delay = 2000 ; set delay ( value ) { this . _delay = value ; } constructor ( protected readonly config , protected readonly http ) { super ( config , http , [ 'backend' , 'flight' , 'airline' ] ) ; } getMany$ ( ) { const backend = this . config . getSettings ( this . settingsKey ) ; return this . http . get < Array < Airline > > ( backend . endpoint ) . pipe ( delay ( this . _delay ) , retry ( HTTP_CLIENT__MAX_RETRIES ) ) ; } getOne$ ( id ) { const backend = this . config . getSettings ( this . settingsKey ) ; return this . http . get < Array < Airline > > ( backend . endpoint ) . pipe ( delay ( this . _delay ) , retry ( HTTP_CLIENT__MAX_RETRIES ) , map ( cur => cur . find ( item => item . id === id ) ) ) ; } createMany$ ( resources ) { return EMPTY ; } createOne$ ( resource ) { return observableOf ( { ... resource , id : '100000000000000000000001' } ) . pipe ( delay ( this . _delay ) ) ; } updateMany$ ( resources ) { return EMPTY ; } updateOne$ ( resource ) { return observableOf ( resource ) . pipe ( delay ( this . _delay ) ) ; } deleteMany$ ( ids ) { return EMPTY ; } deleteOne$ ( id ) { return observableOf ( id ) . pipe ( delay ( this . _delay ) ) ; } }