import {Injectable} from '@angular/core';
import {Resource, Service} from 'ngx-jsonapi';


@Injectable()
export class ProductsService extends Service<Product> {
  public resource = Product;
  public type = 'products';

}


export class Product extends Resource {
  public attributes: {
    name: string,
    price: number,
  };

  get name() {
    return this.attributes.name;
  }

  set name(name: string) {
    this.attributes.name = name;
  }

  get price() {
    return this.attributes.price;
  }

  set price(price: number) {
    this.attributes.price = price;
  }

}
