/* Copyright (C) 2024 Manuel Bustillo*/ import { Entity } from "./definitions"; export type AttendanceSummary = { considered: number; invited: number; confirmed: number; declined: number; tentative: number; total: number; } export class Group implements Entity { id?: string; name?: string; guest_count?: number; icon?: string; children?: Group[]; parentId?: string; color?: string; attendance?: AttendanceSummary constructor(id?: string, name?: string, guest_count?: number, icon?: string, children?: Group[], parentId?: string, color?: string, attendance?: AttendanceSummary) { this.id = id; this.name = name; this.guest_count = guest_count; this.icon = icon; this.children = children; this.parentId = parentId; this.color = color; this.attendance = attendance; } } export class GroupSerializer { fromJson(data: any): Group { return new Group( data.id, data.name, data.guest_count, data.icon, data.children, data.parent_id, data.color, data.attendance ); } toJson(group: Group): string { return JSON.stringify({ group: { name: group.name, color: group.color, icon: group.icon, parent_id: group.parentId } }); } apiPath(): string { return 'groups'; } }