Some checks failed
Playwright Tests / test (pull_request) Has been skipped
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m9s
Build Nginx-based docker image / build-static-assets (push) Has been cancelled
Add copyright notice / copyright_notice (pull_request) Successful in 1m26s
28 lines
792 B
TypeScript
28 lines
792 B
TypeScript
/* Copyright (C) 2024-2025 LibreWeddingPlanner contributors*/
|
|
|
|
import { Entity } from "./definitions";
|
|
import { Guest } from "./guest";
|
|
|
|
export class Invitation implements Entity {
|
|
id?: string;
|
|
guests: Array<Guest>;
|
|
|
|
constructor(id?: string, guests: Array<Guest> = []) {
|
|
this.id = id;
|
|
this.guests = guests;
|
|
}
|
|
}
|
|
|
|
export class InvitationSerializer {
|
|
fromJson(data: any): Invitation {
|
|
return new Invitation(data.id, (data.guests || []).map((guest: any) => new Guest(guest.id, guest.name, guest.group_name, guest.groupId, guest.color, guest.status, guest.children)));
|
|
}
|
|
|
|
toJson(invitation: Invitation): string {
|
|
return JSON.stringify({ invitation: { guest_ids: invitation.guests.map(guest => guest.id) } });
|
|
}
|
|
|
|
apiPath(): string {
|
|
return 'invitations';
|
|
}
|
|
} |