import { Injectable } from '@angular/core' ; import { Observable } from 'rxjs' ; import { HttpClient , HttpHeaders } from '@angular/common/http' ; import { ProductCatalog } from '../models/product-catalog' ; const headers = new HttpHeaders ( ) . set ( 'Content-Type' , 'application/json' ) ; const apiUrl = "/shop/api/productcatalogs" ; @ Injectable ( { providedIn : 'root' } ) export class ProductCatalogService { constructor ( private http ) { } getProductCatalogs ( ) { return this . http . get < ProductCatalog [ ] > ( apiUrl , { headers } ) ; } getProductCatalog ( id ) { return this . http . get < ProductCatalog > ( `${ apiUrl }/${ id }` , { headers } ) ; } createProductCatalog ( productCatalog ) { return this . http . post < ProductCatalog > ( apiUrl , productCatalog , { headers } ) ; } updateProductCatalog ( id , productCatalog ) { return this . http . put < ProductCatalog > ( `${ apiUrl }/${ id }` , productCatalog , { headers } ) ; } }