// SPDX-FileCopyrightText: Politik im Blick developers
// SPDX-FileCopyrightText: Wolfgang Silbermayr <wolfgang@silbermayr.at>
//
// SPDX-License-Identifier: AGPL-3.0-or-later OR EUPL-1.2

use oparl_types::{DateTime, EmailAddress, Name};
use pib_service_core_types::{BodyId, PersonId};
use serde::{Deserialize, Serialize};

pub mod get;
pub mod post;

pub mod by_id;

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct Person {
    pub id: PersonId,
    pub body_id: BodyId,
    pub created: DateTime,
    pub modified: DateTime,
    pub name: Option<Name>,
    pub family_name: Option<Name>,
    pub given_name: Option<Name>,
    pub form_of_address: Option<String>,
    pub affix: Option<String>,
    pub title: Vec<String>,
    pub gender: Option<String>,
    pub phone: Vec<String>,
    pub email: Vec<EmailAddress>,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct NewPerson {
    pub name: Name,
    pub family_name: Option<Name>,
    pub given_name: Option<Name>,
    pub form_of_address: Option<String>,
    pub affix: Option<String>,
    pub title: Vec<String>,
    pub gender: Option<String>,
    pub phone: Vec<String>,
    pub email: Vec<EmailAddress>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct UpdatePerson {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<Name>,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub family_name: Option<Option<Name>>,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub given_name: Option<Option<Name>>,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub form_of_address: Option<Option<String>>,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub affix: Option<Option<String>>,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<Vec<String>>,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub gender: Option<Option<String>>,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub phone: Option<Vec<String>>,

    #[serde(skip_serializing_if = "Option::is_none")]
    pub email: Option<Vec<EmailAddress>>,
}
