Manuel Bustillo 7de37759ca
All checks were successful
Playwright Tests / test (pull_request) Has been skipped
Check usage of free licenses / build-static-assets (pull_request) Successful in 32s
Add copyright notice / copyright_notice (pull_request) Successful in 40s
Add copyright notice
2024-12-09 18:22:44 +00:00

64 lines
1.3 KiB
TypeScript

/* 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';
}
}