"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "PrinterApiFactory", {
    enumerable: true,
    get: function() {
        return PrinterApiFactory;
    }
});
const _printerapiinterface = require("./printer-api.interface");
const _containertokens = require("../container.tokens");
class PrinterApiFactory {
    cradle;
    constructor(cradle){
        this.cradle = cradle;
    }
    getById(id) {
        const login = this.cradle[_containertokens.DITokens.printerCache].getLoginDto(id);
        return this.getScopedPrinter(login);
    }
    getScopedPrinter(login) {
        let printerApi;
        if (login.printerType === _printerapiinterface.OctoprintType) {
            printerApi = this.cradle[_containertokens.DITokens.octoprintApi];
        } else if (login.printerType === _printerapiinterface.MoonrakerType) {
            printerApi = this.cradle[_containertokens.DITokens.moonrakerApi];
        } else {
            throw new Error("PrinterType is unknown, cant pick the right socket adapter");
        }
        printerApi.login = login;
        return printerApi;
    }
}

//# sourceMappingURL=printer-api.factory.js.map