use derive_builder::Builder;
use serde::Serialize;
use uuid::Uuid;
use crate::schema::{group::ScanlationGroupList, manga::MangaList, user::*, NoData};
use crate::Result;
#[derive(Debug, Serialize, Clone, Builder, Default)]
#[builder(setter(strip_option), default)]
pub struct ListUsers<'a> {
pub limit: Option<i32>,
pub offset: Option<i32>,
#[builder(setter(each = "add_user"))]
#[serde(rename = "ids")]
pub user_ids: Vec<&'a Uuid>,
pub username: Option<&'a str>,
pub order: Option<UserOrder>,
}
impl_endpoint! {
GET "/user",
#[query auth] ListUsers<'_>,
UserList
}
#[derive(Debug, Clone)]
pub struct GetUser<'a> {
pub user_id: &'a Uuid,
}
impl_endpoint! {
GET ("/user/{:x}", user_id),
#[no_data] GetUser<'_>,
#[flatten_result] UserResponse
}
#[derive(Debug, Serialize, Clone)]
pub struct UpdatePassword<'a> {
pub old_password: &'a str,
pub new_password: &'a str,
}
impl_endpoint! {
POST "/user/password",
#[body auth] UpdatePassword<'_>,
#[discard_result] Result<NoData>
}
#[derive(Debug, Serialize, Clone)]
pub struct UpdateEmail<'a> {
pub email: &'a str,
}
impl_endpoint! {
POST "/user/email",
#[body auth] UpdateEmail<'_>,
#[discard_result] Result<NoData>
}
#[derive(Debug, Clone)]
pub struct GetLoggedUser;
impl_endpoint! {
GET "/user/me",
#[no_data auth] GetLoggedUser,
#[flatten_result] UserResponse
}
#[derive(Debug, Serialize, Clone)]
pub struct ListFollowedGroups {
pub limit: Option<i32>,
pub offset: Option<i32>,
}
impl_endpoint! {
GET "/user/follows/group",
#[query auth] ListFollowedGroups,
ScanlationGroupList
}
#[derive(Debug, Serialize, Clone)]
pub struct ListFollowedUsers {
pub limit: Option<i32>,
pub offset: Option<i32>,
}
impl_endpoint! {
GET "/user/follows/user",
#[query auth] ListFollowedUsers,
UserList
}
#[derive(Debug, Serialize, Clone)]
pub struct ListFollowedManga {
pub limit: Option<i32>,
pub offset: Option<i32>,
}
impl_endpoint! {
GET "/user/follows/manga",
#[query auth] ListFollowedManga,
MangaList
}