use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
pub struct APIPermissionDemandIdentify {
#[serde(default, skip_serializing_if = "String::is_empty")]
pub path: String,
#[serde(default, skip_serializing_if = "String::is_empty")]
pub method: String,
}
impl APIPermissionDemandIdentify {
pub fn new(path: impl Into<String>, method: impl Into<String>) -> Self {
Self {
path: path.into(),
method: method.into(),
}
}
pub fn guild_members() -> Self {
Self::new("/guilds/{guild_id}/members/{user_id}", "GET")
}
pub fn guild_channels() -> Self {
Self::new("/guilds/{guild_id}/channels", "GET")
}
pub fn post_messages() -> Self {
Self::new("/channels/{channel_id}/messages", "POST")
}
pub fn guild_roles() -> Self {
Self::new("/guilds/{guild_id}/roles", "POST")
}
}
impl std::fmt::Display for APIPermissionDemandIdentify {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{} {}", self.method, self.path)
}
}