import Serializable from "../util/Serializable.js";

export default class APIConfig extends Serializable {
    #isTestNet = false;

    constructor(){
        super();
    }

    /**
     * @param {boolean} testNet enable testnet config
     */
    setTestNet(testNet) {
        this.#isTestNet = testNet;
    }

    /**
     * @returns {boolean}
     */
    isTestNet() {
        return this.#isTestNet;
    }

    /**
     * @returns {string} string representation of this object
     */
    toJson() {
        const obj = JSON.parse(super.toJson());
        obj.testNet = this.#isTestNet;

        return JSON.stringify(obj);
    }

    /**
     * @param {string} objString 
     * @returns {APIConfig}
     */
    static fromJson(objString) {
        const conf = new APIConfig();
        conf.setTestNet(JSON.parse(objString).testNet);

        return conf;
    }
}