import Serializable from "../../util/Serializable.js"; export default class TransactionSettings extends Serializable{ /** * ordered quantity * @type {number} */ orderQuantity = 0; /** * ordered price * @type {number} */ orderPrice = 0; /** * real quantity * @type {number} */ quantity = 0; /** * real price * @type {number} */ price = 0; /** * extern id (from api) * @type {string} */ apiID = ""; /** * @param {number} price default 0 * @param {number} quantity default 0 */ constructor(price = 0, quantity = 0){ super(); this.orderPrice = price; this.orderQuantity = quantity; } /** * @returns {string} string representation of this object */ toJson() { const obj = JSON.parse(super.toJson()); obj.orderQuantity = this.orderQuantity; obj.oderPrice = this.orderPrice; obj.quantity = this.quantity; obj.price = this.price; obj.apiID = this.apiID; return JSON.stringify(obj); } /** * @param {string} objString * @returns {TransactionSettings} */ static fromJson(objString) { const obj = new TransactionSettings(); const tmpObj = JSON.parse(objString); obj.orderQuantity = tmpObj.orderQuantity; obj.orderPrice = tmpObj.oderPrice; obj.quantity = tmpObj.quantity; obj.price = tmpObj.price; obj.apiID = tmpObj.apiID; return obj; } }