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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5zaW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vc2VydmljZS9pbXBsL2ludGVyZmFjZS9zcmMvbGliL2N1c3RvbS9leHRlbnNpb24udHMi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