import { Magento2AbstractApiService } from '../widgets/magento2.abstract.api.service';

export class SparepartsService extends Magento2AbstractApiService {

  private attribute: string = 'kopfhoerermodell';

  constructor(
    public $http,
    public $q,
    public API_URL,
    public API_PRODUCTS_ENDPOINT
  ) {
    super($http, $q, API_URL, API_PRODUCTS_ENDPOINT);
  }

  public get(categories: string): Promise<any> {
    return super.get('category_id', categories, 'created_at', 'DESC', 'in', '500');
  }

  public prepareResponse(res: any) {
    return {
      attributeValues: this.getAttributeValues(res.data.items, this.attribute),
      products: res.data.items
    }
  }

}
