pub async fn update_user_alias(&self, user_id: &str, alias: &str) -> Result<(), APIError> {
        let mut a: HashMap<&str, &str> = HashMap::new();
        a.insert("alias", alias);
        // Build the request.
        let request = self.request(DIRECTORY_ENDPOINT, Method::POST, &format!("users/{}/aliases", user_id), a, None);

        let resp = self.client.execute(request).await.unwrap();
        match resp.status() {
            StatusCode::OK => (),
            StatusCode::NOT_FOUND => {
                // Try again. It might just be that the user was just created.
                // TODO: this will result in an endless loop if that is not the case
                // clean this up eventually. Sorry future person.
                println!("Got 404 while updating user alias for user {} alias {}, trying again", user_id, alias);
                //return self.update_user_alias(user_id, alias).await;
            }
            s => {
                let body = resp.text().await.unwrap();

                if body.contains("duplicate") {
                    // Ignore the error because we don't care about if it is a duplicate.
                    return Ok(());
                }

                return Err(APIError { status_code: s, body });
            }
        };

        Ok(())
    }
/// Update an alias for a user.
Update an alias for a user.
Update an alias for a user .
pub async fn update_user_alias(&self, user_id: &str, alias: &str) -> Result<(), APIError> {
        let mut a: HashMap<&str, &str> = HashMap::new();
        a.insert("alias", alias);
        // Build the request.
        let request = self.request(DIRECTORY_ENDPOINT, Method::POST, &format!("users/{}/aliases", user_id), a, None);
        let resp = self.client.execute(request).await.unwrap();
        match resp.status() {
            StatusCode::OK => (),
            StatusCode::NOT_FOUND => {
                // Try again. It might just be that the user was just created.
                // TODO: this will result in an endless loop if that is not the case
                // clean this up eventually. Sorry future person.
                println!("Got 404 while updating user alias for user {} alias {}, trying again", user_id, alias);
                //return self.update_user_alias(user_id, alias).await;
            }
            s => {
                let body = resp.text().await.unwrap();
                if body.contains("duplicate") {
                    // Ignore the error because we don't care about if it is a duplicate.
                    return Ok(());
                }
                return Err(APIError { status_code: s, body });
            }
        };
        Ok(())
    }
pub async fn update_user_alias ( & self , user_id : & str , alias : & str ) -> Result < ( ) , APIError > { let mut a : HashMap < & str , & str > = HashMap :: new ( ) ; a . insert ( " " , alias ) ; // Build the request. let request = self . request ( DIRECTORY_ENDPOINT , Method :: POST , & format ! ( " " user_id ) , a , None ) ; let resp = self . client . execute ( request ) . await . unwrap ( ) ; match resp . status ( ) { StatusCode :: OK => ( ) , StatusCode :: NOT_FOUND => { // Try again. It might just be that the user was just created. // TODO: this will result in an endless loop if that is not the case // clean this up eventually. Sorry future person. println ! ( " " user_id alias ) ; //return self.update_user_alias(user_id, alias).await; } s => { let body = resp . text ( ) . await . unwrap ( ) ; if body . contains ( " " ) { // Ignore the error because we don't care about if it is a duplicate. return Ok ( ( ) ) ; } return Err ( APIError { status_code : s , body } ) ; } } ; Ok ( ( ) ) }
Update an alias for a user.
Update an alias for a user .
&self
user_id
&str
alias
&str
&self
user_id
&str
alias
&str