import { HttpClient } from '@angular/common/http' ; import { Inject , Injectable , } from '@angular/core' ; import { Observable } from 'rxjs' ; import { map } from 'rxjs/operators' ; import { DaffProduct } from '@daffodil/product' ; import { DaffProductDriverResponse , DaffProductServiceInterface , } from '@daffodil/product/driver' ; import { DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM } from '../injection-tokens/public_api' ; import { DaffInMemoryProductResponseTransform } from '../interfaces/public_api' ; inheritdoc Param @ Injectable ( { providedIn : 'root' , } ) export class DaffInMemoryProductService implements DaffProductServiceInterface { docs-private url = '/api/products' ; constructor ( private http , @ Inject ( DAFF_PRODUCT_IN_MEMORY_PRODUCT_RESPONSE_TRANSFORM ) private transform ) { } getAll ( ) { return this . http . get < DaffProduct [ ] > ( this . url ) ; } getBestSellers ( ) { return this . http . get < DaffProduct [ ] > ( `${ this . url }/best-sellers` ) ; } get ( productId ) { return this . http . get < DaffProduct > ( `${ this . url }/${ productId }` ) . pipe ( map ( this . transform ) ) ; } getByUrl ( url ) { return this . http . get < DaffProduct > ( `${ this . url }${ url }` ) . pipe ( map ( this . transform ) ) ; } }