UNPKG

merchantapi

Version:
77 lines (67 loc) 1.33 kB
/* * (c) Miva Inc <https://www.miva.com/> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ const util = require('./../util'); const { Model } = require('./../abstract'); const Decimal = require('decimal.js-light'); /** * OrderPart data model. * @class */ class OrderPart extends Model { /** * OrderPart Constructor. * @param {Object} data * @returns {void} */ constructor(data = {}) { super(data); if (!util.isNullOrUndefined(this.price)) this.price = new Decimal(this.price); } /** * Get code. * @returns {string} */ getCode() { return this.getField('code'); } /** * Get sku. * @returns {string} */ getSku() { return this.getField('sku'); } /** * Get name. * @returns {string} */ getName() { return this.getField('name'); } /** * Get quantity. * @returns {number} */ getQuantity() { return this.getField('quantity', 0); } /** * Get total_quantity. * @returns {number} */ getTotalQuantity() { return this.getField('total_quantity', 0); } /** * Get price. * @returns {Decimal} */ getPrice() { return this.getField('price', new Decimal(0.00)); } } module.exports.OrderPart = OrderPart;