import OrderBookEntry from "../../../apiwrapper/orderbook/OrderBookEntry.js";
import AbstractConverter from "../AbstractConverter.js";
import ConverterFactory from "../ConverterFactory.js";

export default class OrderBookEntryConverter extends AbstractConverter {

    constructor(){
        super();
    }

    /**
     * @param {OrderBookEntry} obj
     * @returns {object} 
     */
    toRestObject(obj) {
        return {
            _objectType: ConverterFactory.OBJECT_TYPE_ORDER_BOOK_ENTRY,
            price: obj.price,
            quantity: obj.quantity
        };
    }

    /**
     * @param {object} obj
     * @returns {OrderBookEntry} 
     */
    fromRestObject(obj) {
        return new OrderBookEntry(obj.price, obj.quantity);
    }
}