async fn request_users<'a, 'b>(
        &self,
        filter: &'b str,
    ) -> Result<Option<ProfileId>, reqwest::Error> {
        let params: HashMap<&str, &str> = [("filter", filter)].iter().cloned().collect();

        println!("Requesting users");
        let result: UserSearchResult = self
            .client
            .get(&self.make_api_url("/toro/chat/api/v2/users"))
            .bearer_auth(&self.connection.oauth_token)
            .query(&params)
            .send()
            .await?
            .json()
            .await?;

        let mut profiles: Vec<JustUserProfile> = result.items;
        if !profiles.is_empty() && profiles.len() == 1 {
            // call .remove, it allows us to take ownership and return the ProfileId struct
            // another option would be to call nth(), which would also allow us to remove mut
            return Ok(Some(profiles.remove(0).id.to_profile_id()));
        } else {
            info!(
                "Too many results for user search '{}'. Expected to find exactly one result.",
                filter
            );
            debug!("Profiles length is {}", profiles.len());
            return Ok(None);
        }
    }
// Error message is valid as long the access token, as it's related to the API request
Error message is valid as long the access token, as it's related to the API request
Error message is valid as long the access token as it ' s related to the API request
async fn request_users<'a, 'b>(
        &self,
        filter: &'b str,
    ) -> Result<Option<ProfileId>, reqwest::Error> {
        let params: HashMap<&str, &str> = [("filter", filter)].iter().cloned().collect();
        println!("Requesting users");
        let result: UserSearchResult = self
            .client
            .get(&self.make_api_url("/toro/chat/api/v2/users"))
            .bearer_auth(&self.connection.oauth_token)
            .query(&params)
            .send()
            .await?
            .json()
            .await?;
        let mut profiles: Vec<JustUserProfile> = result.items;
        if !profiles.is_empty() && profiles.len() == 1 {
            // call .remove, it allows us to take ownership and return the ProfileId struct
            // another option would be to call nth(), which would also allow us to remove mut
            return Ok(Some(profiles.remove(0).id.to_profile_id()));
        } else {
            info!(
                "Too many results for user search '{}'. Expected to find exactly one result.",
                filter
            );
            debug!("Profiles length is {}", profiles.len());
            return Ok(None);
        }
    }
async fn request_users < ' a , ' b > ( & self , filter : & ' b str , ) -> Result < Option < ProfileId > , reqwest :: Error > { let params : HashMap < & str , & str > = [ ( " " , filter ) ] . iter ( ) . cloned ( ) . collect ( ) ; println ! ( " " ) ; let result : UserSearchResult = self . client . get ( & self . make_api_url ( " " ) ) . bearer_auth ( & self . connection . oauth_token ) . query ( & params ) . send ( ) . await ? . json ( ) . await ? ; let mut profiles : Vec < JustUserProfile > = result . items ; if ! profiles . is_empty ( ) && profiles . len ( ) == 1 { // call .remove, it allows us to take ownership and return the ProfileId struct // another option would be to call nth(), which would also allow us to remove mut return Ok ( Some ( profiles . remove ( 0 ) . id . to_profile_id ( ) ) ) ; } else { info ! ( " " filter ) ; debug ! ( " " profiles len ( ) ) ; return Ok ( None ) ; } }
Error message is valid as long the access token, as it's related to the API request
Error message is valid as long the access token as it ' s related to the API request
&self
filter
&'b str
&self
filter
&'b str