use mzrs_proto::realtime as rt;
use crate::client::MzrsClient;
use crate::error::SdkError;
use crate::handles::ChannelHandle;
#[derive(Clone)]
pub struct ClanHandle {
client: MzrsClient,
clan_id: String,
}
impl ClanHandle {
pub(crate) fn new(client: MzrsClient, clan_id: String) -> Self {
Self { client, clan_id }
}
pub fn id(&self) -> &str {
&self.clan_id
}
pub fn client(&self) -> &MzrsClient {
&self.client
}
#[tracing::instrument(skip(self), fields(clan_id = %self.clan_id))]
pub async fn join_chat(&self) -> Result<rt::ClanJoin, SdkError> {
self.client.join_clan_chat(&self.clan_id).await
}
#[tracing::instrument(skip(self, nick_name, avatar))]
pub async fn update_my_profile(
&self,
nick_name: Option<String>,
avatar: Option<String>,
) -> Result<(), SdkError> {
self.client
.update_clan_profile(&self.clan_id, nick_name, avatar)
.await
}
#[tracing::instrument(skip(self, avatar))]
pub async fn update_my_profile_avatar(&self, avatar: Option<String>) -> Result<(), SdkError> {
self.client
.update_clan_profile_avatar(&self.clan_id, avatar)
.await
}
pub fn channel(&self, channel_id: impl Into<String>) -> ChannelHandle {
ChannelHandle::new(self.client.clone(), self.clan_id.clone(), channel_id.into())
}
}