pub struct Http { /* private fields */ }Expand description
An instance of a client to the REST API
Implementations§
Source§impl Http
impl Http
pub async fn get_onboarding(&self) -> Result<OnboardingStatus>
pub async fn complete_onboarding(&self, username: &str) -> Result
Source§impl Http
impl Http
pub async fn fetch_account(&self) -> Result<Account>
pub async fn create_account( email: &str, password: &str, invite: Option<&str>, captcha: Option<&str>, ) -> Result
pub async fn resend_verification(email: &str, captcha: Option<&str>) -> Result
pub async fn verify_email(code: &str) -> Result
pub async fn send_password_reset(email: &str, captcha: Option<&str>) -> Result
pub async fn password_reset(password: &str, token: &str) -> Result
pub async fn change_password( &self, password: &str, current_password: &str, ) -> Result
pub async fn change_email(&self, email: &str, current_password: &str) -> Result
pub async fn login( email: &str, password: Option<&str>, challange: Option<&str>, friendly_name: Option<&str>, captcha: Option<&str>, ) -> Result<Session>
pub async fn logout(self) -> Result
pub async fn edit_session( &self, session: SessionId, friendly_name: &str, ) -> Result
pub async fn delete_session(&self, session: SessionId) -> Result
pub async fn fetch_sessions(&self) -> Result<Vec<SessionInfo>>
pub async fn delete_all_sessions(&self, revoke_self: bool) -> Result
Source§impl Http
impl Http
Sourcepub async fn fetch_user(&self, user_id: UserId) -> Result<User>
pub async fn fetch_user(&self, user_id: UserId) -> Result<User>
Gets an user from the api
Sourcepub async fn edit_user(&self, patch: UserEditPatch) -> Result
pub async fn edit_user(&self, patch: UserEditPatch) -> Result
Edits user
Sourcepub async fn edit_username(&self, username: &str, password: &str) -> Result
pub async fn edit_username(&self, username: &str, password: &str) -> Result
Edits an username
Sourcepub async fn fetch_user_profile(&self, user_id: UserId) -> Result<Profile>
pub async fn fetch_user_profile(&self, user_id: UserId) -> Result<Profile>
Gets information abot an user profile
pub async fn fetch_mutual_friends(&self, user_id: UserId) -> Result<Vec<UserId>>
Source§impl Http
impl Http
Sourcepub async fn fetch_dm_channels(&self) -> Result<Vec<Channel>>
pub async fn fetch_dm_channels(&self) -> Result<Vec<Channel>>
Gets dm channels / groups.
Sourcepub async fn open_dm(&self, user_id: UserId) -> Result<DirectMessageChannel>
pub async fn open_dm(&self, user_id: UserId) -> Result<DirectMessageChannel>
Opens a dm with user
Source§impl Http
impl Http
Sourcepub async fn fetch_relationships(&self) -> Result<Vec<Relationship>>
pub async fn fetch_relationships(&self) -> Result<Vec<Relationship>>
Fetches relationships of the current user
Sourcepub async fn fetch_relationship(
&self,
user_id: UserId,
) -> Result<SingleRelationshipResponse>
pub async fn fetch_relationship( &self, user_id: UserId, ) -> Result<SingleRelationshipResponse>
Fetches your relationship with the given user
Sourcepub async fn send_friend_request(
&self,
username: &str,
) -> Result<SingleRelationshipResponse>
pub async fn send_friend_request( &self, username: &str, ) -> Result<SingleRelationshipResponse>
Sends or accepts a friend request to / from the user with given username
Sourcepub async fn deny_friend_request(
&self,
username: &str,
) -> Result<SingleRelationshipResponse>
pub async fn deny_friend_request( &self, username: &str, ) -> Result<SingleRelationshipResponse>
Denies a friend request
pub async fn remove_friend( &self, username: &str, ) -> Result<SingleRelationshipResponse>
Sourcepub async fn block_user(
&self,
user_id: UserId,
) -> Result<SingleRelationshipResponse>
pub async fn block_user( &self, user_id: UserId, ) -> Result<SingleRelationshipResponse>
Blocks an user
Sourcepub async fn unblock(
&self,
user_id: UserId,
) -> Result<SingleRelationshipResponse>
pub async fn unblock( &self, user_id: UserId, ) -> Result<SingleRelationshipResponse>
Unblocks an user
Source§impl Http
impl Http
Sourcepub async fn fetch_channel(&self, channel_id: ChannelId) -> Result<Channel>
pub async fn fetch_channel(&self, channel_id: ChannelId) -> Result<Channel>
Gets the channel given the id
Sourcepub async fn edit_channel(
&self,
channel_id: ChannelId,
name: Option<String>,
description: Option<String>,
icon: Option<AttachmentId>,
nsfw: Option<bool>,
remove: Option<ChannelField>,
) -> Result
pub async fn edit_channel( &self, channel_id: ChannelId, name: Option<String>, description: Option<String>, icon: Option<AttachmentId>, nsfw: Option<bool>, remove: Option<ChannelField>, ) -> Result
Edits the channel given by id
Sourcepub async fn close_channel(&self, channel_id: ChannelId) -> Result
pub async fn close_channel(&self, channel_id: ChannelId) -> Result
Closes a channel / leaves group
Sourcepub async fn create_invite(
&self,
channel_id: ChannelId,
) -> Result<CreateChannelInviteResponse>
pub async fn create_invite( &self, channel_id: ChannelId, ) -> Result<CreateChannelInviteResponse>
Creates an invite
Sourcepub async fn set_channel_role_permissions(
&self,
channel_id: ChannelId,
role_id: RoleId,
permissions: ChannelPermissions,
) -> Result
pub async fn set_channel_role_permissions( &self, channel_id: ChannelId, role_id: RoleId, permissions: ChannelPermissions, ) -> Result
Sets role permissions
Sourcepub async fn set_channel_default_role_permissions(
&self,
channel_id: ChannelId,
permissions: ChannelPermissions,
) -> Result
pub async fn set_channel_default_role_permissions( &self, channel_id: ChannelId, permissions: ChannelPermissions, ) -> Result
Sets default permissions
Source§impl Http
impl Http
Sourcepub async fn send_message(
&self,
channel_id: ChannelId,
content: impl AsRef<str>,
nonce: impl AsRef<str>,
attachments: Vec<AttachmentId>,
replies: Vec<ReplyData>,
) -> Result<Message>
pub async fn send_message( &self, channel_id: ChannelId, content: impl AsRef<str>, nonce: impl AsRef<str>, attachments: Vec<AttachmentId>, replies: Vec<ReplyData>, ) -> Result<Message>
Sends a message
Sourcepub async fn fetch_messages(
&self,
channel: ChannelId,
filter: MessageFilter,
) -> Result<FetchMessagesResult>
pub async fn fetch_messages( &self, channel: ChannelId, filter: MessageFilter, ) -> Result<FetchMessagesResult>
Fetches messages
Sourcepub async fn fetch_message(
&self,
channel: ChannelId,
message: MessageId,
) -> Result<Message>
pub async fn fetch_message( &self, channel: ChannelId, message: MessageId, ) -> Result<Message>
Fetches a single message
Sourcepub async fn edit_message(
&self,
channel: ChannelId,
message: MessageId,
content: &str,
) -> Result
pub async fn edit_message( &self, channel: ChannelId, message: MessageId, content: &str, ) -> Result
Edits a message to contain content content
Sourcepub async fn delete_message(
&self,
channel: ChannelId,
message: MessageId,
) -> Result
pub async fn delete_message( &self, channel: ChannelId, message: MessageId, ) -> Result
Deletes a message
pub async fn poll_message_changes( &self, channel: ChannelId, ids: &[MessageId], ) -> Result<PollMessageChangesResponse>
pub async fn acknowledge_message( &self, channel: ChannelId, message: MessageId, ) -> Result
Source§impl Http
impl Http
Sourcepub async fn fetch_server(&self, server: ServerId) -> Result<Server>
pub async fn fetch_server(&self, server: ServerId) -> Result<Server>
Fetches a server
Sourcepub async fn edit_server(
&self,
server_id: ServerId,
server: PartialServer,
remove: ServerField,
) -> Result
pub async fn edit_server( &self, server_id: ServerId, server: PartialServer, remove: ServerField, ) -> Result
Edits a server
Sourcepub async fn delete_server(&self, server_id: ServerId) -> Result
pub async fn delete_server(&self, server_id: ServerId) -> Result
Deletes a server
Sourcepub async fn create_server(
&self,
name: String,
description: Option<String>,
nsfw: Option<bool>,
nonce: String,
) -> Result<Server>
pub async fn create_server( &self, name: String, description: Option<String>, nsfw: Option<bool>, nonce: String, ) -> Result<Server>
Creates a server
Sourcepub async fn create_channel(
&self,
server: ServerId,
kind: ServerChannelType,
name: String,
description: Option<String>,
nonce: String,
) -> Result
pub async fn create_channel( &self, server: ServerId, kind: ServerChannelType, name: String, description: Option<String>, nonce: String, ) -> Result
Creates a channel
Sourcepub async fn fetch_invites(
&self,
server: ServerId,
) -> Result<Vec<FetchInviteResult>>
pub async fn fetch_invites( &self, server: ServerId, ) -> Result<Vec<FetchInviteResult>>
Fetches invites in server
Sourcepub async fn mark_server_as_read(&self, server: ServerId) -> Result
pub async fn mark_server_as_read(&self, server: ServerId) -> Result
Marks server as read
Source§impl Http
impl Http
Sourcepub async fn fetch_member(
&self,
server_id: ServerId,
user_id: UserId,
) -> Result<Member>
pub async fn fetch_member( &self, server_id: ServerId, user_id: UserId, ) -> Result<Member>
Fetches member in server
Sourcepub async fn edit_member(
&self,
server_id: ServerId,
user_id: UserId,
member: PartialMember,
remove: MemberField,
) -> Result
pub async fn edit_member( &self, server_id: ServerId, user_id: UserId, member: PartialMember, remove: MemberField, ) -> Result
Edits member in server
Sourcepub async fn kick_member(&self, server_id: ServerId, user_id: UserId) -> Result
pub async fn kick_member(&self, server_id: ServerId, user_id: UserId) -> Result
Kicks member out of server
Sourcepub async fn fetch_all_members(
&self,
server_id: ServerId,
) -> Result<FetchMembersResult>
pub async fn fetch_all_members( &self, server_id: ServerId, ) -> Result<FetchMembersResult>
Fetches all members in a server
Sourcepub async fn ban_user(
&self,
server_id: ServerId,
user_id: UserId,
reason: Option<&str>,
) -> Result
pub async fn ban_user( &self, server_id: ServerId, user_id: UserId, reason: Option<&str>, ) -> Result
Bans an user from the server
Sourcepub async fn unban_user(&self, server_id: ServerId, user_id: UserId) -> Result
pub async fn unban_user(&self, server_id: ServerId, user_id: UserId) -> Result
Unbans an user from the server
Sourcepub async fn fetch_bans(&self, server_id: ServerId) -> Result<FetchBansResult>
pub async fn fetch_bans(&self, server_id: ServerId) -> Result<FetchBansResult>
Fetches all the users who are banned and the reasons associated with their bans if available
Source§impl Http
impl Http
pub async fn set_role_permissions( &self, server: ServerId, role: RoleId, permissions: PermissionTuple, ) -> Result
pub async fn set_default_role_permissions( &self, server: ServerId, permissions: PermissionTuple, ) -> Result
pub async fn create_role( &self, server: ServerId, name: &str, ) -> Result<RoleIdAndPermissions>
pub async fn delete_role(&self, server: ServerId, role: RoleId) -> Result
Source§impl Http
impl Http
pub async fn create_bot(&self, name: &str) -> Result<Bot>
pub async fn fetch_owned_bots(&self) -> Result<FetchOwnedBotsResponse>
pub async fn fetch_bot(&self, bot: UserId) -> Result<FetchBotResponse>
pub async fn edit_bot( &self, bot: UserId, name: Option<&str>, public: Option<bool>, interactions_url: Option<&str>, remove: Option<BotField>, ) -> Result
pub async fn delete_bot(&self, bot: UserId) -> Result
pub async fn fetch_public_bot(&self, bot: UserId) -> Result<PublicBot>
pub async fn invite_bot(&self, bot: UserId, target: InviteBotTarget) -> Result
Source§impl Http
impl Http
pub async fn fetch_invite(&self, invite: &str) -> Result<RetrievedInvite>
pub async fn join_invite(&self, invite: &str) -> Result<JoinInviteResponse>
pub async fn delete_invite(&self, invite: &str) -> Result
Source§impl Http
impl Http
Sourcepub async fn new<'auth>(
auth: impl Into<HttpAuthentication<'auth>>,
) -> Result<Self>
pub async fn new<'auth>( auth: impl Into<HttpAuthentication<'auth>>, ) -> Result<Self>
Creates a new client from the authentication
Sourcepub async fn new_with_url<'auth>(
auth: impl Into<HttpAuthentication<'auth>>,
api_root: &str,
) -> Result<Self>
pub async fn new_with_url<'auth>( auth: impl Into<HttpAuthentication<'auth>>, api_root: &str, ) -> Result<Self>
Creates a new client from the authentication and url.
Use this if using a self hosted instance of revolt, otherwise use Self::new.
Sourcepub fn get_ws_url(&self) -> &str
pub fn get_ws_url(&self) -> &str
Gets the websocket url
pub async fn get_self_id(&self) -> Result<UserId>
Sourcepub async fn upload_autumn(
&self,
tag: AttachmentTag,
name: String,
bytes: Vec<u8>,
) -> Result<AttachmentId>
pub async fn upload_autumn( &self, tag: AttachmentTag, name: String, bytes: Vec<u8>, ) -> Result<AttachmentId>
Uploads a file to autumn, returning the AttachmentId