Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 34x 34x 34x 3x 2x 1x 20x 20x 1x 20x | import { AttributeHelper } from 'ish-core/models/attribute/attribute.helper';
import { Link } from 'ish-core/models/link/link.model';
import { PriceMapper } from 'ish-core/models/price/price.mapper';
import { WarrantyData } from './warranty.interface';
import { Warranty } from './warranty.model';
export class WarrantyMapper {
static fromData(data: WarrantyData): Warranty {
if (data) {
return {
id: data.sku,
name: data.name,
price: { type: 'Money', value: data.price, currency: data.currencyCode },
shortDescription: data.shortDescription,
longDescription: data.longDescription,
attributes: data.attributes,
};
} else {
throw new Error(`'WarrantyData' is required for the mapping`);
}
}
static fromLinkData(warrantyLinks: Link[] = []): Warranty[] {
const warranties: Warranty[] = [];
warrantyLinks.map(linkData =>
warranties.push({
id: linkData.uri.slice(linkData.uri.lastIndexOf('/') + 1),
name: linkData.title,
price: PriceMapper.fromData(
AttributeHelper.getAttributeValueByAttributeName(linkData.attributes, 'WarrantyPrice')
),
})
);
return warranties;
}
}
|