UNPKG

xiot-core-spec-ts

Version:
51 lines (50 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApplicationCodec = void 0; const Application_1 = require("../../typedef/app/Application"); const EventReceiverCodec_1 = require("./event/EventReceiverCodec"); const AuthorizationCodec_1 = require("./authorization/AuthorizationCodec"); class ApplicationCodec { static decodeArray(array) { return array ? array.map(x => { return ApplicationCodec.decode(x); }) : []; } static decode(o) { const app = new Application_1.Application(); app.appId = o.appId; app.name = o.name; app.organization = o.organization; app.eventReceiver = EventReceiverCodec_1.EventReceiverCodec.decode(o.event); app.authorization = AuthorizationCodec_1.AuthorizationCodec.decode(o.authorization); app.createBy = o.createBy; app.createAt = o.createAt; return app; } static encode(x) { const o = { appId: x.appId, name: x.name, organization: x.organization, createBy: x.createBy, createAt: x.createAt }; if (x.authorization != null) { o.authorization = AuthorizationCodec_1.AuthorizationCodec.encode(x.authorization); } if (x.eventReceiver != null) { o.event = EventReceiverCodec_1.EventReceiverCodec.encode(x.eventReceiver); } return o; } static encodeArray(children) { return children != null ? children.map(s => { return ApplicationCodec.encode(s); }) : []; } } exports.ApplicationCodec = ApplicationCodec;