pub mod note;
pub mod timeline;
pub mod user;

use http::Method;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use ts_rs::TS;

#[derive(Clone, Debug, Serialize, Deserialize, TS)]
pub struct ResponseError {
    pub kind: ErrorKind,
    pub status: Option<u16>,
    pub code: String,
    pub message: String,
}

#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, TS)]
pub enum ErrorKind {
    #[default]
    ApiError,
    Other,
}

#[derive(Clone, Debug, Serialize, Deserialize, TS)]
#[ts(export)]
pub struct Empty {}

impl From<Empty> for () {
    fn from(_: Empty) -> Self {}
}

pub trait Endpoint {
    const NAME: &'static str;
    const ENDPOINT: &'static str;
    const METHOD: Method;
    const PAGINATED: bool;

    type Request: Serialize + DeserializeOwned + Send + Sync + 'static;
    type Response: Serialize + DeserializeOwned + Send + Sync + 'static;
}

pub type Req<T> = <T as Endpoint>::Request;
pub type Res<T> = <T as Endpoint>::Response;
