// 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::{Date, DateTime, Name, OrganizationClassification, Url};
use pib_oparl_extensions::Color;
use pib_service_core_types::{BodyId, OrganizationId};
use serde::{Deserialize, Serialize};

pub mod get;
pub mod post;

pub mod by_id;

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct Organization {
    pub id: OrganizationId,
    pub body_id: BodyId,
    pub created: DateTime,
    pub modified: DateTime,
    pub name: Name,
    pub short_name: Option<Name>,
    pub classification: Option<OrganizationClassification>,
    pub start_date: Option<Date>,
    pub end_date: Option<Date>,
    pub website: Option<Url>,
    pub color: Option<Color>,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct NewOrganization {
    pub name: Name,
    pub short_name: Option<Name>,
    pub classification: Option<OrganizationClassification>,
    pub start_date: Option<Date>,
    pub end_date: Option<Date>,
    pub website: Option<Url>,
    pub color: Option<Color>,
}

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

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

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

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

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

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

    #[serde(skip_serializing_if = "Option::is_none")]
    pub color: Option<Option<Color>>,
}
