import PropertyUtils from "@impl/utils/PropertyUtils";
import IValidations from "./IValidations";
import { ValidationResult } from "./RuleEngine";

export default class Validations implements IValidations {
    public readonly minicartLineItems: boolean;
    public readonly minicartTotals: boolean;
    public readonly cartSummary: boolean;
    public readonly agreementPricing: boolean;
    public readonly dealDescription: boolean;
    public readonly allotmentStatus: boolean;
    public readonly chevronStatus: boolean;
    public readonly agreementDates: boolean;
    public readonly lineItems: boolean;
    public readonly accountingTotal: boolean;
    
    public constructor(json: any, validationResults: ValidationResult[]) {
        this.minicartLineItems = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.minicartLineItems);
        this.minicartTotals = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.minicartTotals);
        this.cartSummary = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.cartSummary);
        this.dealDescription = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.dealDescription);
        this.agreementPricing = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.agreementPricing);
        this.allotmentStatus = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.allotmentStatus);
        this.chevronStatus = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.chevronStatus);
        this.agreementDates = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.agreementDates);
        this.lineItems = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.lineItems);
        this.accountingTotal = PropertyUtils.getValue<this>(json, Validations.name, validationResults, { isRequired: true }, x => x.accountingTotal);
    }
}
