use crate::entities as MegalodonEntities;
use serde::Deserialize;

#[derive(Debug, Deserialize, Clone)]
pub struct List {
    id: String,
    title: String,
    replies_policy: RepliesPolicy,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(rename_all = "snake_case")]
pub enum RepliesPolicy {
    Followed,
    List,
    None,
}

impl From<RepliesPolicy> for MegalodonEntities::list::RepliesPolicy {
    fn from(val: RepliesPolicy) -> Self {
        match val {
            RepliesPolicy::Followed => MegalodonEntities::list::RepliesPolicy::Followed,
            RepliesPolicy::List => MegalodonEntities::list::RepliesPolicy::List,
            RepliesPolicy::None => MegalodonEntities::list::RepliesPolicy::None,
        }
    }
}

impl From<List> for MegalodonEntities::List {
    fn from(val: List) -> Self {
        MegalodonEntities::List {
            id: val.id,
            title: val.title,
            replies_policy: Some(val.replies_policy.into()),
        }
    }
}
