feat!: add get_user_profile query string schema
This commit is contained in:
parent
e6a4cc30a6
commit
1fa84b4b63
|
@ -12,9 +12,7 @@ use crate::{
|
|||
instance::{ChorusUser, Instance},
|
||||
ratelimiter::ChorusRequest,
|
||||
types::{
|
||||
DeleteDisableUserSchema, LimitType, PublicUser, Snowflake, User, UserModifyProfileSchema,
|
||||
UserModifySchema, UserProfile, UserProfileMetadata, UserSettings,
|
||||
VerifyUserEmailChangeResponse, VerifyUserEmailChangeSchema,
|
||||
DeleteDisableUserSchema, GetUserProfileSchema, LimitType, PublicUser, Snowflake, User, UserModifyProfileSchema, UserModifySchema, UserProfile, UserProfileMetadata, UserSettings, VerifyUserEmailChangeResponse, VerifyUserEmailChangeSchema
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -174,8 +172,8 @@ impl ChorusUser {
|
|||
///
|
||||
/// # Reference
|
||||
/// See <https://docs.discord.sex/resources/user#get-user-profile>
|
||||
pub async fn get_user_profile(&mut self, id: Snowflake) -> ChorusResult<UserProfile> {
|
||||
User::get_profile(self, id).await
|
||||
pub async fn get_user_profile(&mut self, id: Snowflake, query_parameters: GetUserProfileSchema) -> ChorusResult<UserProfile> {
|
||||
User::get_profile(self, id, query_parameters).await
|
||||
}
|
||||
|
||||
/// Modifies the current user's profile.
|
||||
|
@ -355,12 +353,13 @@ impl User {
|
|||
///
|
||||
/// # Reference
|
||||
/// See <https://docs.discord.sex/resources/user#get-user-profile>
|
||||
// TODO: Implement query string parameters for this endpoint
|
||||
pub async fn get_profile(user: &mut ChorusUser, id: Snowflake) -> ChorusResult<UserProfile> {
|
||||
pub async fn get_profile(user: &mut ChorusUser, id: Snowflake, query_parameters: GetUserProfileSchema) -> ChorusResult<UserProfile> {
|
||||
let url_api = user.belongs_to.read().unwrap().urls.api.clone();
|
||||
let request: reqwest::RequestBuilder = Client::new()
|
||||
.get(format!("{}/users/{}/profile", url_api, id))
|
||||
.header("Authorization", user.token());
|
||||
.header("Authorization", user.token())
|
||||
.query(&query_parameters);
|
||||
|
||||
let chorus_request = ChorusRequest {
|
||||
request,
|
||||
limit_type: LimitType::Global,
|
||||
|
|
|
@ -181,3 +181,35 @@ pub struct VerifyUserEmailChangeResponse {
|
|||
#[serde(rename = "token")]
|
||||
pub email_token: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
|
||||
/// Query string parameters for the route GET /users/{user.id}/profile
|
||||
/// ([crate::types::User::get_profile])
|
||||
///
|
||||
/// See <https://docs.discord.sex/resources/user#get-user-profile>
|
||||
pub struct GetUserProfileSchema {
|
||||
/// Whether to include the mutual guilds between the current user.
|
||||
///
|
||||
/// If unset it will default to true
|
||||
pub with_mutual_guilds: Option<bool>,
|
||||
/// Whether to include the mutual friends between the current user.
|
||||
///
|
||||
/// If unset it will default to false
|
||||
pub with_mutual_friends: Option<bool>,
|
||||
/// Whether to include the number of mutual friends between the current user
|
||||
///
|
||||
/// If unset it will default to false
|
||||
pub with_mutual_friends_count: Option<bool>,
|
||||
/// The guild id to get the user's member profile in, if any.
|
||||
///
|
||||
/// Note:
|
||||
///
|
||||
/// when you click on a user in the member list in the discord client, a request is sent with
|
||||
/// this property set to the selected guild id.
|
||||
///
|
||||
/// This makes the request include fields such as guild_member and guild_member_profile
|
||||
pub guild_id: Option<Snowflake>,
|
||||
/// The role id to get the user's application role connection metadata in, if any.
|
||||
pub connections_role_id: Option<Snowflake>,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue