vanilli-shop-client
Advanced tools
Comparing version 1.3.0 to 1.3.1
import { IBaseDto, IPropertyDto } from "./base"; | ||
import { IParameter } from "./parameter"; | ||
export interface IProductBaseDto extends IBaseDto { | ||
@@ -30,2 +31,4 @@ ref: string; | ||
export declare class ProductDetails { | ||
static getCurrentPrice(product: IProductBaseDto, parameters?: IParameter[]): number; | ||
static getPrice(defaultPrice: number, parameters?: IParameter[]): number; | ||
static getProperty(properties: IPropertyDto[] | undefined, key: string): string | undefined; | ||
@@ -32,0 +35,0 @@ } |
@@ -33,2 +33,22 @@ "use strict"; | ||
} | ||
ProductDetails.getCurrentPrice = function (product, parameters) { | ||
var discountPrice = product.discountPrice; | ||
if (discountPrice) { | ||
return discountPrice; | ||
} | ||
return this.getPrice(product.currentPrice, parameters); | ||
}; | ||
ProductDetails.getPrice = function (defaultPrice, parameters) { | ||
var maxPrice = defaultPrice; | ||
if (parameters) { | ||
for (var _i = 0, parameters_1 = parameters; _i < parameters_1.length; _i++) { | ||
var parameter = parameters_1[_i]; | ||
var price = parameter.price; | ||
if (price && price > maxPrice) { | ||
maxPrice = price; | ||
} | ||
} | ||
} | ||
return maxPrice; | ||
}; | ||
ProductDetails.getProperty = function (properties, key) { | ||
@@ -35,0 +55,0 @@ var property = properties === null || properties === void 0 ? void 0 : properties.find(function (x) { return x.key === key; }); |
{ | ||
"name": "vanilli-shop-client", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Client for Vanilli Shop API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import {IBaseDto, IPropertyDto} from "./base"; | ||
import {IParameter} from "./parameter"; | ||
@@ -54,2 +55,28 @@ export interface IProductBaseDto extends IBaseDto { | ||
export class ProductDetails { | ||
static getCurrentPrice(product: IProductBaseDto, parameters?: IParameter[]): number { | ||
const discountPrice = product.discountPrice; | ||
if (discountPrice) { | ||
return discountPrice; | ||
} | ||
return this.getPrice(product.currentPrice, parameters); | ||
} | ||
static getPrice(defaultPrice: number, parameters?: IParameter[]): number { | ||
let maxPrice = defaultPrice; | ||
if (parameters) { | ||
for (const parameter of parameters) { | ||
const price = parameter.price; | ||
if (price && price > maxPrice) { | ||
maxPrice = price; | ||
} | ||
} | ||
} | ||
return maxPrice; | ||
} | ||
static getProperty(properties: IPropertyDto[] | undefined, key: string): string | undefined { | ||
@@ -56,0 +83,0 @@ const property = properties?.find(x => x.key === key); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222693
4948