var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { InterfaceService } from '../generated/service';
InterfaceService.prototype.getAppUrl = function () {
    return __awaiter(this, void 0, void 0, function* () {
        const appPath = yield this.getAppPath();
        if (appPath.isSuccessful()) {
            let body = appPath.body();
            if (body.match(/^\$[1-6]\//)) {
                const code = body.substring(0, 3);
                const content = body.substring(3);
                switch (code) {
                    case '$1/':
                        body = `https://user.cloud.iotize.com/users/${content}`;
                        break;
                    case '$2/':
                        body = `http://${content}`;
                        break;
                    case '$5/':
                        body = `https://user.cloud.iotize.com/users/${content}`;
                        break;
                    default:
                        body = '';
                }
                appPath.setBody(body);
            }
        }
        return appPath;
    });
};
InterfaceService.prototype.getAndroidApplicationId = function () {
    return __awaiter(this, void 0, void 0, function* () {
        const appPath = yield this.getAppPath();
        if (appPath.isSuccessful()) {
            const body = appPath.body();
            if (body.startsWith('$4/')) { // TODO replace with constant
                appPath.setBody(body.substring(3));
            }
            else {
                appPath.setBody("");
            }
        }
        return appPath;
    });
};
InterfaceService.prototype.putAndroidApplicationId = function (value) {
    return __awaiter(this, void 0, void 0, function* () {
        return this.putAppPath(`$4/${value}`);
    });
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5zaW9uLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGlvdGl6ZS90YXAvc2VydmljZS9pbXBsL2ludGVyZmFjZS8iLCJzb3VyY2VzIjpbImxpYi9jdXN0b20vZXh0ZW5zaW9uLnRzIl0sIm5hbWVzIjpbXS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