HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/csb.komma.pro/resources/js/global/models/checkoutInformationResponse.js
class CheckoutInformationResponse {
    constructor() {
        this._totalExVatAndDiscounts = 0;
        this._totalExVatAndDiscountsFormatted = '';
        this._totalExVat = 0;
        this._totalExVatFormatted = '';
        this._vatTotal = 0;
        this._vatTotalFormatted = '';
        this._shippingCosts = 0;
        this._shippingCostsFormatted = '';
        this._total = 0;
        this._totalFormatted = '';
        this._vatPercentage = 0;
        this._couponCodes = [];
    }

    /**
     * @param {string} json
     * @return {CheckoutInformationResponse|null}
     */
    static fromJsonString(json) {
        if(!this.is(json)) {
            return null;
        }
        let jsonObject = JSON.parse(json);

        let instance = new this;
        instance._totalExVatAndDiscounts = jsonObject.totalExVatAndDiscounts;
        instance._totalExVatAndDiscountsFormatted = jsonObject.totalExVatAndDiscountsFormatted;
        instance._totalExVat = jsonObject.totalExVat;
        instance._totalExVatFormatted = jsonObject.totalExVatFormatted;
        instance._vatTotal = jsonObject.vatTotal;
        instance._vatTotalFormatted = jsonObject.vatTotalFormatted;
        instance._shippingCosts = jsonObject.shippingCosts;
        instance._shippingCostsFormatted = jsonObject.shippingCostsFormatted;
        instance._total = jsonObject.total;
        instance._totalFormatted = jsonObject.totalFormatted;
        instance._vatPercentage = jsonObject.vatPercentage;
        instance._couponCodes = jsonObject.couponCodes;

        return instance;
    }

    /**
     * Checks that the given json string represents a CheckoutInformationResponse
     *
     * @param {string} json
     * @param {boolean} logErrors
     * @return {boolean}
     */
    static is(json, logErrors = true)
    {
        let jsonObject = null;
        try {
            jsonObject = JSON.parse(json);
            if(!jsonObject) return false;
        } catch (e) {
            if(logErrors) console.error('CheckoutInformationResponse: The given json does not represent a valid CheckoutInformationResponse since the json string was not a valid json');
            return false;
        }

        if(!jsonObject.hasOwnProperty('totalExVatFormatted') || typeof jsonObject.totalExVatFormatted !== 'string') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a totalExVatFormatted property that is a string. Object: ', jsonObject);
            return false;
        }
        if(!jsonObject.hasOwnProperty('totalExVatAndDiscountsFormatted') || typeof jsonObject.totalExVatAndDiscountsFormatted !== 'string') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a totalExVatAndDiscountsFormatted property that is a string. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('vatTotalFormatted') || typeof jsonObject.vatTotalFormatted !== 'string') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a vatTotalFormatted property that is a string. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('shippingCostsFormatted') || typeof jsonObject.shippingCostsFormatted !== 'string') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a shippingCostsFormatted property that is a string. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('totalFormatted') || typeof jsonObject.totalFormatted !== 'string') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a totalFormatted property that is a string. Object: ', jsonObject);
            return false;

        }

        if(!jsonObject.hasOwnProperty('totalExVatAndDiscounts') || typeof jsonObject.totalExVatAndDiscounts !== 'number') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a totalExVatAndDiscounts property that is a number. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('totalExVat') || typeof jsonObject.totalExVat !== 'number') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a totalExVat property that is a number. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('vatTotal') || typeof jsonObject.vatTotal !== 'number') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a vatTotal property that is a number. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('shippingCosts') || typeof jsonObject.shippingCosts !== 'number') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a shippingCosts property that is a number. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('total') || typeof jsonObject.total !== 'number') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a total property that is a number. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('vatPercentage') || typeof jsonObject.vatPercentage !== 'number') {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a vatPercentage property that is a number. Object: ', jsonObject);
            return false;

        }
        if(!jsonObject.hasOwnProperty('couponCodes') || !Array.isArray(jsonObject.couponCodes)) {
            if(logErrors) console.error('CheckoutInformationResponse: The response object must have a couponCodes property that is an array. Object: ', jsonObject);
            return false;

        }

        return true;
    }


    get totalExVatAndDiscounts() {
        return this._totalExVatAndDiscounts;
    }

    get totalExVatAndDiscountsFormatted() {
        return this._totalExVatAndDiscountsFormatted;
    }

    get totalExVat() {
        return this._totalExVat;
    }

    get totalExVatFormatted() {
        return this._totalExVatFormatted;
    }

    get vatTotal() {
        return this._vatTotal;
    }

    get vatTotalFormatted() {
        return this._vatTotalFormatted;
    }

    get shippingCosts() {
        return this._shippingCosts;
    }

    get shippingCostsFormatted() {
        return this._shippingCostsFormatted;
    }

    get total() {
        return this._total;
    }

    get totalFormatted() {
        return this._totalFormatted;
    }

    get vatPercentage() {
        return this._vatPercentage;
    }

    get couponCodes() {
        return this._couponCodes;
    }
}

export { CheckoutInformationResponse }