diff --git a/src/api/users/users.rs b/src/api/users/users.rs index c8ef4b5..b49f4a6 100644 --- a/src/api/users/users.rs +++ b/src/api/users/users.rs @@ -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 - pub async fn get_user_profile(&mut self, id: Snowflake) -> ChorusResult { - User::get_profile(self, id).await + pub async fn get_user_profile(&mut self, id: Snowflake, query_parameters: GetUserProfileSchema) -> ChorusResult { + User::get_profile(self, id, query_parameters).await } /// Modifies the current user's profile. @@ -355,12 +353,13 @@ impl User { /// /// # Reference /// See - // TODO: Implement query string parameters for this endpoint - pub async fn get_profile(user: &mut ChorusUser, id: Snowflake) -> ChorusResult { + pub async fn get_profile(user: &mut ChorusUser, id: Snowflake, query_parameters: GetUserProfileSchema) -> ChorusResult { 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, diff --git a/src/types/schema/user.rs b/src/types/schema/user.rs index 904ff54..a53298a 100644 --- a/src/types/schema/user.rs +++ b/src/types/schema/user.rs @@ -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 +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, + /// Whether to include the mutual friends between the current user. + /// + /// If unset it will default to false + pub with_mutual_friends: Option, + /// 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, + /// 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, + /// The role id to get the user's application role connection metadata in, if any. + pub connections_role_id: Option, +} +