68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
import PlaybackDevice from "./playback-device.js";
|
|
import User from "./user.js";
|
|
import Integration from "./integration.js";
|
|
import Command from "./command.js";
|
|
import Remote from "./remote.js";
|
|
|
|
const Serializer = (function () {
|
|
function deserializeUser(object) {
|
|
object.isAdmin = object.is_admin;
|
|
return new User(object);
|
|
}
|
|
|
|
function deserializeUsers(objects) {
|
|
return objects.map((object) => deserializeUser(object));
|
|
}
|
|
|
|
function deserializeDevice(object) {
|
|
return new PlaybackDevice(object);
|
|
}
|
|
|
|
function deserializeDevices(objects) {
|
|
if (!objects) return [];
|
|
return objects.map((object) => deserializeDevice(object));
|
|
}
|
|
|
|
function deserializeIntegration(object) {
|
|
return new Integration(object);
|
|
}
|
|
|
|
function deserializeIntegrations(objects) {
|
|
if (!objects) return [];
|
|
return objects.map((object) => deserializeIntegration(object));
|
|
}
|
|
|
|
function deserializeCommand(object) {
|
|
return new Command(object);
|
|
}
|
|
|
|
function deserializeCommands(objects) {
|
|
if (!objects) return [];
|
|
return objects.map((object) => deserializeCommand(object));
|
|
}
|
|
|
|
function deserializeRemote(object) {
|
|
return new Remote(object);
|
|
}
|
|
|
|
function deserializeRemotes(objects) {
|
|
if (!objects) return [];
|
|
return objects.map((object) => deserializeRemote(object));
|
|
}
|
|
|
|
return {
|
|
deserializeUser,
|
|
deserializeUsers,
|
|
deserializeDevice,
|
|
deserializeDevices,
|
|
deserializeIntegration,
|
|
deserializeIntegrations,
|
|
deserializeCommand,
|
|
deserializeCommands,
|
|
deserializeRemote,
|
|
deserializeRemotes,
|
|
};
|
|
})();
|
|
|
|
export default Serializer;
|