import TransactionSettings from "../../../apiwrapper/transaction/TransactionSettings.js";
import AbstractConverter from "../AbstractConverter.js";
import ConverterFactory from "../ConverterFactory.js";

export default class TransactionSettingsConverter extends AbstractConverter {

    constructor(){
        super();
    }

    /**
     * @param {TransactionSettings} obj
     * @returns {object} 
     */
    toRestObject(obj) {
        return {
            _objectType: ConverterFactory.OBJECT_TYPE_TRANSACTION_SETTINGS,
            id: obj.apiID,
            orderPrice: obj.orderPrice,
            orderQuantity: obj.orderQuantity,
            price: obj.price,
            quantity: obj.quantity
        };
    }

    /**
     * @param {object} obj
     * @returns {TransactionSettings} 
     */
    fromRestObject(obj) {
        const ts = new TransactionSettings(null, null);

        ts.apiID = obj.id;
        ts.orderPrice = obj.orderPrice;
        ts.orderQuantity = obj.orderQuantity;
        ts.price = obj.price;
        ts.quantity = obj.quantity;

        return ts;
    }
}