/* Copyright (C) 2024 Manuel Bustillo*/

import { Serializable } from "../api/abstract-api";
import { Entity } from "./definitions";

export const guestStatuses = ['considered', 'invited', 'confirmed', 'declined', 'tentative'] as const;
export type GuestStatus = typeof guestStatuses[number];

export class Guest implements Entity {
  id?: string;
  name?: string;
  group_name?: string;
  groupId?: string;
  color?: string;
  status?: GuestStatus;

  constructor(id?: string, name?: string, group_name?: string, groupId?: string, color?: string, status?: GuestStatus) {
    this.id = id;
    this.name = name;
    this.group_name = group_name;
    this.groupId = groupId;
    this.color = color;
    this.status = status;
  }
}

export class GuestSerializer implements Serializable<Guest> {
  fromJson(data: any): Guest {
    return new Guest(data.id, data.name, data.group_name, data.group_id, data.color, data.status);
  }

  toJson(guest: Guest): string {
    return JSON.stringify({ guest: { name: guest.name, status: guest.status, group_id: guest.groupId } });
  }

  apiPath(): string {
    return 'guests';
  }
}

