import { Injectable } from '@angular/core';
import { Mapper } from './mapper';
import { Product } from '../models/product';
import { ProductDTO } from '@swagger/remi';

@Injectable()
export class ProductToProductDTOMapping implements Mapper<Product, ProductDTO> {
  constructor() {}

  get sourceName(): string {
    return 'Product';
  }

  get targetName(): string {
    return 'ProductDTO';
  }

  map(source: Product): ProductDTO {
    if (source.sourceProduct) {
      return source.sourceProduct;
    } else {
      throw Error('Keine Produktinformationen vorhanden');
    }
  }
}
